From a1d19711f36707651f14733670eb2454fc975705 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 24 Jun 2022 17:48:18 +0000 Subject: [PATCH] feat: Enable REST transport for most of Java and Go clients (#941) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 456641589 Source-Link: https://github.com/googleapis/googleapis/commit/8a251f5225b789b2383207ffd978f6aa3d77fcf7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9 --- .../google-cloud-dialogflow/pom.xml | 16 + .../cloud/dialogflow/v2/AgentsClient.java | 37 +- .../cloud/dialogflow/v2/AgentsSettings.java | 23 +- .../dialogflow/v2/AnswerRecordsClient.java | 14 + .../dialogflow/v2/AnswerRecordsSettings.java | 23 +- .../cloud/dialogflow/v2/ContextsClient.java | 14 + .../cloud/dialogflow/v2/ContextsSettings.java | 23 +- .../v2/ConversationDatasetsClient.java | 38 +- .../v2/ConversationDatasetsSettings.java | 23 +- .../v2/ConversationModelsClient.java | 38 +- .../v2/ConversationModelsSettings.java | 23 +- .../v2/ConversationProfilesClient.java | 38 +- .../v2/ConversationProfilesSettings.java | 23 +- .../dialogflow/v2/ConversationsClient.java | 14 + .../dialogflow/v2/ConversationsSettings.java | 23 +- .../cloud/dialogflow/v2/DocumentsClient.java | 37 +- .../dialogflow/v2/DocumentsSettings.java | 23 +- .../dialogflow/v2/EntityTypesClient.java | 37 +- .../dialogflow/v2/EntityTypesSettings.java | 23 +- .../dialogflow/v2/EnvironmentsClient.java | 14 + .../dialogflow/v2/EnvironmentsSettings.java | 23 +- .../dialogflow/v2/FulfillmentsClient.java | 14 + .../dialogflow/v2/FulfillmentsSettings.java | 23 +- .../cloud/dialogflow/v2/IntentsClient.java | 37 +- .../cloud/dialogflow/v2/IntentsSettings.java | 23 +- .../dialogflow/v2/KnowledgeBasesClient.java | 14 + .../dialogflow/v2/KnowledgeBasesSettings.java | 23 +- .../dialogflow/v2/ParticipantsClient.java | 14 + .../dialogflow/v2/ParticipantsSettings.java | 23 +- .../v2/SessionEntityTypesClient.java | 15 + .../v2/SessionEntityTypesSettings.java | 23 +- .../cloud/dialogflow/v2/SessionsClient.java | 14 + .../cloud/dialogflow/v2/SessionsSettings.java | 23 +- .../cloud/dialogflow/v2/VersionsClient.java | 14 + .../cloud/dialogflow/v2/VersionsSettings.java | 23 +- .../cloud/dialogflow/v2/stub/AgentsStub.java | 6 +- .../v2/stub/AgentsStubSettings.java | 52 +- .../v2/stub/AnswerRecordsStubSettings.java | 53 +- .../v2/stub/ContextsStubSettings.java | 52 +- .../v2/stub/ConversationDatasetsStub.java | 6 +- .../ConversationDatasetsStubSettings.java | 53 +- .../v2/stub/ConversationModelsStub.java | 6 +- .../stub/ConversationModelsStubSettings.java | 53 +- .../v2/stub/ConversationProfilesStub.java | 6 +- .../ConversationProfilesStubSettings.java | 53 +- .../v2/stub/ConversationsStubSettings.java | 53 +- .../dialogflow/v2/stub/DocumentsStub.java | 6 +- .../v2/stub/DocumentsStubSettings.java | 52 +- .../dialogflow/v2/stub/EntityTypesStub.java | 6 +- .../v2/stub/EntityTypesStubSettings.java | 53 +- .../v2/stub/EnvironmentsStubSettings.java | 53 +- .../v2/stub/FulfillmentsStubSettings.java | 53 +- .../stub/HttpJsonAgentsCallableFactory.java | 105 + .../v2/stub/HttpJsonAgentsStub.java | 705 +++++++ .../HttpJsonAnswerRecordsCallableFactory.java | 105 + .../v2/stub/HttpJsonAnswerRecordsStub.java | 275 +++ .../stub/HttpJsonContextsCallableFactory.java | 105 + .../v2/stub/HttpJsonContextsStub.java | 482 +++++ ...onConversationDatasetsCallableFactory.java | 105 + .../HttpJsonConversationDatasetsStub.java | 541 ++++++ ...JsonConversationModelsCallableFactory.java | 105 + .../stub/HttpJsonConversationModelsStub.java | 847 +++++++++ ...onConversationProfilesCallableFactory.java | 105 + .../HttpJsonConversationProfilesStub.java | 650 +++++++ .../HttpJsonConversationsCallableFactory.java | 105 + .../v2/stub/HttpJsonConversationsStub.java | 448 +++++ .../HttpJsonDocumentsCallableFactory.java | 105 + .../v2/stub/HttpJsonDocumentsStub.java | 714 +++++++ .../HttpJsonEntityTypesCallableFactory.java | 105 + .../v2/stub/HttpJsonEntityTypesStub.java | 819 ++++++++ .../HttpJsonEnvironmentsCallableFactory.java | 105 + .../v2/stub/HttpJsonEnvironmentsStub.java | 506 +++++ .../HttpJsonFulfillmentsCallableFactory.java | 105 + .../v2/stub/HttpJsonFulfillmentsStub.java | 250 +++ .../stub/HttpJsonIntentsCallableFactory.java | 105 + .../v2/stub/HttpJsonIntentsStub.java | 589 ++++++ ...HttpJsonKnowledgeBasesCallableFactory.java | 105 + .../v2/stub/HttpJsonKnowledgeBasesStub.java | 446 +++++ .../HttpJsonParticipantsCallableFactory.java | 105 + .../v2/stub/HttpJsonParticipantsStub.java | 612 ++++++ ...JsonSessionEntityTypesCallableFactory.java | 105 + .../stub/HttpJsonSessionEntityTypesStub.java | 470 +++++ .../stub/HttpJsonSessionsCallableFactory.java | 105 + .../v2/stub/HttpJsonSessionsStub.java | 197 ++ .../stub/HttpJsonVersionsCallableFactory.java | 105 + .../v2/stub/HttpJsonVersionsStub.java | 413 ++++ .../cloud/dialogflow/v2/stub/IntentsStub.java | 6 +- .../v2/stub/IntentsStubSettings.java | 52 +- .../v2/stub/KnowledgeBasesStubSettings.java | 53 +- .../v2/stub/ParticipantsStubSettings.java | 53 +- .../stub/SessionEntityTypesStubSettings.java | 53 +- .../v2/stub/SessionsStubSettings.java | 52 +- .../v2/stub/VersionsStubSettings.java | 52 +- .../dialogflow/v2beta1/AgentsClient.java | 37 +- .../dialogflow/v2beta1/AgentsSettings.java | 23 +- .../v2beta1/AnswerRecordsClient.java | 14 + .../v2beta1/AnswerRecordsSettings.java | 23 +- .../dialogflow/v2beta1/ContextsClient.java | 14 + .../dialogflow/v2beta1/ContextsSettings.java | 23 +- .../v2beta1/ConversationProfilesClient.java | 38 +- .../v2beta1/ConversationProfilesSettings.java | 23 +- .../v2beta1/ConversationsClient.java | 14 + .../v2beta1/ConversationsSettings.java | 23 +- .../dialogflow/v2beta1/DocumentsClient.java | 37 +- .../dialogflow/v2beta1/DocumentsSettings.java | 23 +- .../dialogflow/v2beta1/EntityTypesClient.java | 37 +- .../v2beta1/EntityTypesSettings.java | 23 +- .../v2beta1/EnvironmentsClient.java | 14 + .../v2beta1/EnvironmentsSettings.java | 23 +- .../v2beta1/FulfillmentsClient.java | 14 + .../v2beta1/FulfillmentsSettings.java | 23 +- .../dialogflow/v2beta1/IntentsClient.java | 37 +- .../dialogflow/v2beta1/IntentsSettings.java | 23 +- .../v2beta1/KnowledgeBasesClient.java | 14 + .../v2beta1/KnowledgeBasesSettings.java | 23 +- .../v2beta1/ParticipantsClient.java | 14 + .../v2beta1/ParticipantsSettings.java | 23 +- .../v2beta1/SessionEntityTypesClient.java | 15 + .../v2beta1/SessionEntityTypesSettings.java | 23 +- .../dialogflow/v2beta1/SessionsClient.java | 14 + .../dialogflow/v2beta1/SessionsSettings.java | 23 +- .../dialogflow/v2beta1/VersionsClient.java | 14 + .../dialogflow/v2beta1/VersionsSettings.java | 23 +- .../dialogflow/v2beta1/stub/AgentsStub.java | 6 +- .../v2beta1/stub/AgentsStubSettings.java | 52 +- .../stub/AnswerRecordsStubSettings.java | 53 +- .../v2beta1/stub/ContextsStubSettings.java | 52 +- .../stub/ConversationProfilesStub.java | 6 +- .../ConversationProfilesStubSettings.java | 53 +- .../stub/ConversationsStubSettings.java | 53 +- .../v2beta1/stub/DocumentsStub.java | 6 +- .../v2beta1/stub/DocumentsStubSettings.java | 52 +- .../v2beta1/stub/EntityTypesStub.java | 6 +- .../v2beta1/stub/EntityTypesStubSettings.java | 53 +- .../stub/EnvironmentsStubSettings.java | 53 +- .../stub/FulfillmentsStubSettings.java | 53 +- .../stub/HttpJsonAgentsCallableFactory.java | 105 + .../v2beta1/stub/HttpJsonAgentsStub.java | 705 +++++++ .../HttpJsonAnswerRecordsCallableFactory.java | 105 + .../stub/HttpJsonAnswerRecordsStub.java | 324 ++++ .../stub/HttpJsonContextsCallableFactory.java | 105 + .../v2beta1/stub/HttpJsonContextsStub.java | 482 +++++ ...onConversationProfilesCallableFactory.java | 105 + .../HttpJsonConversationProfilesStub.java | 650 +++++++ .../HttpJsonConversationsCallableFactory.java | 105 + .../stub/HttpJsonConversationsStub.java | 511 +++++ .../HttpJsonDocumentsCallableFactory.java | 105 + .../v2beta1/stub/HttpJsonDocumentsStub.java | 647 +++++++ .../HttpJsonEntityTypesCallableFactory.java | 105 + .../v2beta1/stub/HttpJsonEntityTypesStub.java | 825 ++++++++ .../HttpJsonEnvironmentsCallableFactory.java | 105 + .../stub/HttpJsonEnvironmentsStub.java | 511 +++++ .../HttpJsonFulfillmentsCallableFactory.java | 105 + .../stub/HttpJsonFulfillmentsStub.java | 251 +++ .../stub/HttpJsonIntentsCallableFactory.java | 105 + .../v2beta1/stub/HttpJsonIntentsStub.java | 589 ++++++ ...HttpJsonKnowledgeBasesCallableFactory.java | 105 + .../stub/HttpJsonKnowledgeBasesStub.java | 450 +++++ .../HttpJsonParticipantsCallableFactory.java | 105 + .../stub/HttpJsonParticipantsStub.java | 737 +++++++ ...JsonSessionEntityTypesCallableFactory.java | 105 + .../stub/HttpJsonSessionEntityTypesStub.java | 470 +++++ .../stub/HttpJsonSessionsCallableFactory.java | 105 + .../v2beta1/stub/HttpJsonSessionsStub.java | 197 ++ .../stub/HttpJsonVersionsCallableFactory.java | 105 + .../v2beta1/stub/HttpJsonVersionsStub.java | 413 ++++ .../dialogflow/v2beta1/stub/IntentsStub.java | 6 +- .../v2beta1/stub/IntentsStubSettings.java | 52 +- .../stub/KnowledgeBasesStubSettings.java | 53 +- .../stub/ParticipantsStubSettings.java | 53 +- .../stub/SessionEntityTypesStubSettings.java | 53 +- .../v2beta1/stub/SessionsStubSettings.java | 52 +- .../v2beta1/stub/VersionsStubSettings.java | 52 +- .../v2/AgentsClientHttpJsonTest.java | 1002 ++++++++++ .../v2/AnswerRecordsClientHttpJsonTest.java | 289 +++ .../v2/ContextsClientHttpJsonTest.java | 603 ++++++ ...onversationDatasetsClientHttpJsonTest.java | 509 +++++ .../ConversationModelsClientHttpJsonTest.java | 622 ++++++ ...onversationProfilesClientHttpJsonTest.java | 870 +++++++++ .../v2/ConversationsClientHttpJsonTest.java | 712 +++++++ .../v2/DocumentsClientHttpJsonTest.java | 858 +++++++++ .../v2/EntityTypesClientHttpJsonTest.java | 1623 ++++++++++++++++ .../v2/EnvironmentsClientHttpJsonTest.java | 491 +++++ .../v2/FulfillmentsClientHttpJsonTest.java | 230 +++ .../v2/IntentsClientHttpJsonTest.java | 1386 ++++++++++++++ .../v2/KnowledgeBasesClientHttpJsonTest.java | 623 ++++++ .../v2/ParticipantsClientHttpJsonTest.java | 977 ++++++++++ .../SessionEntityTypesClientHttpJsonTest.java | 591 ++++++ .../v2/SessionsClientHttpJsonTest.java | 180 ++ .../v2/VersionsClientHttpJsonTest.java | 512 +++++ .../v2beta1/AgentsClientHttpJsonTest.java | 1002 ++++++++++ .../AnswerRecordsClientHttpJsonTest.java | 342 ++++ .../v2beta1/ContextsClientHttpJsonTest.java | 665 +++++++ ...onversationProfilesClientHttpJsonTest.java | 870 +++++++++ .../ConversationsClientHttpJsonTest.java | 799 ++++++++ .../v2beta1/DocumentsClientHttpJsonTest.java | 866 +++++++++ .../EntityTypesClientHttpJsonTest.java | 1689 +++++++++++++++++ .../EnvironmentsClientHttpJsonTest.java | 491 +++++ .../FulfillmentsClientHttpJsonTest.java | 230 +++ .../v2beta1/IntentsClientHttpJsonTest.java | 1616 ++++++++++++++++ .../KnowledgeBasesClientHttpJsonTest.java | 685 +++++++ .../ParticipantsClientHttpJsonTest.java | 1106 +++++++++++ .../SessionEntityTypesClientHttpJsonTest.java | 591 ++++++ .../v2beta1/SessionsClientHttpJsonTest.java | 183 ++ .../v2beta1/VersionsClientHttpJsonTest.java | 512 +++++ .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 37 + .../deleteagent/AsyncDeleteAgent.java | 44 + .../deleteagent/SyncDeleteAgent.java | 40 + .../SyncDeleteAgentLocationname.java | 38 + .../SyncDeleteAgentProjectname.java | 38 + .../deleteagent/SyncDeleteAgentString.java | 38 + .../exportagent/AsyncExportAgent.java | 47 + .../exportagent/AsyncExportAgentLRO.java | 49 + .../exportagent/SyncExportAgent.java | 44 + .../SyncExportAgentLocationname.java | 39 + .../SyncExportAgentProjectname.java | 39 + .../exportagent/SyncExportAgentString.java | 39 + .../agentsclient/getagent/AsyncGetAgent.java | 44 + .../agentsclient/getagent/SyncGetAgent.java | 41 + .../getagent/SyncGetAgentLocationname.java | 39 + .../getagent/SyncGetAgentProjectname.java | 39 + .../getagent/SyncGetAgentString.java | 39 + .../AsyncGetValidationResult.java | 48 + .../SyncGetValidationResult.java | 44 + .../importagent/AsyncImportAgent.java | 44 + .../importagent/AsyncImportAgentLRO.java | 46 + .../importagent/SyncImportAgent.java | 40 + .../restoreagent/AsyncRestoreAgent.java | 46 + .../restoreagent/AsyncRestoreAgentLRO.java | 48 + .../restoreagent/SyncRestoreAgent.java | 42 + .../searchagents/AsyncSearchAgents.java | 50 + .../searchagents/AsyncSearchAgentsPaged.java | 58 + .../searchagents/SyncSearchAgents.java | 47 + .../SyncSearchAgentsLocationname.java | 41 + .../SyncSearchAgentsProjectname.java | 41 + .../searchagents/SyncSearchAgentsString.java | 41 + .../agentsclient/setagent/AsyncSetAgent.java | 47 + .../agentsclient/setagent/SyncSetAgent.java | 44 + .../setagent/SyncSetAgentAgent.java | 38 + .../trainagent/AsyncTrainAgent.java | 44 + .../trainagent/AsyncTrainAgentLRO.java | 46 + .../trainagent/SyncTrainAgent.java | 40 + .../SyncTrainAgentLocationname.java | 38 + .../trainagent/SyncTrainAgentProjectname.java | 38 + .../trainagent/SyncTrainAgentString.java | 38 + .../agentssettings/getagent/SyncGetAgent.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncListAnswerRecords.java | 52 + .../AsyncListAnswerRecordsPaged.java | 60 + .../SyncListAnswerRecords.java | 48 + .../SyncListAnswerRecordsLocationname.java | 41 + .../SyncListAnswerRecordsProjectname.java | 41 + .../SyncListAnswerRecordsString.java | 41 + .../AsyncUpdateAnswerRecord.java | 48 + .../SyncUpdateAnswerRecord.java | 44 + ...dateAnswerRecordAnswerrecordFieldmask.java | 40 + .../SyncUpdateAnswerRecord.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createcontext/AsyncCreateContext.java | 47 + .../createcontext/SyncCreateContext.java | 44 + .../SyncCreateContextSessionnameContext.java | 40 + .../SyncCreateContextStringContext.java | 40 + .../AsyncDeleteAllContexts.java | 46 + .../SyncDeleteAllContexts.java | 42 + .../SyncDeleteAllContextsSessionname.java | 38 + .../SyncDeleteAllContextsString.java | 38 + .../deletecontext/AsyncDeleteContext.java | 48 + .../deletecontext/SyncDeleteContext.java | 44 + .../SyncDeleteContextContextname.java | 39 + .../SyncDeleteContextString.java | 39 + .../getcontext/AsyncGetContext.java | 48 + .../getcontext/SyncGetContext.java | 45 + .../getcontext/SyncGetContextContextname.java | 40 + .../getcontext/SyncGetContextString.java | 40 + .../listcontexts/AsyncListContexts.java | 50 + .../listcontexts/AsyncListContextsPaged.java | 58 + .../listcontexts/SyncListContexts.java | 47 + .../SyncListContextsSessionname.java | 41 + .../listcontexts/SyncListContextsString.java | 41 + .../updatecontext/AsyncUpdateContext.java | 47 + .../updatecontext/SyncUpdateContext.java | 44 + .../SyncUpdateContextContextFieldmask.java | 40 + .../getcontext/SyncGetContext.java | 45 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateConversationDataset.java | 49 + .../AsyncCreateConversationDatasetLRO.java | 51 + .../SyncCreateConversationDataset.java | 45 + ...ationDatasetStringConversationdataset.java | 45 + .../AsyncDeleteConversationDataset.java | 50 + .../AsyncDeleteConversationDatasetLRO.java | 53 + .../SyncDeleteConversationDataset.java | 45 + ...rsationDatasetConversationdatasetname.java | 42 + .../SyncDeleteConversationDatasetString.java | 41 + .../AsyncGetConversationDataset.java | 50 + .../SyncGetConversationDataset.java | 46 + ...rsationDatasetConversationdatasetname.java | 43 + .../SyncGetConversationDatasetString.java | 42 + .../AsyncImportConversationData.java | 52 + .../AsyncImportConversationDataLRO.java | 57 + .../SyncImportConversationData.java | 49 + .../AsyncListConversationDatasets.java | 52 + .../AsyncListConversationDatasetsPaged.java | 60 + .../SyncListConversationDatasets.java | 49 + ...cListConversationDatasetsLocationname.java | 45 + .../SyncListConversationDatasetsString.java | 43 + .../SyncGetConversationDataset.java | 47 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateConversationModel.java | 48 + .../AsyncCreateConversationModelLRO.java | 48 + .../SyncCreateConversationModel.java | 44 + ...versationModelStringConversationmodel.java | 42 + ...syncCreateConversationModelEvaluation.java | 52 + ...cCreateConversationModelEvaluationLRO.java | 58 + ...SyncCreateConversationModelEvaluation.java | 48 + ...nmodelnameConversationmodelevaluation.java | 50 + ...tionStringConversationmodelevaluation.java | 50 + .../AsyncDeleteConversationModel.java | 44 + .../AsyncDeleteConversationModelLRO.java | 45 + .../SyncDeleteConversationModel.java | 39 + .../SyncDeleteConversationModelString.java | 37 + .../AsyncDeployConversationModel.java | 44 + .../AsyncDeployConversationModelLRO.java | 45 + .../SyncDeployConversationModel.java | 39 + .../AsyncGetConversationModel.java | 44 + .../SyncGetConversationModel.java | 40 + .../SyncGetConversationModelString.java | 38 + .../AsyncGetConversationModelEvaluation.java | 44 + .../SyncGetConversationModelEvaluation.java | 41 + ...cGetConversationModelEvaluationString.java | 40 + ...AsyncListConversationModelEvaluations.java | 52 + ...ListConversationModelEvaluationsPaged.java | 60 + .../SyncListConversationModelEvaluations.java | 47 + ...istConversationModelEvaluationsString.java | 43 + .../AsyncListConversationModels.java | 50 + .../AsyncListConversationModelsPaged.java | 58 + .../SyncListConversationModels.java | 47 + .../SyncListConversationModelsString.java | 41 + .../AsyncUndeployConversationModel.java | 44 + .../AsyncUndeployConversationModelLRO.java | 45 + .../SyncUndeployConversationModel.java | 39 + .../SyncGetConversationModel.java | 47 + .../AsyncClearSuggestionFeatureConfig.java | 47 + .../AsyncClearSuggestionFeatureConfigLRO.java | 50 + .../SyncClearSuggestionFeatureConfig.java | 44 + ...yncClearSuggestionFeatureConfigString.java | 41 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateConversationProfile.java | 49 + .../SyncCreateConversationProfile.java | 45 + ...rofileLocationnameConversationprofile.java | 45 + ...ProfileProjectnameConversationprofile.java | 45 + ...ationProfileStringConversationprofile.java | 44 + .../AsyncDeleteConversationProfile.java | 51 + .../SyncDeleteConversationProfile.java | 46 + ...rsationProfileConversationprofilename.java | 43 + .../SyncDeleteConversationProfileString.java | 42 + .../AsyncGetConversationProfile.java | 51 + .../SyncGetConversationProfile.java | 47 + ...rsationProfileConversationprofilename.java | 44 + .../SyncGetConversationProfileString.java | 43 + .../AsyncListConversationProfiles.java | 52 + .../AsyncListConversationProfilesPaged.java | 60 + .../SyncListConversationProfiles.java | 49 + ...cListConversationProfilesLocationname.java | 45 + ...ncListConversationProfilesProjectname.java | 45 + .../SyncListConversationProfilesString.java | 43 + .../AsyncSetSuggestionFeatureConfig.java | 50 + .../AsyncSetSuggestionFeatureConfigLRO.java | 53 + .../SyncSetSuggestionFeatureConfig.java | 47 + .../SyncSetSuggestionFeatureConfigString.java | 40 + .../AsyncUpdateConversationProfile.java | 49 + .../SyncUpdateConversationProfile.java | 45 + ...onProfileConversationprofileFieldmask.java | 44 + .../SyncGetConversationProfile.java | 47 + .../AsyncCompleteConversation.java | 49 + .../SyncCompleteConversation.java | 45 + ...cCompleteConversationConversationname.java | 40 + .../SyncCompleteConversationString.java | 40 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncCreateConversation.java | 49 + .../SyncCreateConversation.java | 45 + ...eConversationLocationnameConversation.java | 42 + ...teConversationProjectnameConversation.java | 41 + ...cCreateConversationStringConversation.java | 40 + .../getconversation/AsyncGetConversation.java | 49 + .../getconversation/SyncGetConversation.java | 45 + .../SyncGetConversationConversationname.java | 40 + .../SyncGetConversationString.java | 40 + .../AsyncListConversations.java | 52 + .../AsyncListConversationsPaged.java | 60 + .../SyncListConversations.java | 48 + .../SyncListConversationsLocationname.java | 41 + .../SyncListConversationsProjectname.java | 41 + .../SyncListConversationsString.java | 41 + .../listmessages/AsyncListMessages.java | 54 + .../listmessages/AsyncListMessagesPaged.java | 61 + .../listmessages/SyncListMessages.java | 50 + .../SyncListMessagesConversationname.java | 42 + .../listmessages/SyncListMessagesString.java | 42 + .../SyncCreateConversation.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createdocument/AsyncCreateDocument.java | 50 + .../AsyncCreateDocumentLRO.java | 51 + .../createdocument/SyncCreateDocument.java | 46 + ...eateDocumentKnowledgebasenameDocument.java | 41 + .../SyncCreateDocumentStringDocument.java | 41 + .../deletedocument/AsyncDeleteDocument.java | 49 + .../AsyncDeleteDocumentLRO.java | 51 + .../deletedocument/SyncDeleteDocument.java | 45 + .../SyncDeleteDocumentDocumentname.java | 40 + .../SyncDeleteDocumentString.java | 41 + .../exportdocument/AsyncExportDocument.java | 51 + .../AsyncExportDocumentLRO.java | 53 + .../exportdocument/SyncExportDocument.java | 48 + .../getdocument/AsyncGetDocument.java | 49 + .../getdocument/SyncGetDocument.java | 46 + .../SyncGetDocumentDocumentname.java | 41 + .../getdocument/SyncGetDocumentString.java | 42 + .../importdocuments/AsyncImportDocuments.java | 51 + .../AsyncImportDocumentsLRO.java | 53 + .../importdocuments/SyncImportDocuments.java | 48 + .../listdocuments/AsyncListDocuments.java | 53 + .../AsyncListDocumentsPaged.java | 61 + .../listdocuments/SyncListDocuments.java | 50 + .../SyncListDocumentsKnowledgebasename.java | 42 + .../SyncListDocumentsString.java | 42 + .../reloaddocument/AsyncReloadDocument.java | 51 + .../AsyncReloadDocumentLRO.java | 53 + .../reloaddocument/SyncReloadDocument.java | 48 + .../SyncReloadDocumentDocumentnameString.java | 42 + .../SyncReloadDocumentStringString.java | 43 + .../updatedocument/AsyncUpdateDocument.java | 48 + .../AsyncUpdateDocumentLRO.java | 49 + .../updatedocument/SyncUpdateDocument.java | 44 + .../SyncUpdateDocumentDocumentFieldmask.java | 40 + .../getdocument/SyncGetDocument.java | 45 + .../AsyncBatchCreateEntities.java | 52 + .../AsyncBatchCreateEntitiesLRO.java | 53 + .../SyncBatchCreateEntities.java | 47 + ...iesEntitytypenameListentitytypeentity.java | 44 + ...itytypenameListentitytypeentityString.java | 46 + ...ateEntitiesStringListentitytypeentity.java | 45 + ...itiesStringListentitytypeentityString.java | 46 + .../AsyncBatchDeleteEntities.java | 51 + .../AsyncBatchDeleteEntitiesLRO.java | 52 + .../SyncBatchDeleteEntities.java | 46 + ...eleteEntitiesEntitytypenameListstring.java | 42 + ...ntitiesEntitytypenameListstringString.java | 44 + ...ncBatchDeleteEntitiesStringListstring.java | 42 + ...hDeleteEntitiesStringListstringString.java | 43 + .../AsyncBatchDeleteEntityTypes.java | 49 + .../AsyncBatchDeleteEntityTypesLRO.java | 50 + .../SyncBatchDeleteEntityTypes.java | 44 + ...hDeleteEntityTypesAgentnameListstring.java | 41 + ...atchDeleteEntityTypesStringListstring.java | 41 + .../AsyncBatchUpdateEntities.java | 54 + .../AsyncBatchUpdateEntitiesLRO.java | 55 + .../SyncBatchUpdateEntities.java | 49 + ...iesEntitytypenameListentitytypeentity.java | 44 + ...itytypenameListentitytypeentityString.java | 46 + ...ateEntitiesStringListentitytypeentity.java | 45 + ...itiesStringListentitytypeentityString.java | 46 + .../AsyncBatchUpdateEntityTypes.java | 50 + .../AsyncBatchUpdateEntityTypesLRO.java | 51 + .../SyncBatchUpdateEntityTypes.java | 47 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncCreateEntityType.java | 49 + .../SyncCreateEntityType.java | 45 + ...ncCreateEntityTypeAgentnameEntitytype.java | 40 + ...teEntityTypeAgentnameEntitytypeString.java | 41 + .../SyncCreateEntityTypeStringEntitytype.java | 40 + ...reateEntityTypeStringEntitytypeString.java | 41 + .../AsyncDeleteEntityType.java | 47 + .../SyncDeleteEntityType.java | 43 + .../SyncDeleteEntityTypeEntitytypename.java | 38 + .../SyncDeleteEntityTypeString.java | 38 + .../getentitytype/AsyncGetEntityType.java | 48 + .../getentitytype/SyncGetEntityType.java | 45 + .../SyncGetEntityTypeEntitytypename.java | 39 + ...SyncGetEntityTypeEntitytypenameString.java | 40 + .../SyncGetEntityTypeString.java | 39 + .../SyncGetEntityTypeStringString.java | 40 + .../listentitytypes/AsyncListEntityTypes.java | 52 + .../AsyncListEntityTypesPaged.java | 60 + .../listentitytypes/SyncListEntityTypes.java | 48 + .../SyncListEntityTypesAgentname.java | 41 + .../SyncListEntityTypesAgentnameString.java | 43 + .../SyncListEntityTypesString.java | 41 + .../SyncListEntityTypesStringString.java | 43 + .../AsyncUpdateEntityType.java | 49 + .../SyncUpdateEntityType.java | 45 + .../SyncUpdateEntityTypeEntitytype.java | 38 + .../SyncUpdateEntityTypeEntitytypeString.java | 39 + .../getentitytype/SyncGetEntityType.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncCreateEnvironment.java | 49 + .../SyncCreateEnvironment.java | 45 + .../AsyncDeleteEnvironment.java | 47 + .../SyncDeleteEnvironment.java | 43 + .../getenvironment/AsyncGetEnvironment.java | 48 + .../getenvironment/SyncGetEnvironment.java | 44 + .../AsyncGetEnvironmentHistory.java | 52 + .../AsyncGetEnvironmentHistoryPaged.java | 59 + .../SyncGetEnvironmentHistory.java | 49 + .../AsyncListEnvironments.java | 51 + .../AsyncListEnvironmentsPaged.java | 59 + .../SyncListEnvironments.java | 47 + .../SyncListEnvironmentsAgentname.java | 41 + .../SyncListEnvironmentsString.java | 41 + .../AsyncUpdateEnvironment.java | 49 + .../SyncUpdateEnvironment.java | 45 + .../getenvironment/SyncGetEnvironment.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../getfulfillment/AsyncGetFulfillment.java | 47 + .../getfulfillment/SyncGetFulfillment.java | 43 + .../SyncGetFulfillmentFulfillmentname.java | 39 + .../SyncGetFulfillmentString.java | 39 + .../AsyncUpdateFulfillment.java | 48 + .../SyncUpdateFulfillment.java | 44 + ...UpdateFulfillmentFulfillmentFieldmask.java | 40 + .../getfulfillment/SyncGetFulfillment.java | 45 + .../AsyncBatchDeleteIntents.java | 49 + .../AsyncBatchDeleteIntentsLRO.java | 51 + .../SyncBatchDeleteIntents.java | 45 + ...BatchDeleteIntentsAgentnameListintent.java | 42 + ...yncBatchDeleteIntentsStringListintent.java | 42 + .../AsyncBatchUpdateIntents.java | 51 + .../AsyncBatchUpdateIntentsLRO.java | 53 + .../SyncBatchUpdateIntents.java | 48 + ...atchUpdateIntentsAgentnameIntentbatch.java | 42 + ...SyncBatchUpdateIntentsAgentnameString.java | 41 + ...ncBatchUpdateIntentsStringIntentbatch.java | 42 + .../SyncBatchUpdateIntentsStringString.java | 41 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 37 + .../createintent/AsyncCreateIntent.java | 50 + .../createintent/SyncCreateIntent.java | 47 + .../SyncCreateIntentAgentnameIntent.java | 40 + ...SyncCreateIntentAgentnameIntentString.java | 41 + .../SyncCreateIntentStringIntent.java | 40 + .../SyncCreateIntentStringIntentString.java | 41 + .../deleteintent/AsyncDeleteIntent.java | 46 + .../deleteintent/SyncDeleteIntent.java | 42 + .../SyncDeleteIntentIntentname.java | 38 + .../deleteintent/SyncDeleteIntentString.java | 38 + .../getintent/AsyncGetIntent.java | 49 + .../getintent/SyncGetIntent.java | 46 + .../getintent/SyncGetIntentIntentname.java | 39 + .../SyncGetIntentIntentnameString.java | 40 + .../getintent/SyncGetIntentString.java | 39 + .../getintent/SyncGetIntentStringString.java | 40 + .../listintents/AsyncListIntents.java | 53 + .../listintents/AsyncListIntentsPaged.java | 61 + .../listintents/SyncListIntents.java | 50 + .../listintents/SyncListIntentsAgentname.java | 41 + .../SyncListIntentsAgentnameString.java | 42 + .../listintents/SyncListIntentsString.java | 41 + .../SyncListIntentsStringString.java | 42 + .../updateintent/AsyncUpdateIntent.java | 50 + .../updateintent/SyncUpdateIntent.java | 47 + .../SyncUpdateIntentIntentString.java | 39 + ...SyncUpdateIntentIntentStringFieldmask.java | 41 + .../getintent/SyncGetIntent.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncCreateKnowledgeBase.java | 48 + .../SyncCreateKnowledgeBase.java | 44 + ...nowledgeBaseLocationnameKnowledgebase.java | 42 + ...KnowledgeBaseProjectnameKnowledgebase.java | 42 + ...reateKnowledgeBaseStringKnowledgebase.java | 40 + .../AsyncDeleteKnowledgeBase.java | 50 + .../SyncDeleteKnowledgeBase.java | 45 + ...cDeleteKnowledgeBaseKnowledgebasename.java | 39 + .../SyncDeleteKnowledgeBaseString.java | 39 + .../AsyncGetKnowledgeBase.java | 49 + .../SyncGetKnowledgeBase.java | 45 + ...SyncGetKnowledgeBaseKnowledgebasename.java | 40 + .../SyncGetKnowledgeBaseString.java | 40 + .../AsyncListKnowledgeBases.java | 52 + .../AsyncListKnowledgeBasesPaged.java | 60 + .../SyncListKnowledgeBases.java | 48 + .../SyncListKnowledgeBasesLocationname.java | 41 + .../SyncListKnowledgeBasesProjectname.java | 41 + .../SyncListKnowledgeBasesString.java | 41 + .../AsyncUpdateKnowledgeBase.java | 48 + .../SyncUpdateKnowledgeBase.java | 44 + ...teKnowledgeBaseKnowledgebaseFieldmask.java | 42 + .../SyncGetKnowledgeBase.java | 46 + .../analyzecontent/AsyncAnalyzeContent.java | 59 + .../analyzecontent/SyncAnalyzeContent.java | 55 + ...alyzeContentParticipantnameEventinput.java | 43 + ...nalyzeContentParticipantnameTextinput.java | 43 + .../SyncAnalyzeContentStringEventinput.java | 44 + .../SyncAnalyzeContentStringTextinput.java | 44 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncCreateParticipant.java | 50 + .../SyncCreateParticipant.java | 46 + ...articipantConversationnameParticipant.java | 43 + ...yncCreateParticipantStringParticipant.java | 41 + .../getparticipant/AsyncGetParticipant.java | 50 + .../getparticipant/SyncGetParticipant.java | 46 + .../SyncGetParticipantParticipantname.java | 41 + .../SyncGetParticipantString.java | 42 + .../AsyncListParticipants.java | 53 + .../AsyncListParticipantsPaged.java | 61 + .../SyncListParticipants.java | 49 + .../SyncListParticipantsConversationname.java | 42 + .../SyncListParticipantsString.java | 42 + .../suggestarticles/AsyncSuggestArticles.java | 58 + .../suggestarticles/SyncSuggestArticles.java | 54 + .../SyncSuggestArticlesParticipantname.java | 41 + .../SyncSuggestArticlesString.java | 42 + .../AsyncSuggestFaqAnswers.java | 58 + .../SyncSuggestFaqAnswers.java | 54 + .../SyncSuggestFaqAnswersParticipantname.java | 41 + .../SyncSuggestFaqAnswersString.java | 42 + .../AsyncSuggestSmartReplies.java | 58 + .../SyncSuggestSmartReplies.java | 54 + ...yncSuggestSmartRepliesParticipantname.java | 41 + .../SyncSuggestSmartRepliesString.java | 42 + .../AsyncUpdateParticipant.java | 48 + .../SyncUpdateParticipant.java | 44 + ...UpdateParticipantParticipantFieldmask.java | 40 + .../SyncCreateParticipant.java | 45 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateSessionEntityType.java | 48 + .../SyncCreateSessionEntityType.java | 44 + ...ntityTypeSessionnameSessionentitytype.java | 43 + ...sionEntityTypeStringSessionentitytype.java | 43 + .../AsyncDeleteSessionEntityType.java | 50 + .../SyncDeleteSessionEntityType.java | 45 + ...essionEntityTypeSessionentitytypename.java | 42 + .../SyncDeleteSessionEntityTypeString.java | 41 + .../AsyncGetSessionEntityType.java | 50 + .../SyncGetSessionEntityType.java | 46 + ...essionEntityTypeSessionentitytypename.java | 43 + .../SyncGetSessionEntityTypeString.java | 42 + .../AsyncListSessionEntityTypes.java | 51 + .../AsyncListSessionEntityTypesPaged.java | 59 + .../SyncListSessionEntityTypes.java | 48 + ...SyncListSessionEntityTypesSessionname.java | 42 + .../SyncListSessionEntityTypesString.java | 42 + .../AsyncUpdateSessionEntityType.java | 48 + .../SyncUpdateSessionEntityType.java | 44 + ...ateSessionEntityTypeSessionentitytype.java | 41 + ...nEntityTypeSessionentitytypeFieldmask.java | 43 + .../SyncGetSessionEntityType.java | 47 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../detectintent/AsyncDetectIntent.java | 57 + .../detectintent/SyncDetectIntent.java | 53 + ...SyncDetectIntentSessionnameQueryinput.java | 41 + .../SyncDetectIntentStringQueryinput.java | 41 + .../AsyncStreamingDetectIntent.java | 60 + .../detectintent/SyncDetectIntent.java | 45 + .../getagent/SyncGetAgent.java | 45 + .../SyncUpdateAnswerRecord.java | 46 + .../getcontext/SyncGetContext.java | 45 + .../SyncGetConversationDataset.java | 47 + .../SyncGetConversationModel.java | 47 + .../SyncGetConversationProfile.java | 47 + .../SyncCreateConversation.java | 46 + .../getdocument/SyncGetDocument.java | 45 + .../getentitytype/SyncGetEntityType.java | 46 + .../getenvironment/SyncGetEnvironment.java | 46 + .../getfulfillment/SyncGetFulfillment.java | 46 + .../getintent/SyncGetIntent.java | 45 + .../SyncGetKnowledgeBase.java | 46 + .../SyncCreateParticipant.java | 46 + .../SyncGetSessionEntityType.java | 47 + .../detectintent/SyncDetectIntent.java | 45 + .../getversion/SyncGetVersion.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createversion/AsyncCreateVersion.java | 47 + .../createversion/SyncCreateVersion.java | 44 + .../SyncCreateVersionAgentnameVersion.java | 40 + .../SyncCreateVersionStringVersion.java | 40 + .../deleteversion/AsyncDeleteVersion.java | 46 + .../deleteversion/SyncDeleteVersion.java | 42 + .../SyncDeleteVersionString.java | 38 + .../SyncDeleteVersionVersionname.java | 38 + .../getversion/AsyncGetVersion.java | 46 + .../getversion/SyncGetVersion.java | 43 + .../getversion/SyncGetVersionString.java | 39 + .../getversion/SyncGetVersionVersionname.java | 39 + .../listversions/AsyncListVersions.java | 50 + .../listversions/AsyncListVersionsPaged.java | 58 + .../listversions/SyncListVersions.java | 47 + .../SyncListVersionsAgentname.java | 41 + .../listversions/SyncListVersionsString.java | 41 + .../updateversion/AsyncUpdateVersion.java | 47 + .../updateversion/SyncUpdateVersion.java | 44 + .../SyncUpdateVersionVersionFieldmask.java | 40 + .../getversion/SyncGetVersion.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 37 + .../deleteagent/AsyncDeleteAgent.java | 44 + .../deleteagent/SyncDeleteAgent.java | 40 + .../SyncDeleteAgentLocationname.java | 38 + .../SyncDeleteAgentProjectname.java | 38 + .../deleteagent/SyncDeleteAgentString.java | 38 + .../exportagent/AsyncExportAgent.java | 47 + .../exportagent/AsyncExportAgentLRO.java | 49 + .../exportagent/SyncExportAgent.java | 44 + .../SyncExportAgentLocationname.java | 39 + .../SyncExportAgentProjectname.java | 39 + .../exportagent/SyncExportAgentString.java | 39 + .../agentsclient/getagent/AsyncGetAgent.java | 44 + .../agentsclient/getagent/SyncGetAgent.java | 41 + .../getagent/SyncGetAgentLocationname.java | 39 + .../getagent/SyncGetAgentProjectname.java | 39 + .../getagent/SyncGetAgentString.java | 39 + .../AsyncGetValidationResult.java | 48 + .../SyncGetValidationResult.java | 44 + .../importagent/AsyncImportAgent.java | 44 + .../importagent/AsyncImportAgentLRO.java | 46 + .../importagent/SyncImportAgent.java | 40 + .../restoreagent/AsyncRestoreAgent.java | 46 + .../restoreagent/AsyncRestoreAgentLRO.java | 48 + .../restoreagent/SyncRestoreAgent.java | 42 + .../searchagents/AsyncSearchAgents.java | 50 + .../searchagents/AsyncSearchAgentsPaged.java | 58 + .../searchagents/SyncSearchAgents.java | 47 + .../SyncSearchAgentsLocationname.java | 41 + .../SyncSearchAgentsProjectname.java | 41 + .../searchagents/SyncSearchAgentsString.java | 41 + .../agentsclient/setagent/AsyncSetAgent.java | 47 + .../agentsclient/setagent/SyncSetAgent.java | 44 + .../setagent/SyncSetAgentAgent.java | 38 + .../trainagent/AsyncTrainAgent.java | 44 + .../trainagent/AsyncTrainAgentLRO.java | 46 + .../trainagent/SyncTrainAgent.java | 40 + .../SyncTrainAgentLocationname.java | 38 + .../trainagent/SyncTrainAgentProjectname.java | 38 + .../trainagent/SyncTrainAgentString.java | 38 + .../agentssettings/getagent/SyncGetAgent.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../getanswerrecord/AsyncGetAnswerRecord.java | 44 + .../getanswerrecord/SyncGetAnswerRecord.java | 40 + .../AsyncListAnswerRecords.java | 51 + .../AsyncListAnswerRecordsPaged.java | 59 + .../SyncListAnswerRecords.java | 47 + .../SyncListAnswerRecordsLocationname.java | 41 + .../SyncListAnswerRecordsProjectname.java | 41 + .../SyncListAnswerRecordsString.java | 41 + .../AsyncUpdateAnswerRecord.java | 48 + .../SyncUpdateAnswerRecord.java | 44 + ...dateAnswerRecordAnswerrecordFieldmask.java | 42 + .../getanswerrecord/SyncGetAnswerRecord.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createcontext/AsyncCreateContext.java | 47 + .../createcontext/SyncCreateContext.java | 44 + .../SyncCreateContextSessionnameContext.java | 40 + .../SyncCreateContextStringContext.java | 40 + .../AsyncDeleteAllContexts.java | 46 + .../SyncDeleteAllContexts.java | 42 + .../SyncDeleteAllContextsSessionname.java | 38 + .../SyncDeleteAllContextsString.java | 38 + .../deletecontext/AsyncDeleteContext.java | 48 + .../deletecontext/SyncDeleteContext.java | 44 + .../SyncDeleteContextContextname.java | 39 + .../SyncDeleteContextString.java | 39 + .../getcontext/AsyncGetContext.java | 48 + .../getcontext/SyncGetContext.java | 45 + .../getcontext/SyncGetContextContextname.java | 40 + .../getcontext/SyncGetContextString.java | 40 + .../listcontexts/AsyncListContexts.java | 50 + .../listcontexts/AsyncListContextsPaged.java | 58 + .../listcontexts/SyncListContexts.java | 47 + .../SyncListContextsSessionname.java | 41 + .../listcontexts/SyncListContextsString.java | 41 + .../updatecontext/AsyncUpdateContext.java | 47 + .../updatecontext/SyncUpdateContext.java | 44 + .../SyncUpdateContextContext.java | 38 + .../SyncUpdateContextContextFieldmask.java | 40 + .../getcontext/SyncGetContext.java | 45 + .../AsyncClearSuggestionFeatureConfig.java | 48 + .../AsyncClearSuggestionFeatureConfigLRO.java | 52 + .../SyncClearSuggestionFeatureConfig.java | 44 + ...yncClearSuggestionFeatureConfigString.java | 42 + .../SyncCreateSetCredentialsProvider.java | 43 + .../SyncCreateSetCredentialsProvider1.java | 42 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateConversationProfile.java | 49 + .../SyncCreateConversationProfile.java | 45 + ...rofileLocationnameConversationprofile.java | 45 + ...ProfileProjectnameConversationprofile.java | 45 + ...ationProfileStringConversationprofile.java | 44 + .../AsyncDeleteConversationProfile.java | 51 + .../SyncDeleteConversationProfile.java | 46 + ...rsationProfileConversationprofilename.java | 43 + .../SyncDeleteConversationProfileString.java | 44 + .../AsyncGetConversationProfile.java | 51 + .../SyncGetConversationProfile.java | 47 + ...rsationProfileConversationprofilename.java | 44 + .../SyncGetConversationProfileString.java | 44 + .../AsyncListConversationProfiles.java | 52 + .../AsyncListConversationProfilesPaged.java | 62 + .../SyncListConversationProfiles.java | 49 + ...cListConversationProfilesLocationname.java | 45 + ...ncListConversationProfilesProjectname.java | 45 + .../SyncListConversationProfilesString.java | 45 + .../AsyncSetSuggestionFeatureConfig.java | 50 + .../AsyncSetSuggestionFeatureConfigLRO.java | 55 + .../SyncSetSuggestionFeatureConfig.java | 47 + .../SyncSetSuggestionFeatureConfigString.java | 42 + .../AsyncUpdateConversationProfile.java | 49 + .../SyncUpdateConversationProfile.java | 45 + ...onProfileConversationprofileFieldmask.java | 44 + .../SyncGetConversationProfile.java | 47 + .../AsyncBatchCreateMessages.java | 52 + .../SyncBatchCreateMessages.java | 48 + ...ncBatchCreateMessagesConversationname.java | 41 + .../SyncBatchCreateMessagesString.java | 40 + .../AsyncCompleteConversation.java | 49 + .../SyncCompleteConversation.java | 45 + ...cCompleteConversationConversationname.java | 41 + .../SyncCompleteConversationString.java | 40 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncCreateConversation.java | 49 + .../SyncCreateConversation.java | 45 + ...eConversationLocationnameConversation.java | 42 + ...teConversationProjectnameConversation.java | 42 + ...cCreateConversationStringConversation.java | 41 + .../getconversation/AsyncGetConversation.java | 49 + .../getconversation/SyncGetConversation.java | 45 + .../SyncGetConversationConversationname.java | 40 + .../SyncGetConversationString.java | 40 + .../AsyncListConversations.java | 52 + .../AsyncListConversationsPaged.java | 60 + .../SyncListConversations.java | 48 + .../SyncListConversationsLocationname.java | 41 + .../SyncListConversationsProjectname.java | 41 + .../SyncListConversationsString.java | 41 + .../listmessages/AsyncListMessages.java | 54 + .../listmessages/AsyncListMessagesPaged.java | 61 + .../listmessages/SyncListMessages.java | 50 + .../SyncListMessagesConversationname.java | 42 + .../listmessages/SyncListMessagesString.java | 42 + .../SyncCreateConversation.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createdocument/AsyncCreateDocument.java | 51 + .../AsyncCreateDocumentLRO.java | 52 + .../createdocument/SyncCreateDocument.java | 47 + ...eateDocumentKnowledgebasenameDocument.java | 42 + .../SyncCreateDocumentStringDocument.java | 41 + .../deletedocument/AsyncDeleteDocument.java | 49 + .../AsyncDeleteDocumentLRO.java | 51 + .../deletedocument/SyncDeleteDocument.java | 45 + .../SyncDeleteDocumentDocumentname.java | 40 + .../SyncDeleteDocumentString.java | 41 + .../getdocument/AsyncGetDocument.java | 49 + .../getdocument/SyncGetDocument.java | 46 + .../SyncGetDocumentDocumentname.java | 41 + .../getdocument/SyncGetDocumentString.java | 42 + .../importdocuments/AsyncImportDocuments.java | 51 + .../AsyncImportDocumentsLRO.java | 53 + .../importdocuments/SyncImportDocuments.java | 48 + .../listdocuments/AsyncListDocuments.java | 53 + .../AsyncListDocumentsPaged.java | 61 + .../listdocuments/SyncListDocuments.java | 50 + .../SyncListDocumentsKnowledgebasename.java | 42 + .../SyncListDocumentsString.java | 42 + .../reloaddocument/AsyncReloadDocument.java | 50 + .../AsyncReloadDocumentLRO.java | 52 + .../reloaddocument/SyncReloadDocument.java | 47 + ...ncReloadDocumentDocumentnameGcssource.java | 43 + .../SyncReloadDocumentStringGcssource.java | 44 + .../updatedocument/AsyncUpdateDocument.java | 48 + .../AsyncUpdateDocumentLRO.java | 49 + .../updatedocument/SyncUpdateDocument.java | 44 + .../SyncUpdateDocumentDocument.java | 38 + .../SyncUpdateDocumentDocumentFieldmask.java | 40 + .../getdocument/SyncGetDocument.java | 45 + .../AsyncBatchCreateEntities.java | 52 + .../AsyncBatchCreateEntitiesLRO.java | 53 + .../SyncBatchCreateEntities.java | 47 + ...iesEntitytypenameListentitytypeentity.java | 44 + ...itytypenameListentitytypeentityString.java | 46 + ...ateEntitiesStringListentitytypeentity.java | 45 + ...itiesStringListentitytypeentityString.java | 46 + .../AsyncBatchDeleteEntities.java | 51 + .../AsyncBatchDeleteEntitiesLRO.java | 52 + .../SyncBatchDeleteEntities.java | 46 + ...eleteEntitiesEntitytypenameListstring.java | 43 + ...ntitiesEntitytypenameListstringString.java | 44 + ...ncBatchDeleteEntitiesStringListstring.java | 42 + ...hDeleteEntitiesStringListstringString.java | 45 + .../AsyncBatchDeleteEntityTypes.java | 49 + .../AsyncBatchDeleteEntityTypesLRO.java | 50 + .../SyncBatchDeleteEntityTypes.java | 44 + ...hDeleteEntityTypesAgentnameListstring.java | 43 + ...atchDeleteEntityTypesStringListstring.java | 42 + .../AsyncBatchUpdateEntities.java | 54 + .../AsyncBatchUpdateEntitiesLRO.java | 55 + .../SyncBatchUpdateEntities.java | 49 + ...iesEntitytypenameListentitytypeentity.java | 44 + ...itytypenameListentitytypeentityString.java | 46 + ...ateEntitiesStringListentitytypeentity.java | 45 + ...itiesStringListentitytypeentityString.java | 46 + .../AsyncBatchUpdateEntityTypes.java | 50 + .../AsyncBatchUpdateEntityTypesLRO.java | 51 + .../SyncBatchUpdateEntityTypes.java | 47 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncCreateEntityType.java | 49 + .../SyncCreateEntityType.java | 45 + ...ncCreateEntityTypeAgentnameEntitytype.java | 40 + ...teEntityTypeAgentnameEntitytypeString.java | 43 + .../SyncCreateEntityTypeStringEntitytype.java | 40 + ...reateEntityTypeStringEntitytypeString.java | 42 + .../AsyncDeleteEntityType.java | 47 + .../SyncDeleteEntityType.java | 43 + .../SyncDeleteEntityTypeEntitytypename.java | 38 + .../SyncDeleteEntityTypeString.java | 38 + .../getentitytype/AsyncGetEntityType.java | 48 + .../getentitytype/SyncGetEntityType.java | 45 + .../SyncGetEntityTypeEntitytypename.java | 39 + ...SyncGetEntityTypeEntitytypenameString.java | 40 + .../SyncGetEntityTypeString.java | 39 + .../SyncGetEntityTypeStringString.java | 40 + .../listentitytypes/AsyncListEntityTypes.java | 52 + .../AsyncListEntityTypesPaged.java | 60 + .../listentitytypes/SyncListEntityTypes.java | 48 + .../SyncListEntityTypesAgentname.java | 41 + .../SyncListEntityTypesAgentnameString.java | 43 + .../SyncListEntityTypesString.java | 41 + .../SyncListEntityTypesStringString.java | 43 + .../AsyncUpdateEntityType.java | 49 + .../SyncUpdateEntityType.java | 45 + .../SyncUpdateEntityTypeEntitytype.java | 38 + .../SyncUpdateEntityTypeEntitytypeString.java | 39 + ...teEntityTypeEntitytypeStringFieldmask.java | 44 + .../getentitytype/SyncGetEntityType.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncCreateEnvironment.java | 49 + .../SyncCreateEnvironment.java | 45 + .../AsyncDeleteEnvironment.java | 47 + .../SyncDeleteEnvironment.java | 43 + .../getenvironment/AsyncGetEnvironment.java | 48 + .../getenvironment/SyncGetEnvironment.java | 44 + .../AsyncGetEnvironmentHistory.java | 52 + .../AsyncGetEnvironmentHistoryPaged.java | 59 + .../SyncGetEnvironmentHistory.java | 49 + .../AsyncListEnvironments.java | 51 + .../AsyncListEnvironmentsPaged.java | 59 + .../SyncListEnvironments.java | 47 + .../SyncListEnvironmentsAgentname.java | 41 + .../SyncListEnvironmentsString.java | 41 + .../AsyncUpdateEnvironment.java | 49 + .../SyncUpdateEnvironment.java | 45 + .../getenvironment/SyncGetEnvironment.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../getfulfillment/AsyncGetFulfillment.java | 47 + .../getfulfillment/SyncGetFulfillment.java | 43 + .../SyncGetFulfillmentFulfillmentname.java | 39 + .../SyncGetFulfillmentString.java | 39 + .../AsyncUpdateFulfillment.java | 48 + .../SyncUpdateFulfillment.java | 44 + ...UpdateFulfillmentFulfillmentFieldmask.java | 41 + .../getfulfillment/SyncGetFulfillment.java | 45 + .../AsyncBatchDeleteIntents.java | 49 + .../AsyncBatchDeleteIntentsLRO.java | 51 + .../SyncBatchDeleteIntents.java | 45 + ...BatchDeleteIntentsAgentnameListintent.java | 42 + ...yncBatchDeleteIntentsStringListintent.java | 42 + .../AsyncBatchUpdateIntents.java | 51 + .../AsyncBatchUpdateIntentsLRO.java | 53 + .../SyncBatchUpdateIntents.java | 48 + ...atchUpdateIntentsAgentnameIntentbatch.java | 42 + ...SyncBatchUpdateIntentsAgentnameString.java | 41 + ...ncBatchUpdateIntentsStringIntentbatch.java | 42 + .../SyncBatchUpdateIntentsStringString.java | 41 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 37 + .../createintent/AsyncCreateIntent.java | 50 + .../createintent/SyncCreateIntent.java | 47 + .../SyncCreateIntentAgentnameIntent.java | 40 + ...SyncCreateIntentAgentnameIntentString.java | 41 + .../SyncCreateIntentStringIntent.java | 40 + .../SyncCreateIntentStringIntentString.java | 41 + .../deleteintent/AsyncDeleteIntent.java | 46 + .../deleteintent/SyncDeleteIntent.java | 42 + .../SyncDeleteIntentIntentname.java | 38 + .../deleteintent/SyncDeleteIntentString.java | 38 + .../getintent/AsyncGetIntent.java | 49 + .../getintent/SyncGetIntent.java | 46 + .../getintent/SyncGetIntentIntentname.java | 39 + .../SyncGetIntentIntentnameString.java | 40 + .../getintent/SyncGetIntentString.java | 39 + .../getintent/SyncGetIntentStringString.java | 40 + .../listintents/AsyncListIntents.java | 53 + .../listintents/AsyncListIntentsPaged.java | 61 + .../listintents/SyncListIntents.java | 50 + .../listintents/SyncListIntentsAgentname.java | 41 + .../SyncListIntentsAgentnameString.java | 42 + .../listintents/SyncListIntentsString.java | 41 + .../SyncListIntentsStringString.java | 42 + .../updateintent/AsyncUpdateIntent.java | 50 + .../updateintent/SyncUpdateIntent.java | 47 + .../updateintent/SyncUpdateIntentIntent.java | 38 + .../SyncUpdateIntentIntentFieldmask.java | 40 + .../SyncUpdateIntentIntentString.java | 39 + ...SyncUpdateIntentIntentStringFieldmask.java | 41 + .../getintent/SyncGetIntent.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncCreateKnowledgeBase.java | 48 + .../SyncCreateKnowledgeBase.java | 44 + ...nowledgeBaseLocationnameKnowledgebase.java | 42 + ...KnowledgeBaseProjectnameKnowledgebase.java | 42 + ...reateKnowledgeBaseStringKnowledgebase.java | 42 + .../AsyncDeleteKnowledgeBase.java | 50 + .../SyncDeleteKnowledgeBase.java | 45 + ...cDeleteKnowledgeBaseKnowledgebasename.java | 41 + .../SyncDeleteKnowledgeBaseString.java | 39 + .../AsyncGetKnowledgeBase.java | 49 + .../SyncGetKnowledgeBase.java | 45 + ...SyncGetKnowledgeBaseKnowledgebasename.java | 40 + .../SyncGetKnowledgeBaseString.java | 40 + .../AsyncListKnowledgeBases.java | 52 + .../AsyncListKnowledgeBasesPaged.java | 60 + .../SyncListKnowledgeBases.java | 48 + .../SyncListKnowledgeBasesLocationname.java | 41 + .../SyncListKnowledgeBasesProjectname.java | 41 + .../SyncListKnowledgeBasesString.java | 41 + .../AsyncUpdateKnowledgeBase.java | 48 + .../SyncUpdateKnowledgeBase.java | 44 + .../SyncUpdateKnowledgeBaseKnowledgebase.java | 38 + ...teKnowledgeBaseKnowledgebaseFieldmask.java | 42 + .../SyncGetKnowledgeBase.java | 46 + .../analyzecontent/AsyncAnalyzeContent.java | 61 + .../analyzecontent/SyncAnalyzeContent.java | 57 + ...alyzeContentParticipantnameEventinput.java | 45 + ...nalyzeContentParticipantnameTextinput.java | 45 + .../SyncAnalyzeContentStringEventinput.java | 44 + .../SyncAnalyzeContentStringTextinput.java | 44 + .../AsyncCompileSuggestion.java | 48 + .../SyncCompileSuggestion.java | 44 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncCreateParticipant.java | 50 + .../SyncCreateParticipant.java | 46 + ...articipantConversationnameParticipant.java | 43 + ...yncCreateParticipantStringParticipant.java | 41 + .../getparticipant/AsyncGetParticipant.java | 50 + .../getparticipant/SyncGetParticipant.java | 46 + .../SyncGetParticipantParticipantname.java | 41 + .../SyncGetParticipantString.java | 42 + .../AsyncListParticipants.java | 53 + .../AsyncListParticipantsPaged.java | 61 + .../SyncListParticipants.java | 49 + .../SyncListParticipantsConversationname.java | 42 + .../SyncListParticipantsString.java | 42 + .../listsuggestions/AsyncListSuggestions.java | 51 + .../AsyncListSuggestionsPaged.java | 59 + .../listsuggestions/SyncListSuggestions.java | 47 + .../AsyncStreamingAnalyzeContent.java | 61 + .../suggestarticles/AsyncSuggestArticles.java | 58 + .../suggestarticles/SyncSuggestArticles.java | 54 + .../SyncSuggestArticlesParticipantname.java | 41 + .../SyncSuggestArticlesString.java | 42 + .../AsyncSuggestFaqAnswers.java | 58 + .../SyncSuggestFaqAnswers.java | 54 + .../SyncSuggestFaqAnswersParticipantname.java | 41 + .../SyncSuggestFaqAnswersString.java | 42 + .../AsyncSuggestSmartReplies.java | 58 + .../SyncSuggestSmartReplies.java | 54 + ...yncSuggestSmartRepliesParticipantname.java | 41 + .../SyncSuggestSmartRepliesString.java | 42 + .../AsyncUpdateParticipant.java | 48 + .../SyncUpdateParticipant.java | 44 + ...UpdateParticipantParticipantFieldmask.java | 41 + .../SyncCreateParticipant.java | 45 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateSessionEntityType.java | 48 + .../SyncCreateSessionEntityType.java | 44 + ...ntityTypeSessionnameSessionentitytype.java | 43 + ...sionEntityTypeStringSessionentitytype.java | 43 + .../AsyncDeleteSessionEntityType.java | 50 + .../SyncDeleteSessionEntityType.java | 45 + ...essionEntityTypeSessionentitytypename.java | 42 + .../SyncDeleteSessionEntityTypeString.java | 41 + .../AsyncGetSessionEntityType.java | 50 + .../SyncGetSessionEntityType.java | 46 + ...essionEntityTypeSessionentitytypename.java | 43 + .../SyncGetSessionEntityTypeString.java | 42 + .../AsyncListSessionEntityTypes.java | 51 + .../AsyncListSessionEntityTypesPaged.java | 59 + .../SyncListSessionEntityTypes.java | 48 + ...SyncListSessionEntityTypesSessionname.java | 44 + .../SyncListSessionEntityTypesString.java | 42 + .../AsyncUpdateSessionEntityType.java | 48 + .../SyncUpdateSessionEntityType.java | 44 + ...ateSessionEntityTypeSessionentitytype.java | 41 + ...nEntityTypeSessionentitytypeFieldmask.java | 43 + .../SyncGetSessionEntityType.java | 47 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../detectintent/AsyncDetectIntent.java | 57 + .../detectintent/SyncDetectIntent.java | 53 + ...SyncDetectIntentSessionnameQueryinput.java | 41 + .../SyncDetectIntentStringQueryinput.java | 41 + .../AsyncStreamingDetectIntent.java | 60 + .../detectintent/SyncDetectIntent.java | 45 + .../getagent/SyncGetAgent.java | 45 + .../getanswerrecord/SyncGetAnswerRecord.java | 46 + .../getcontext/SyncGetContext.java | 45 + .../SyncGetConversationProfile.java | 47 + .../SyncCreateConversation.java | 46 + .../getdocument/SyncGetDocument.java | 45 + .../getentitytype/SyncGetEntityType.java | 46 + .../getenvironment/SyncGetEnvironment.java | 46 + .../getfulfillment/SyncGetFulfillment.java | 46 + .../getintent/SyncGetIntent.java | 45 + .../SyncGetKnowledgeBase.java | 46 + .../SyncCreateParticipant.java | 46 + .../SyncGetSessionEntityType.java | 47 + .../detectintent/SyncDetectIntent.java | 45 + .../getversion/SyncGetVersion.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createversion/AsyncCreateVersion.java | 47 + .../createversion/SyncCreateVersion.java | 44 + .../SyncCreateVersionAgentnameVersion.java | 40 + .../SyncCreateVersionStringVersion.java | 40 + .../deleteversion/AsyncDeleteVersion.java | 46 + .../deleteversion/SyncDeleteVersion.java | 42 + .../SyncDeleteVersionString.java | 38 + .../SyncDeleteVersionVersionname.java | 38 + .../getversion/AsyncGetVersion.java | 46 + .../getversion/SyncGetVersion.java | 43 + .../getversion/SyncGetVersionString.java | 39 + .../getversion/SyncGetVersionVersionname.java | 39 + .../listversions/AsyncListVersions.java | 50 + .../listversions/AsyncListVersionsPaged.java | 58 + .../listversions/SyncListVersions.java | 47 + .../SyncListVersionsAgentname.java | 41 + .../listversions/SyncListVersionsString.java | 41 + .../updateversion/AsyncUpdateVersion.java | 47 + .../updateversion/SyncUpdateVersion.java | 44 + .../SyncUpdateVersionVersionFieldmask.java | 40 + .../getversion/SyncGetVersion.java | 45 + 1194 files changed, 91240 insertions(+), 232 deletions(-) create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAgentsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAgentsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAnswerRecordsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAnswerRecordsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonContextsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonContextsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationDatasetsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationDatasetsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationModelsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationModelsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationProfilesCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationProfilesStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonDocumentsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonDocumentsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEntityTypesCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEntityTypesStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEnvironmentsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEnvironmentsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonFulfillmentsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonFulfillmentsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonIntentsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonIntentsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonKnowledgeBasesCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonKnowledgeBasesStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonParticipantsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonParticipantsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionEntityTypesCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionEntityTypesStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonVersionsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonVersionsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAgentsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAgentsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAnswerRecordsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAnswerRecordsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonContextsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonContextsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationProfilesCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationProfilesStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonDocumentsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonDocumentsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEntityTypesCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEntityTypesStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEnvironmentsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEnvironmentsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonFulfillmentsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonFulfillmentsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonIntentsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonIntentsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonKnowledgeBasesCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonKnowledgeBasesStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonParticipantsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonParticipantsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionEntityTypesCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionEntityTypesStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonVersionsCallableFactory.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonVersionsStub.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/AgentsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/AnswerRecordsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ContextsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationDatasetsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationModelsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationProfilesClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/DocumentsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/EntityTypesClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/EnvironmentsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/FulfillmentsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/IntentsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/KnowledgeBasesClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ParticipantsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/VersionsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/AgentsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/AnswerRecordsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ContextsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ConversationProfilesClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ConversationsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/DocumentsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/EntityTypesClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/EnvironmentsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/FulfillmentsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/IntentsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/KnowledgeBasesClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ParticipantsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/SessionsClientHttpJsonTest.java create mode 100644 java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/VersionsClientHttpJsonTest.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/AsyncDeleteAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgentLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgentProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/AsyncExportAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/AsyncExportAgentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgentLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgentProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/AsyncGetAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgentLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgentProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getvalidationresult/AsyncGetValidationResult.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getvalidationresult/SyncGetValidationResult.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/importagent/AsyncImportAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/importagent/AsyncImportAgentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/importagent/SyncImportAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/restoreagent/AsyncRestoreAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/restoreagent/AsyncRestoreAgentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/restoreagent/SyncRestoreAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/AsyncSearchAgents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/AsyncSearchAgentsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgentsLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgentsProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgentsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/setagent/AsyncSetAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/setagent/SyncSetAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/setagent/SyncSetAgentAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/AsyncTrainAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/AsyncTrainAgentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgentLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgentProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentssettings/getagent/SyncGetAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/AsyncListAnswerRecords.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/AsyncListAnswerRecordsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecords.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/updateanswerrecord/AsyncUpdateAnswerRecord.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecord.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecordAnswerrecordFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordssettings/updateanswerrecord/SyncUpdateAnswerRecord.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/AsyncCreateContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/SyncCreateContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/SyncCreateContextSessionnameContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/SyncCreateContextStringContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/AsyncDeleteAllContexts.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/SyncDeleteAllContexts.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/SyncDeleteAllContextsSessionname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/SyncDeleteAllContextsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/AsyncDeleteContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/SyncDeleteContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/SyncDeleteContextContextname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/SyncDeleteContextString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/AsyncGetContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/SyncGetContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/SyncGetContextContextname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/SyncGetContextString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/AsyncListContexts.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/AsyncListContextsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/SyncListContexts.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/SyncListContextsSessionname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/SyncListContextsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/updatecontext/AsyncUpdateContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/updatecontext/SyncUpdateContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/updatecontext/SyncUpdateContextContextFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextssettings/getcontext/SyncGetContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/AsyncCreateConversationDataset.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/AsyncCreateConversationDatasetLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/SyncCreateConversationDataset.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/SyncCreateConversationDatasetStringConversationdataset.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/AsyncDeleteConversationDataset.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/AsyncDeleteConversationDatasetLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/SyncDeleteConversationDataset.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/SyncDeleteConversationDatasetConversationdatasetname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/SyncDeleteConversationDatasetString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/AsyncGetConversationDataset.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/SyncGetConversationDataset.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/SyncGetConversationDatasetConversationdatasetname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/SyncGetConversationDatasetString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/importconversationdata/AsyncImportConversationData.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/importconversationdata/AsyncImportConversationDataLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/importconversationdata/SyncImportConversationData.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/AsyncListConversationDatasets.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/AsyncListConversationDatasetsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/SyncListConversationDatasets.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/SyncListConversationDatasetsLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/SyncListConversationDatasetsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetssettings/getconversationdataset/SyncGetConversationDataset.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/AsyncCreateConversationModel.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/AsyncCreateConversationModelLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/SyncCreateConversationModel.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/SyncCreateConversationModelStringConversationmodel.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/AsyncCreateConversationModelEvaluation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/AsyncCreateConversationModelEvaluationLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/SyncCreateConversationModelEvaluation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/SyncCreateConversationModelEvaluationConversationmodelnameConversationmodelevaluation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/SyncCreateConversationModelEvaluationStringConversationmodelevaluation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/AsyncDeleteConversationModel.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/AsyncDeleteConversationModelLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/SyncDeleteConversationModel.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/SyncDeleteConversationModelString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deployconversationmodel/AsyncDeployConversationModel.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deployconversationmodel/AsyncDeployConversationModelLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deployconversationmodel/SyncDeployConversationModel.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodel/AsyncGetConversationModel.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodel/SyncGetConversationModel.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodel/SyncGetConversationModelString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodelevaluation/AsyncGetConversationModelEvaluation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodelevaluation/SyncGetConversationModelEvaluation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodelevaluation/SyncGetConversationModelEvaluationString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/AsyncListConversationModelEvaluations.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/AsyncListConversationModelEvaluationsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/SyncListConversationModelEvaluations.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/SyncListConversationModelEvaluationsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/AsyncListConversationModels.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/AsyncListConversationModelsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/SyncListConversationModels.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/SyncListConversationModelsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/undeployconversationmodel/AsyncUndeployConversationModel.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/undeployconversationmodel/AsyncUndeployConversationModelLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/undeployconversationmodel/SyncUndeployConversationModel.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelssettings/getconversationmodel/SyncGetConversationModel.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfig.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfigLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfig.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfigString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/AsyncCreateConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileLocationnameConversationprofile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileProjectnameConversationprofile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileStringConversationprofile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/AsyncDeleteConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileConversationprofilename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/AsyncGetConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/SyncGetConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileConversationprofilename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfiles.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfilesPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfiles.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfig.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfigLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfig.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfigString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/updateconversationprofile/AsyncUpdateConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfileConversationprofileFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilessettings/getconversationprofile/SyncGetConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/AsyncCompleteConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/SyncCompleteConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/SyncCompleteConversationConversationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/SyncCompleteConversationString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/AsyncCreateConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversationLocationnameConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversationProjectnameConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversationStringConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/AsyncGetConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/SyncGetConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/SyncGetConversationConversationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/SyncGetConversationString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/AsyncListConversations.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/AsyncListConversationsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversations.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversationsLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversationsProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversationsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/AsyncListMessages.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/AsyncListMessagesPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/SyncListMessages.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/SyncListMessagesConversationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/SyncListMessagesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationssettings/createconversation/SyncCreateConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/AsyncCreateDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/AsyncCreateDocumentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/SyncCreateDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/SyncCreateDocumentKnowledgebasenameDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/SyncCreateDocumentStringDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/AsyncDeleteDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/AsyncDeleteDocumentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/SyncDeleteDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/SyncDeleteDocumentDocumentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/SyncDeleteDocumentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/exportdocument/AsyncExportDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/exportdocument/AsyncExportDocumentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/exportdocument/SyncExportDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/AsyncGetDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/SyncGetDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/SyncGetDocumentDocumentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/SyncGetDocumentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/importdocuments/AsyncImportDocuments.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/importdocuments/AsyncImportDocumentsLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/importdocuments/SyncImportDocuments.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/AsyncListDocuments.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/AsyncListDocumentsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/SyncListDocuments.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/SyncListDocumentsKnowledgebasename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/SyncListDocumentsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/AsyncReloadDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/AsyncReloadDocumentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/SyncReloadDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/SyncReloadDocumentDocumentnameString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/SyncReloadDocumentStringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/AsyncUpdateDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/AsyncUpdateDocumentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/SyncUpdateDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/SyncUpdateDocumentDocumentFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentssettings/getdocument/SyncGetDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/AsyncBatchCreateEntities.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/AsyncBatchCreateEntitiesLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntities.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentity.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentityString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentity.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentityString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntities.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntitiesLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntities.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstring.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstring.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypesLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesAgentnameListstring.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesStringListstring.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntities.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntitiesLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntities.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentity.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentityString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentity.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentityString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypesLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentitytypes/SyncBatchUpdateEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/AsyncCreateEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytype.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytype.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/AsyncDeleteEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/SyncDeleteEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeEntitytypename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/AsyncGetEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypenameString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeStringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/AsyncListEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/AsyncListEntityTypesPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesAgentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesAgentnameString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesStringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/AsyncUpdateEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/SyncUpdateEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytype.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypessettings/getentitytype/SyncGetEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/createenvironment/AsyncCreateEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/createenvironment/SyncCreateEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/deleteenvironment/SyncDeleteEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironment/AsyncGetEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironment/SyncGetEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistory.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistoryPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironmenthistory/SyncGetEnvironmentHistory.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/AsyncListEnvironments.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/SyncListEnvironments.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/SyncListEnvironmentsAgentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/SyncListEnvironmentsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/updateenvironment/AsyncUpdateEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/updateenvironment/SyncUpdateEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentssettings/getenvironment/SyncGetEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/AsyncGetFulfillment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/SyncGetFulfillment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/SyncGetFulfillmentFulfillmentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/SyncGetFulfillmentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/updatefulfillment/AsyncUpdateFulfillment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillmentFulfillmentFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentssettings/getfulfillment/SyncGetFulfillment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/AsyncBatchDeleteIntents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/AsyncBatchDeleteIntentsLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/SyncBatchDeleteIntents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsAgentnameListintent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsStringListintent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/AsyncBatchUpdateIntents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/AsyncBatchUpdateIntentsLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameIntentbatch.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringIntentbatch.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/AsyncCreateIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentAgentnameIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentAgentnameIntentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentStringIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentStringIntentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/AsyncDeleteIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/SyncDeleteIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/SyncDeleteIntentIntentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/SyncDeleteIntentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/AsyncGetIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentIntentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentIntentnameString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentStringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/AsyncListIntents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/AsyncListIntentsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsAgentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsAgentnameString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsStringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/AsyncUpdateIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/SyncUpdateIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/SyncUpdateIntentIntentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/SyncUpdateIntentIntentStringFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentssettings/getintent/SyncGetIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/AsyncCreateKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseLocationnameKnowledgebase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseProjectnameKnowledgebase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseStringKnowledgebase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/AsyncDeleteKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseKnowledgebasename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/AsyncGetKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseKnowledgebasename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBases.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBasesPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBases.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/updateknowledgebase/AsyncUpdateKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBaseKnowledgebaseFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasessettings/getknowledgebase/SyncGetKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/AsyncAnalyzeContent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameEventinput.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameTextinput.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentStringEventinput.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentStringTextinput.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/AsyncCreateParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/SyncCreateParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/SyncCreateParticipantConversationnameParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/SyncCreateParticipantStringParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/AsyncGetParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/SyncGetParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/SyncGetParticipantParticipantname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/SyncGetParticipantString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/AsyncListParticipants.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/AsyncListParticipantsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/SyncListParticipants.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/SyncListParticipantsConversationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/SyncListParticipantsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/AsyncSuggestArticles.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/SyncSuggestArticles.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/SyncSuggestArticlesParticipantname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/SyncSuggestArticlesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/AsyncSuggestFaqAnswers.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswers.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersParticipantname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/AsyncSuggestSmartReplies.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/SyncSuggestSmartReplies.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesParticipantname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/updateparticipant/AsyncUpdateParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/updateparticipant/SyncUpdateParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/updateparticipant/SyncUpdateParticipantParticipantFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantssettings/createparticipant/SyncCreateParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/AsyncCreateSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeSessionnameSessionentitytype.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeStringSessionentitytype.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/AsyncDeleteSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeSessionentitytypename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/AsyncGetSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeSessionentitytypename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypesPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesSessionname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/AsyncUpdateSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytype.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytypeFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypessettings/getsessionentitytype/SyncGetSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/AsyncDetectIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/SyncDetectIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/SyncDetectIntentSessionnameQueryinput.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/SyncDetectIntentStringQueryinput.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/streamingdetectintent/AsyncStreamingDetectIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionssettings/detectintent/SyncDetectIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/agentsstubsettings/getagent/SyncGetAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/answerrecordsstubsettings/updateanswerrecord/SyncUpdateAnswerRecord.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/contextsstubsettings/getcontext/SyncGetContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationdatasetsstubsettings/getconversationdataset/SyncGetConversationDataset.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationmodelsstubsettings/getconversationmodel/SyncGetConversationModel.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationprofilesstubsettings/getconversationprofile/SyncGetConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationsstubsettings/createconversation/SyncCreateConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/documentsstubsettings/getdocument/SyncGetDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/entitytypesstubsettings/getentitytype/SyncGetEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/fulfillmentsstubsettings/getfulfillment/SyncGetFulfillment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/intentsstubsettings/getintent/SyncGetIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/knowledgebasesstubsettings/getknowledgebase/SyncGetKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/participantsstubsettings/createparticipant/SyncCreateParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/sessionentitytypesstubsettings/getsessionentitytype/SyncGetSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/sessionsstubsettings/detectintent/SyncDetectIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/versionsstubsettings/getversion/SyncGetVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/AsyncCreateVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/SyncCreateVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/SyncCreateVersionAgentnameVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/SyncCreateVersionStringVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/AsyncDeleteVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/SyncDeleteVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/SyncDeleteVersionString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/SyncDeleteVersionVersionname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/AsyncGetVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/SyncGetVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/SyncGetVersionString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/SyncGetVersionVersionname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/AsyncListVersions.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/AsyncListVersionsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/SyncListVersions.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/SyncListVersionsAgentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/SyncListVersionsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/updateversion/AsyncUpdateVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/updateversion/SyncUpdateVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/updateversion/SyncUpdateVersionVersionFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionssettings/getversion/SyncGetVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/AsyncDeleteAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgentLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgentProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/AsyncExportAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/AsyncExportAgentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgentLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgentProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/AsyncGetAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgentLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgentProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getvalidationresult/AsyncGetValidationResult.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getvalidationresult/SyncGetValidationResult.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/importagent/AsyncImportAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/importagent/AsyncImportAgentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/importagent/SyncImportAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/restoreagent/AsyncRestoreAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/restoreagent/AsyncRestoreAgentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/restoreagent/SyncRestoreAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/AsyncSearchAgents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/AsyncSearchAgentsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgentsLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgentsProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgentsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/setagent/AsyncSetAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/setagent/SyncSetAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/setagent/SyncSetAgentAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/AsyncTrainAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/AsyncTrainAgentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgentLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgentProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentssettings/getagent/SyncGetAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/getanswerrecord/AsyncGetAnswerRecord.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/getanswerrecord/SyncGetAnswerRecord.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/AsyncListAnswerRecords.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/AsyncListAnswerRecordsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecords.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/updateanswerrecord/AsyncUpdateAnswerRecord.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecord.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecordAnswerrecordFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordssettings/getanswerrecord/SyncGetAnswerRecord.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/AsyncCreateContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/SyncCreateContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/SyncCreateContextSessionnameContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/SyncCreateContextStringContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/AsyncDeleteAllContexts.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/SyncDeleteAllContexts.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/SyncDeleteAllContextsSessionname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/SyncDeleteAllContextsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/AsyncDeleteContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/SyncDeleteContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/SyncDeleteContextContextname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/SyncDeleteContextString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/AsyncGetContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/SyncGetContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/SyncGetContextContextname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/SyncGetContextString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/AsyncListContexts.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/AsyncListContextsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/SyncListContexts.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/SyncListContextsSessionname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/SyncListContextsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/AsyncUpdateContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/SyncUpdateContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/SyncUpdateContextContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/SyncUpdateContextContextFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextssettings/getcontext/SyncGetContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfig.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfigLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfig.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfigString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/AsyncCreateConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileLocationnameConversationprofile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileProjectnameConversationprofile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileStringConversationprofile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/AsyncDeleteConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileConversationprofilename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/AsyncGetConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/SyncGetConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileConversationprofilename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfiles.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfilesPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfiles.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfig.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfigLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfig.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfigString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/updateconversationprofile/AsyncUpdateConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfileConversationprofileFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilessettings/getconversationprofile/SyncGetConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/AsyncBatchCreateMessages.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/SyncBatchCreateMessages.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/SyncBatchCreateMessagesConversationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/SyncBatchCreateMessagesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/AsyncCompleteConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/SyncCompleteConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/SyncCompleteConversationConversationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/SyncCompleteConversationString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/AsyncCreateConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversationLocationnameConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversationProjectnameConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversationStringConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/AsyncGetConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/SyncGetConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/SyncGetConversationConversationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/SyncGetConversationString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/AsyncListConversations.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/AsyncListConversationsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversations.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversationsLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversationsProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversationsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/AsyncListMessages.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/AsyncListMessagesPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/SyncListMessages.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/SyncListMessagesConversationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/SyncListMessagesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationssettings/createconversation/SyncCreateConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/AsyncCreateDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/AsyncCreateDocumentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/SyncCreateDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/SyncCreateDocumentKnowledgebasenameDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/SyncCreateDocumentStringDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/AsyncDeleteDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/AsyncDeleteDocumentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/SyncDeleteDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/SyncDeleteDocumentDocumentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/SyncDeleteDocumentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/AsyncGetDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/SyncGetDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/SyncGetDocumentDocumentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/SyncGetDocumentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/importdocuments/AsyncImportDocuments.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/importdocuments/AsyncImportDocumentsLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/importdocuments/SyncImportDocuments.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/AsyncListDocuments.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/AsyncListDocumentsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/SyncListDocuments.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/SyncListDocumentsKnowledgebasename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/SyncListDocumentsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/AsyncReloadDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/AsyncReloadDocumentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/SyncReloadDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/SyncReloadDocumentDocumentnameGcssource.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/SyncReloadDocumentStringGcssource.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/AsyncUpdateDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/AsyncUpdateDocumentLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/SyncUpdateDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/SyncUpdateDocumentDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/SyncUpdateDocumentDocumentFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentssettings/getdocument/SyncGetDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/AsyncBatchCreateEntities.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/AsyncBatchCreateEntitiesLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntities.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentity.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentityString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentity.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentityString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntities.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntitiesLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntities.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstring.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstring.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypesLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesAgentnameListstring.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesStringListstring.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntities.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntitiesLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntities.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentity.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentityString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentity.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentityString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypesLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentitytypes/SyncBatchUpdateEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/AsyncCreateEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytype.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytype.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/AsyncDeleteEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/SyncDeleteEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeEntitytypename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/AsyncGetEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypenameString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeStringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/AsyncListEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/AsyncListEntityTypesPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesAgentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesAgentnameString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesStringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/AsyncUpdateEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytype.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytypeStringFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypessettings/getentitytype/SyncGetEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/createenvironment/AsyncCreateEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/createenvironment/SyncCreateEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/deleteenvironment/SyncDeleteEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironment/AsyncGetEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironment/SyncGetEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistory.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistoryPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironmenthistory/SyncGetEnvironmentHistory.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/AsyncListEnvironments.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/SyncListEnvironments.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/SyncListEnvironmentsAgentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/SyncListEnvironmentsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/updateenvironment/AsyncUpdateEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/updateenvironment/SyncUpdateEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentssettings/getenvironment/SyncGetEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/AsyncGetFulfillment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/SyncGetFulfillment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/SyncGetFulfillmentFulfillmentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/SyncGetFulfillmentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/updatefulfillment/AsyncUpdateFulfillment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillmentFulfillmentFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentssettings/getfulfillment/SyncGetFulfillment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/AsyncBatchDeleteIntents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/AsyncBatchDeleteIntentsLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/SyncBatchDeleteIntents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsAgentnameListintent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsStringListintent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/AsyncBatchUpdateIntents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/AsyncBatchUpdateIntentsLRO.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameIntentbatch.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringIntentbatch.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/AsyncCreateIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentAgentnameIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentAgentnameIntentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentStringIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentStringIntentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/AsyncDeleteIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/SyncDeleteIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/SyncDeleteIntentIntentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/SyncDeleteIntentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/AsyncGetIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentIntentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentIntentnameString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentStringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/AsyncListIntents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/AsyncListIntentsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntents.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsAgentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsAgentnameString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsStringString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/AsyncUpdateIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntentFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntentString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntentStringFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentssettings/getintent/SyncGetIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/AsyncCreateKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseLocationnameKnowledgebase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseProjectnameKnowledgebase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseStringKnowledgebase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/AsyncDeleteKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseKnowledgebasename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/AsyncGetKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseKnowledgebasename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBases.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBasesPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBases.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesLocationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesProjectname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/AsyncUpdateKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBaseKnowledgebase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBaseKnowledgebaseFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasessettings/getknowledgebase/SyncGetKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/AsyncAnalyzeContent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameEventinput.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameTextinput.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentStringEventinput.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentStringTextinput.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/compilesuggestion/AsyncCompileSuggestion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/compilesuggestion/SyncCompileSuggestion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/AsyncCreateParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/SyncCreateParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/SyncCreateParticipantConversationnameParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/SyncCreateParticipantStringParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/AsyncGetParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/SyncGetParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/SyncGetParticipantParticipantname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/SyncGetParticipantString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/AsyncListParticipants.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/AsyncListParticipantsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/SyncListParticipants.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/SyncListParticipantsConversationname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/SyncListParticipantsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listsuggestions/AsyncListSuggestions.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listsuggestions/AsyncListSuggestionsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listsuggestions/SyncListSuggestions.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/streaminganalyzecontent/AsyncStreamingAnalyzeContent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/AsyncSuggestArticles.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/SyncSuggestArticles.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/SyncSuggestArticlesParticipantname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/SyncSuggestArticlesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/AsyncSuggestFaqAnswers.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswers.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersParticipantname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/AsyncSuggestSmartReplies.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/SyncSuggestSmartReplies.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesParticipantname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/updateparticipant/AsyncUpdateParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/updateparticipant/SyncUpdateParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/updateparticipant/SyncUpdateParticipantParticipantFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantssettings/createparticipant/SyncCreateParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/AsyncCreateSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeSessionnameSessionentitytype.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeStringSessionentitytype.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/AsyncDeleteSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeSessionentitytypename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/AsyncGetSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeSessionentitytypename.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypesPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypes.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesSessionname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/AsyncUpdateSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytype.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytypeFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypessettings/getsessionentitytype/SyncGetSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/AsyncDetectIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/SyncDetectIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/SyncDetectIntentSessionnameQueryinput.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/SyncDetectIntentStringQueryinput.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/streamingdetectintent/AsyncStreamingDetectIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionssettings/detectintent/SyncDetectIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/agentsstubsettings/getagent/SyncGetAgent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/answerrecordsstubsettings/getanswerrecord/SyncGetAnswerRecord.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/contextsstubsettings/getcontext/SyncGetContext.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/conversationprofilesstubsettings/getconversationprofile/SyncGetConversationProfile.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/conversationsstubsettings/createconversation/SyncCreateConversation.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/documentsstubsettings/getdocument/SyncGetDocument.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/entitytypesstubsettings/getentitytype/SyncGetEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/fulfillmentsstubsettings/getfulfillment/SyncGetFulfillment.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/intentsstubsettings/getintent/SyncGetIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/knowledgebasesstubsettings/getknowledgebase/SyncGetKnowledgeBase.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/participantsstubsettings/createparticipant/SyncCreateParticipant.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/sessionentitytypesstubsettings/getsessionentitytype/SyncGetSessionEntityType.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/sessionsstubsettings/detectintent/SyncDetectIntent.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/versionsstubsettings/getversion/SyncGetVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/AsyncCreateVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/SyncCreateVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/SyncCreateVersionAgentnameVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/SyncCreateVersionStringVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/AsyncDeleteVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/SyncDeleteVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/SyncDeleteVersionString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/SyncDeleteVersionVersionname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/AsyncGetVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/SyncGetVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/SyncGetVersionString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/SyncGetVersionVersionname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/AsyncListVersions.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/AsyncListVersionsPaged.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/SyncListVersions.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/SyncListVersionsAgentname.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/SyncListVersionsString.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/updateversion/AsyncUpdateVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/updateversion/SyncUpdateVersion.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/updateversion/SyncUpdateVersionVersionFieldmask.java create mode 100644 java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionssettings/getversion/SyncGetVersion.java diff --git a/java-dialogflow/google-cloud-dialogflow/pom.xml b/java-dialogflow/google-cloud-dialogflow/pom.xml index 9ca9971b642a..864e6c38b41b 100644 --- a/java-dialogflow/google-cloud-dialogflow/pom.xml +++ b/java-dialogflow/google-cloud-dialogflow/pom.xml @@ -61,6 +61,10 @@ com.google.api gax-grpc + + + com.google.api + gax-httpjson org.threeten @@ -89,12 +93,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsClient.java index 2e0c7ea4dddf..250c4ffadc0a 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.dialogflow.v2.stub.AgentsStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.Struct; import java.io.IOException; @@ -101,13 +101,28 @@ * AgentsClient agentsClient = AgentsClient.create(agentsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * AgentsSettings agentsSettings =
+ *     AgentsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             AgentsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * AgentsClient agentsClient = AgentsClient.create(agentsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class AgentsClient implements BackgroundResource { private final AgentsSettings settings; private final AgentsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of AgentsClient with default settings. */ public static final AgentsClient create() throws IOException { @@ -137,13 +152,17 @@ public static final AgentsClient create(AgentsStub stub) { protected AgentsClient(AgentsSettings settings) throws IOException { this.settings = settings; this.stub = ((AgentsStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected AgentsClient(AgentsStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final AgentsSettings getSettings() { @@ -158,10 +177,18 @@ public AgentsStub getStub() { * 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() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * 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 getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Retrieves the specified agent. diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsSettings.java index 5e6b06f6cc4c..22fa2a6fa6d6 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -166,11 +167,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return AgentsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return AgentsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return AgentsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return AgentsStubSettings.defaultTransportChannelProvider(); } @@ -180,11 +188,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return AgentsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -222,6 +236,11 @@ private static Builder createDefault() { return new Builder(AgentsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(AgentsStubSettings.newHttpJsonBuilder()); + } + public AgentsStubSettings.Builder getStubSettingsBuilder() { return ((AgentsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AnswerRecordsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AnswerRecordsClient.java index 68a07365465d..e0babd8af9f6 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AnswerRecordsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AnswerRecordsClient.java @@ -99,6 +99,20 @@ * AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * AnswerRecordsSettings answerRecordsSettings =
+ *     AnswerRecordsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             AnswerRecordsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AnswerRecordsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AnswerRecordsSettings.java index f98100b0b1cc..76beaa54cb20 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AnswerRecordsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AnswerRecordsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -107,11 +108,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return AnswerRecordsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return AnswerRecordsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return AnswerRecordsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return AnswerRecordsStubSettings.defaultTransportChannelProvider(); } @@ -121,11 +129,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return AnswerRecordsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -163,6 +177,11 @@ private static Builder createDefault() { return new Builder(AnswerRecordsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(AnswerRecordsStubSettings.newHttpJsonBuilder()); + } + public AnswerRecordsStubSettings.Builder getStubSettingsBuilder() { return ((AnswerRecordsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsClient.java index 6732f3a23837..bb63a4cd03e4 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsClient.java @@ -99,6 +99,20 @@ * ContextsClient contextsClient = ContextsClient.create(contextsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ContextsSettings contextsSettings =
+ *     ContextsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ContextsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ContextsClient contextsClient = ContextsClient.create(contextsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsSettings.java index fd4270a56326..10b6781428b9 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -126,11 +127,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ContextsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ContextsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ContextsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ContextsStubSettings.defaultTransportChannelProvider(); } @@ -140,11 +148,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ContextsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -182,6 +196,11 @@ private static Builder createDefault() { return new Builder(ContextsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ContextsStubSettings.newHttpJsonBuilder()); + } + public ContextsStubSettings.Builder getStubSettingsBuilder() { return ((ContextsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationDatasetsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationDatasetsClient.java index 31eae2751cd4..a62d49985c42 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationDatasetsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationDatasetsClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.dialogflow.v2.stub.ConversationDatasetsStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; @@ -109,13 +109,29 @@ * ConversationDatasetsClient.create(conversationDatasetsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ConversationDatasetsSettings conversationDatasetsSettings =
+ *     ConversationDatasetsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ConversationDatasetsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ConversationDatasetsClient conversationDatasetsClient =
+ *     ConversationDatasetsClient.create(conversationDatasetsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class ConversationDatasetsClient implements BackgroundResource { private final ConversationDatasetsSettings settings; private final ConversationDatasetsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ConversationDatasetsClient with default settings. */ public static final ConversationDatasetsClient create() throws IOException { @@ -147,13 +163,17 @@ public static final ConversationDatasetsClient create(ConversationDatasetsStub s protected ConversationDatasetsClient(ConversationDatasetsSettings settings) throws IOException { this.settings = settings; this.stub = ((ConversationDatasetsStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected ConversationDatasetsClient(ConversationDatasetsStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ConversationDatasetsSettings getSettings() { @@ -168,10 +188,18 @@ public ConversationDatasetsStub getStub() { * 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() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * 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 getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new conversation dataset. diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationDatasetsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationDatasetsSettings.java index 2b8beb99d84a..03ebf927427a 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationDatasetsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationDatasetsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -164,11 +165,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ConversationDatasetsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ConversationDatasetsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ConversationDatasetsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ConversationDatasetsStubSettings.defaultTransportChannelProvider(); } @@ -178,11 +186,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ConversationDatasetsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -221,6 +235,11 @@ private static Builder createDefault() { return new Builder(ConversationDatasetsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ConversationDatasetsStubSettings.newHttpJsonBuilder()); + } + public ConversationDatasetsStubSettings.Builder getStubSettingsBuilder() { return ((ConversationDatasetsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationModelsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationModelsClient.java index 77c2de0927c7..d7dd8158e299 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationModelsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationModelsClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.dialogflow.v2.stub.ConversationModelsStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; @@ -104,13 +104,29 @@ * ConversationModelsClient.create(conversationModelsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ConversationModelsSettings conversationModelsSettings =
+ *     ConversationModelsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ConversationModelsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ConversationModelsClient conversationModelsClient =
+ *     ConversationModelsClient.create(conversationModelsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class ConversationModelsClient implements BackgroundResource { private final ConversationModelsSettings settings; private final ConversationModelsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ConversationModelsClient with default settings. */ public static final ConversationModelsClient create() throws IOException { @@ -142,13 +158,17 @@ public static final ConversationModelsClient create(ConversationModelsStub stub) protected ConversationModelsClient(ConversationModelsSettings settings) throws IOException { this.settings = settings; this.stub = ((ConversationModelsStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected ConversationModelsClient(ConversationModelsStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ConversationModelsSettings getSettings() { @@ -163,10 +183,18 @@ public ConversationModelsStub getStub() { * 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() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * 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 getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a model. diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationModelsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationModelsSettings.java index bad24ba7c4bb..04bedb0c2f17 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationModelsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationModelsSettings.java @@ -24,6 +24,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -208,11 +209,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ConversationModelsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ConversationModelsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ConversationModelsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ConversationModelsStubSettings.defaultTransportChannelProvider(); } @@ -222,11 +230,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ConversationModelsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -264,6 +278,11 @@ private static Builder createDefault() { return new Builder(ConversationModelsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ConversationModelsStubSettings.newHttpJsonBuilder()); + } + public ConversationModelsStubSettings.Builder getStubSettingsBuilder() { return ((ConversationModelsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationProfilesClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationProfilesClient.java index 4f18e7e58e3e..1c096aa03059 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationProfilesClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationProfilesClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.dialogflow.v2.stub.ConversationProfilesStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -109,13 +109,29 @@ * ConversationProfilesClient.create(conversationProfilesSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ConversationProfilesSettings conversationProfilesSettings =
+ *     ConversationProfilesSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ConversationProfilesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ConversationProfilesClient conversationProfilesClient =
+ *     ConversationProfilesClient.create(conversationProfilesSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class ConversationProfilesClient implements BackgroundResource { private final ConversationProfilesSettings settings; private final ConversationProfilesStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ConversationProfilesClient with default settings. */ public static final ConversationProfilesClient create() throws IOException { @@ -147,13 +163,17 @@ public static final ConversationProfilesClient create(ConversationProfilesStub s protected ConversationProfilesClient(ConversationProfilesSettings settings) throws IOException { this.settings = settings; this.stub = ((ConversationProfilesStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected ConversationProfilesClient(ConversationProfilesStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ConversationProfilesSettings getSettings() { @@ -168,10 +188,18 @@ public ConversationProfilesStub getStub() { * 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() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * 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 getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the list of all conversation profiles in the specified project. diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationProfilesSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationProfilesSettings.java index 06f2973b7a3e..aa2896c8d4dc 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationProfilesSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationProfilesSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -171,11 +172,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ConversationProfilesStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ConversationProfilesStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ConversationProfilesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ConversationProfilesStubSettings.defaultTransportChannelProvider(); } @@ -185,11 +193,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ConversationProfilesStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -228,6 +242,11 @@ private static Builder createDefault() { return new Builder(ConversationProfilesStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ConversationProfilesStubSettings.newHttpJsonBuilder()); + } + public ConversationProfilesStubSettings.Builder getStubSettingsBuilder() { return ((ConversationProfilesStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationsClient.java index 859280f182c1..e5ff72b9f5e0 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationsClient.java @@ -98,6 +98,20 @@ * ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ConversationsSettings conversationsSettings =
+ *     ConversationsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ConversationsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationsSettings.java index 6f0c93cfa987..2aebe0796665 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ConversationsSettings.java @@ -24,6 +24,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -125,11 +126,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ConversationsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ConversationsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ConversationsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ConversationsStubSettings.defaultTransportChannelProvider(); } @@ -139,11 +147,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ConversationsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -181,6 +195,11 @@ private static Builder createDefault() { return new Builder(ConversationsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ConversationsStubSettings.newHttpJsonBuilder()); + } + public ConversationsStubSettings.Builder getStubSettingsBuilder() { return ((ConversationsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/DocumentsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/DocumentsClient.java index 6127f0a11285..22603d2b8e62 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/DocumentsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/DocumentsClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.dialogflow.v2.stub.DocumentsStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -105,13 +105,28 @@ * DocumentsClient documentsClient = DocumentsClient.create(documentsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * DocumentsSettings documentsSettings =
+ *     DocumentsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             DocumentsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * DocumentsClient documentsClient = DocumentsClient.create(documentsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class DocumentsClient implements BackgroundResource { private final DocumentsSettings settings; private final DocumentsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of DocumentsClient with default settings. */ public static final DocumentsClient create() throws IOException { @@ -141,13 +156,17 @@ public static final DocumentsClient create(DocumentsStub stub) { protected DocumentsClient(DocumentsSettings settings) throws IOException { this.settings = settings; this.stub = ((DocumentsStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected DocumentsClient(DocumentsStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final DocumentsSettings getSettings() { @@ -162,10 +181,18 @@ public DocumentsStub getStub() { * 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() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * 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 getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the list of all documents of the knowledge base. diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/DocumentsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/DocumentsSettings.java index a0ce3c4771f1..44bd0532519c 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/DocumentsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/DocumentsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -175,11 +176,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return DocumentsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return DocumentsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return DocumentsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return DocumentsStubSettings.defaultTransportChannelProvider(); } @@ -189,11 +197,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return DocumentsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -231,6 +245,11 @@ private static Builder createDefault() { return new Builder(DocumentsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(DocumentsStubSettings.newHttpJsonBuilder()); + } + public DocumentsStubSettings.Builder getStubSettingsBuilder() { return ((DocumentsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesClient.java index 268ede6e9cf3..392394ed6bcd 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.dialogflow.v2.stub.EntityTypesStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.Struct; import java.io.IOException; @@ -102,13 +102,28 @@ * EntityTypesClient entityTypesClient = EntityTypesClient.create(entityTypesSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * EntityTypesSettings entityTypesSettings =
+ *     EntityTypesSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             EntityTypesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * EntityTypesClient entityTypesClient = EntityTypesClient.create(entityTypesSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class EntityTypesClient implements BackgroundResource { private final EntityTypesSettings settings; private final EntityTypesStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of EntityTypesClient with default settings. */ public static final EntityTypesClient create() throws IOException { @@ -139,13 +154,17 @@ public static final EntityTypesClient create(EntityTypesStub stub) { protected EntityTypesClient(EntityTypesSettings settings) throws IOException { this.settings = settings; this.stub = ((EntityTypesStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected EntityTypesClient(EntityTypesStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final EntityTypesSettings getSettings() { @@ -160,10 +179,18 @@ public EntityTypesStub getStub() { * 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() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * 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 getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the list of all entity types in the specified agent. diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesSettings.java index feae4a2ee1be..fe7ef2610d9a 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -183,11 +184,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return EntityTypesStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return EntityTypesStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return EntityTypesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return EntityTypesStubSettings.defaultTransportChannelProvider(); } @@ -197,11 +205,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return EntityTypesStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -239,6 +253,11 @@ private static Builder createDefault() { return new Builder(EntityTypesStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(EntityTypesStubSettings.newHttpJsonBuilder()); + } + public EntityTypesStubSettings.Builder getStubSettingsBuilder() { return ((EntityTypesStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EnvironmentsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EnvironmentsClient.java index 8eb2bd551c20..02b5dde5e26e 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EnvironmentsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EnvironmentsClient.java @@ -101,6 +101,20 @@ * EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * EnvironmentsSettings environmentsSettings =
+ *     EnvironmentsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             EnvironmentsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EnvironmentsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EnvironmentsSettings.java index 8f957f2c9bf0..c631c0d12cef 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EnvironmentsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EnvironmentsSettings.java @@ -24,6 +24,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -131,11 +132,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return EnvironmentsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return EnvironmentsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return EnvironmentsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return EnvironmentsStubSettings.defaultTransportChannelProvider(); } @@ -145,11 +153,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return EnvironmentsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -187,6 +201,11 @@ private static Builder createDefault() { return new Builder(EnvironmentsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(EnvironmentsStubSettings.newHttpJsonBuilder()); + } + public EnvironmentsStubSettings.Builder getStubSettingsBuilder() { return ((EnvironmentsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/FulfillmentsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/FulfillmentsClient.java index 431103a3014a..1d4e170bf43c 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/FulfillmentsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/FulfillmentsClient.java @@ -89,6 +89,20 @@ * FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create(fulfillmentsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * FulfillmentsSettings fulfillmentsSettings =
+ *     FulfillmentsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             FulfillmentsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create(fulfillmentsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/FulfillmentsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/FulfillmentsSettings.java index de2fe92b74ca..3a0ccb44a8c6 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/FulfillmentsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/FulfillmentsSettings.java @@ -21,6 +21,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -102,11 +103,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return FulfillmentsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return FulfillmentsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return FulfillmentsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return FulfillmentsStubSettings.defaultTransportChannelProvider(); } @@ -116,11 +124,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return FulfillmentsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -158,6 +172,11 @@ private static Builder createDefault() { return new Builder(FulfillmentsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(FulfillmentsStubSettings.newHttpJsonBuilder()); + } + public FulfillmentsStubSettings.Builder getStubSettingsBuilder() { return ((FulfillmentsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsClient.java index 42bb047c5fc7..fa77b197f0c2 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.dialogflow.v2.stub.IntentsStubSettings; import com.google.common.util.concurrent.MoreExecutors; 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; @@ -102,13 +102,28 @@ * IntentsClient intentsClient = IntentsClient.create(intentsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * IntentsSettings intentsSettings =
+ *     IntentsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             IntentsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * IntentsClient intentsClient = IntentsClient.create(intentsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class IntentsClient implements BackgroundResource { private final IntentsSettings settings; private final IntentsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of IntentsClient with default settings. */ public static final IntentsClient create() throws IOException { @@ -138,13 +153,17 @@ public static final IntentsClient create(IntentsStub stub) { protected IntentsClient(IntentsSettings settings) throws IOException { this.settings = settings; this.stub = ((IntentsStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected IntentsClient(IntentsStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final IntentsSettings getSettings() { @@ -159,10 +178,18 @@ public IntentsStub getStub() { * 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() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * 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 getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the list of all intents in the specified agent. diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsSettings.java index 2e0c1eaa4701..7669defe305c 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -146,11 +147,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return IntentsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return IntentsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return IntentsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return IntentsStubSettings.defaultTransportChannelProvider(); } @@ -160,11 +168,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return IntentsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -202,6 +216,11 @@ private static Builder createDefault() { return new Builder(IntentsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(IntentsStubSettings.newHttpJsonBuilder()); + } + public IntentsStubSettings.Builder getStubSettingsBuilder() { return ((IntentsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/KnowledgeBasesClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/KnowledgeBasesClient.java index 882b39d68dd6..c3c9e49b073d 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/KnowledgeBasesClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/KnowledgeBasesClient.java @@ -100,6 +100,20 @@ * KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create(knowledgeBasesSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * KnowledgeBasesSettings knowledgeBasesSettings =
+ *     KnowledgeBasesSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             KnowledgeBasesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create(knowledgeBasesSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/KnowledgeBasesSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/KnowledgeBasesSettings.java index c8839d419aa6..a00ddab3a7a4 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/KnowledgeBasesSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/KnowledgeBasesSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -126,11 +127,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return KnowledgeBasesStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return KnowledgeBasesStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return KnowledgeBasesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return KnowledgeBasesStubSettings.defaultTransportChannelProvider(); } @@ -140,11 +148,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return KnowledgeBasesStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -182,6 +196,11 @@ private static Builder createDefault() { return new Builder(KnowledgeBasesStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(KnowledgeBasesStubSettings.newHttpJsonBuilder()); + } + public KnowledgeBasesStubSettings.Builder getStubSettingsBuilder() { return ((KnowledgeBasesStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ParticipantsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ParticipantsClient.java index f234b79ee1ff..f67f6e1b1168 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ParticipantsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ParticipantsClient.java @@ -99,6 +99,20 @@ * ParticipantsClient participantsClient = ParticipantsClient.create(participantsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ParticipantsSettings participantsSettings =
+ *     ParticipantsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ParticipantsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ParticipantsClient participantsClient = ParticipantsClient.create(participantsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ParticipantsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ParticipantsSettings.java index 34f892a2a6c5..58e1aa501086 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ParticipantsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ParticipantsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -140,11 +141,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ParticipantsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ParticipantsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ParticipantsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ParticipantsStubSettings.defaultTransportChannelProvider(); } @@ -154,11 +162,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ParticipantsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -196,6 +210,11 @@ private static Builder createDefault() { return new Builder(ParticipantsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ParticipantsStubSettings.newHttpJsonBuilder()); + } + public ParticipantsStubSettings.Builder getStubSettingsBuilder() { return ((ParticipantsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClient.java index 3ddc8ba8acda..ae01281fa931 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClient.java @@ -104,6 +104,21 @@ * SessionEntityTypesClient.create(sessionEntityTypesSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * SessionEntityTypesSettings sessionEntityTypesSettings =
+ *     SessionEntityTypesSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SessionEntityTypesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SessionEntityTypesClient sessionEntityTypesClient =
+ *     SessionEntityTypesClient.create(sessionEntityTypesSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesSettings.java index ad46d987b19b..be0182518bad 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -131,11 +132,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SessionEntityTypesStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return SessionEntityTypesStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SessionEntityTypesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SessionEntityTypesStubSettings.defaultTransportChannelProvider(); } @@ -145,11 +153,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SessionEntityTypesStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -187,6 +201,11 @@ private static Builder createDefault() { return new Builder(SessionEntityTypesStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SessionEntityTypesStubSettings.newHttpJsonBuilder()); + } + public SessionEntityTypesStubSettings.Builder getStubSettingsBuilder() { return ((SessionEntityTypesStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsClient.java index 406a1fb89342..ce0ee114fc1a 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsClient.java @@ -93,6 +93,20 @@ * SessionsClient sessionsClient = SessionsClient.create(sessionsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * SessionsSettings sessionsSettings =
+ *     SessionsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SessionsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SessionsClient sessionsClient = SessionsClient.create(sessionsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsSettings.java index 6f637c35c1ee..b3bcb01f5be1 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsSettings.java @@ -21,6 +21,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -103,11 +104,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SessionsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return SessionsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SessionsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SessionsStubSettings.defaultTransportChannelProvider(); } @@ -117,11 +125,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SessionsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -159,6 +173,11 @@ private static Builder createDefault() { return new Builder(SessionsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SessionsStubSettings.newHttpJsonBuilder()); + } + public SessionsStubSettings.Builder getStubSettingsBuilder() { return ((SessionsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/VersionsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/VersionsClient.java index 6abd5c13a7d2..c48aa888ed9c 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/VersionsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/VersionsClient.java @@ -98,6 +98,20 @@ * VersionsClient versionsClient = VersionsClient.create(versionsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * VersionsSettings versionsSettings =
+ *     VersionsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             VersionsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * VersionsClient versionsClient = VersionsClient.create(versionsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/VersionsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/VersionsSettings.java index 37242978d0c7..2baeddbc6891 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/VersionsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/VersionsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -121,11 +122,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return VersionsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return VersionsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return VersionsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return VersionsStubSettings.defaultTransportChannelProvider(); } @@ -135,11 +143,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return VersionsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -177,6 +191,11 @@ private static Builder createDefault() { return new Builder(VersionsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(VersionsStubSettings.newHttpJsonBuilder()); + } + public VersionsStubSettings.Builder getStubSettingsBuilder() { return ((VersionsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStub.java index 38013388442a..443098ca485e 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStub.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStub.java @@ -50,7 +50,11 @@ public abstract class AgentsStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable getAgentCallable() { diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStubSettings.java index 80107bf9d4d1..d3b16798be84 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -258,6 +261,11 @@ public AgentsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcAgentsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonAgentsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -290,29 +298,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(AgentsStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(AgentsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return AgentsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -473,6 +506,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .getAgentSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AnswerRecordsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AnswerRecordsStubSettings.java index defede857a1b..aac13ca3d4a9 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AnswerRecordsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AnswerRecordsStubSettings.java @@ -27,6 +27,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -181,6 +184,11 @@ public AnswerRecordsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcAnswerRecordsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonAnswerRecordsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -213,18 +221,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(AnswerRecordsStubSettings.class)) @@ -232,11 +247,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(AnswerRecordsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return AnswerRecordsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -333,6 +367,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listAnswerRecordsSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ContextsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ContextsStubSettings.java index e63682a6809a..9c30bd13f02b 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ContextsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ContextsStubSettings.java @@ -27,6 +27,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -199,6 +202,11 @@ public ContextsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcContextsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonContextsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -231,29 +239,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(ContextsStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(ContextsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ContextsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -376,6 +409,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listContextsSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationDatasetsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationDatasetsStub.java index 6621e6eddec8..5fc129bac9ca 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationDatasetsStub.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationDatasetsStub.java @@ -47,7 +47,11 @@ public abstract class ConversationDatasetsStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public OperationCallable< diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationDatasetsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationDatasetsStubSettings.java index c60532bf76db..80f14426228a 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationDatasetsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationDatasetsStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -276,6 +279,11 @@ public ConversationDatasetsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcConversationDatasetsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonConversationDatasetsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -308,18 +316,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ConversationDatasetsStubSettings.class)) @@ -327,11 +342,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ConversationDatasetsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ConversationDatasetsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -483,6 +517,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createConversationDatasetSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationModelsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationModelsStub.java index f1f64e6835dd..9ab95e2a076c 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationModelsStub.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationModelsStub.java @@ -55,7 +55,11 @@ public abstract class ConversationModelsStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public OperationCallable< diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationModelsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationModelsStubSettings.java index d17d6baf8853..ba0039a46d3d 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationModelsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationModelsStubSettings.java @@ -29,6 +29,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -420,6 +423,11 @@ public ConversationModelsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcConversationModelsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonConversationModelsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -452,18 +460,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ConversationModelsStubSettings.class)) @@ -471,11 +486,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ConversationModelsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ConversationModelsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -682,6 +716,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createConversationModelSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationProfilesStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationProfilesStub.java index 489904848b5b..55d4a877d7c7 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationProfilesStub.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationProfilesStub.java @@ -47,7 +47,11 @@ public abstract class ConversationProfilesStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationProfilesStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationProfilesStubSettings.java index 6ca02953ff92..3475ae0be224 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationProfilesStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationProfilesStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -282,6 +285,11 @@ public ConversationProfilesStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcConversationProfilesStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonConversationProfilesStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -314,18 +322,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ConversationProfilesStubSettings.class)) @@ -333,11 +348,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ConversationProfilesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ConversationProfilesStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -498,6 +532,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listConversationProfilesSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationsStubSettings.java index 76d6e242f12f..c0448551679c 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ConversationsStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -263,6 +266,11 @@ public ConversationsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcConversationsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonConversationsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -295,18 +303,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ConversationsStubSettings.class)) @@ -314,11 +329,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ConversationsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ConversationsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -439,6 +473,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createConversationSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/DocumentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/DocumentsStub.java index d2350ba18d74..a91b4044c522 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/DocumentsStub.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/DocumentsStub.java @@ -48,7 +48,11 @@ public abstract class DocumentsStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/DocumentsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/DocumentsStubSettings.java index c01835d1d902..623c2587fe70 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/DocumentsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/DocumentsStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -270,6 +273,11 @@ public DocumentsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDocumentsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonDocumentsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -302,29 +310,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(DocumentsStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(DocumentsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DocumentsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -500,6 +533,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listDocumentsSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStub.java index 09fd50b2bc01..550bf5804241 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStub.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStub.java @@ -50,7 +50,11 @@ public abstract class EntityTypesStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStubSettings.java index 38f6036d03a1..f3b7aa6824c5 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -288,6 +291,11 @@ public EntityTypesStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcEntityTypesStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonEntityTypesStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -320,18 +328,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(EntityTypesStubSettings.class)) @@ -339,11 +354,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(EntityTypesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return EntityTypesStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -533,6 +567,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listEntityTypesSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EnvironmentsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EnvironmentsStubSettings.java index eac7d1d0a54a..90f67a45af56 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EnvironmentsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EnvironmentsStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -275,6 +278,11 @@ public EnvironmentsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcEnvironmentsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonEnvironmentsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -307,18 +315,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(EnvironmentsStubSettings.class)) @@ -326,11 +341,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(EnvironmentsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return EnvironmentsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -459,6 +493,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listEnvironmentsSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/FulfillmentsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/FulfillmentsStubSettings.java index 1376b1b3214f..d285d3af2967 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/FulfillmentsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/FulfillmentsStubSettings.java @@ -24,6 +24,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -105,6 +108,11 @@ public FulfillmentsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcFulfillmentsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonFulfillmentsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -137,18 +145,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(FulfillmentsStubSettings.class)) @@ -156,11 +171,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(FulfillmentsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return FulfillmentsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -256,6 +290,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .getFulfillmentSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAgentsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAgentsCallableFactory.java new file mode 100644 index 000000000000..772db3030be3 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAgentsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Agents service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonAgentsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAgentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAgentsStub.java new file mode 100644 index 000000000000..4b432d3d19c3 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAgentsStub.java @@ -0,0 +1,705 @@ +/* + * Copyright 2022 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.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +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.DeleteAgentRequest; +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.GetValidationResultRequest; +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.SetAgentRequest; +import com.google.cloud.dialogflow.v2.TrainAgentRequest; +import com.google.cloud.dialogflow.v2.ValidationResult; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Agents service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonAgentsStub extends AgentsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(ExportAgentResponse.getDescriptor()) + .add(Struct.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor getAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Agents/GetAgent") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/agent", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/agent") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Agent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor setAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Agents/SetAgent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{agent.parent=projects/*}/agent", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "agent.parent", request.getAgent().getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{agent.parent=projects/*/locations/*}/agent") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> ProtoRestSerializer.create().toBody("agent", request.getAgent())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Agent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor deleteAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Agents/DeleteAgent") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/agent", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/agent") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + searchAgentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Agents/SearchAgents") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/agent:search", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/agent:search") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SearchAgentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + trainAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Agents/TrainAgent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/agent:train", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/agent:train") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (TrainAgentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + exportAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Agents/ExportAgent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/agent:export", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/agent:export") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ExportAgentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Agents/ImportAgent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/agent:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/agent:import") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportAgentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + restoreAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Agents/RestoreAgent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/agent:restore", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/agent:restore") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RestoreAgentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getValidationResultMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Agents/GetValidationResult") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/agent/validationResult", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*}/agent/validationResult") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ValidationResult.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable getAgentCallable; + private final UnaryCallable setAgentCallable; + private final UnaryCallable deleteAgentCallable; + 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 UnaryCallable + getValidationResultCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonAgentsStub create(AgentsStubSettings settings) throws IOException { + return new HttpJsonAgentsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonAgentsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonAgentsStub(AgentsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonAgentsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonAgentsStub( + AgentsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonAgentsStub, 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 HttpJsonAgentsStub(AgentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonAgentsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonAgentsStub, 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 HttpJsonAgentsStub( + AgentsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings getAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings searchAgentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(searchAgentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings trainAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(trainAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings exportAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(exportAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings restoreAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(restoreAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getValidationResultTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getValidationResultMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.getAgentCallable = + callableFactory.createUnaryCallable( + getAgentTransportSettings, settings.getAgentSettings(), clientContext); + this.setAgentCallable = + callableFactory.createUnaryCallable( + setAgentTransportSettings, settings.setAgentSettings(), clientContext); + this.deleteAgentCallable = + callableFactory.createUnaryCallable( + deleteAgentTransportSettings, settings.deleteAgentSettings(), 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, + httpJsonOperationsStub); + this.exportAgentCallable = + callableFactory.createUnaryCallable( + exportAgentTransportSettings, settings.exportAgentSettings(), clientContext); + this.exportAgentOperationCallable = + callableFactory.createOperationCallable( + exportAgentTransportSettings, + settings.exportAgentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importAgentCallable = + callableFactory.createUnaryCallable( + importAgentTransportSettings, settings.importAgentSettings(), clientContext); + this.importAgentOperationCallable = + callableFactory.createOperationCallable( + importAgentTransportSettings, + settings.importAgentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.restoreAgentCallable = + callableFactory.createUnaryCallable( + restoreAgentTransportSettings, settings.restoreAgentSettings(), clientContext); + this.restoreAgentOperationCallable = + callableFactory.createOperationCallable( + restoreAgentTransportSettings, + settings.restoreAgentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getValidationResultCallable = + callableFactory.createUnaryCallable( + getValidationResultTransportSettings, + settings.getValidationResultSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(getAgentMethodDescriptor); + methodDescriptors.add(setAgentMethodDescriptor); + methodDescriptors.add(deleteAgentMethodDescriptor); + methodDescriptors.add(searchAgentsMethodDescriptor); + methodDescriptors.add(trainAgentMethodDescriptor); + methodDescriptors.add(exportAgentMethodDescriptor); + methodDescriptors.add(importAgentMethodDescriptor); + methodDescriptors.add(restoreAgentMethodDescriptor); + methodDescriptors.add(getValidationResultMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable getAgentCallable() { + return getAgentCallable; + } + + @Override + public UnaryCallable setAgentCallable() { + return setAgentCallable; + } + + @Override + public UnaryCallable deleteAgentCallable() { + return deleteAgentCallable; + } + + @Override + public UnaryCallable searchAgentsCallable() { + return searchAgentsCallable; + } + + @Override + public UnaryCallable searchAgentsPagedCallable() { + return searchAgentsPagedCallable; + } + + @Override + public UnaryCallable trainAgentCallable() { + return trainAgentCallable; + } + + @Override + public OperationCallable trainAgentOperationCallable() { + return trainAgentOperationCallable; + } + + @Override + public UnaryCallable exportAgentCallable() { + return exportAgentCallable; + } + + @Override + public OperationCallable + exportAgentOperationCallable() { + return exportAgentOperationCallable; + } + + @Override + public UnaryCallable importAgentCallable() { + return importAgentCallable; + } + + @Override + public OperationCallable importAgentOperationCallable() { + return importAgentOperationCallable; + } + + @Override + public UnaryCallable restoreAgentCallable() { + return restoreAgentCallable; + } + + @Override + public OperationCallable restoreAgentOperationCallable() { + return restoreAgentOperationCallable; + } + + @Override + public UnaryCallable getValidationResultCallable() { + return getValidationResultCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAnswerRecordsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAnswerRecordsCallableFactory.java new file mode 100644 index 000000000000..b06f2e68921f --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAnswerRecordsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the AnswerRecords service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonAnswerRecordsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAnswerRecordsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAnswerRecordsStub.java new file mode 100644 index 000000000000..c8600b41800e --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonAnswerRecordsStub.java @@ -0,0 +1,275 @@ +/* + * Copyright 2022 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.AnswerRecordsClient.ListAnswerRecordsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.AnswerRecord; +import com.google.cloud.dialogflow.v2.ListAnswerRecordsRequest; +import com.google.cloud.dialogflow.v2.ListAnswerRecordsResponse; +import com.google.cloud.dialogflow.v2.UpdateAnswerRecordRequest; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the AnswerRecords service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonAnswerRecordsStub extends AnswerRecordsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listAnswerRecordsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.AnswerRecords/ListAnswerRecords") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/answerRecords", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/answerRecords") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListAnswerRecordsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateAnswerRecordMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.AnswerRecords/UpdateAnswerRecord") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{answerRecord.name=projects/*/answerRecords/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "answerRecord.name", request.getAnswerRecord().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{answerRecord.name=projects/*/locations/*/answerRecords/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("answerRecord", request.getAnswerRecord())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AnswerRecord.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + listAnswerRecordsCallable; + private final UnaryCallable + listAnswerRecordsPagedCallable; + private final UnaryCallable updateAnswerRecordCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonAnswerRecordsStub create(AnswerRecordsStubSettings settings) + throws IOException { + return new HttpJsonAnswerRecordsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonAnswerRecordsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonAnswerRecordsStub( + AnswerRecordsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonAnswerRecordsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonAnswerRecordsStub( + AnswerRecordsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonAnswerRecordsStub, 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 HttpJsonAnswerRecordsStub( + AnswerRecordsStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonAnswerRecordsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonAnswerRecordsStub, 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 HttpJsonAnswerRecordsStub( + AnswerRecordsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listAnswerRecordsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listAnswerRecordsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateAnswerRecordTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateAnswerRecordMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listAnswerRecordsCallable = + callableFactory.createUnaryCallable( + listAnswerRecordsTransportSettings, + settings.listAnswerRecordsSettings(), + clientContext); + this.listAnswerRecordsPagedCallable = + callableFactory.createPagedCallable( + listAnswerRecordsTransportSettings, + settings.listAnswerRecordsSettings(), + clientContext); + this.updateAnswerRecordCallable = + callableFactory.createUnaryCallable( + updateAnswerRecordTransportSettings, + settings.updateAnswerRecordSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listAnswerRecordsMethodDescriptor); + methodDescriptors.add(updateAnswerRecordMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + listAnswerRecordsCallable() { + return listAnswerRecordsCallable; + } + + @Override + public UnaryCallable + listAnswerRecordsPagedCallable() { + return listAnswerRecordsPagedCallable; + } + + @Override + public UnaryCallable updateAnswerRecordCallable() { + return updateAnswerRecordCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonContextsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonContextsCallableFactory.java new file mode 100644 index 000000000000..89de0b315a41 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonContextsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Contexts service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonContextsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonContextsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonContextsStub.java new file mode 100644 index 000000000000..28f95777d5d8 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonContextsStub.java @@ -0,0 +1,482 @@ +/* + * Copyright 2022 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.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +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 com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Contexts service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonContextsStub extends ContextsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listContextsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Contexts/ListContexts") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent/sessions/*}/contexts", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/agent/environments/*/users/*/sessions/*}/contexts", + "/v2/{parent=projects/*/locations/*/agent/sessions/*}/contexts", + "/v2/{parent=projects/*/locations/*/agent/environments/*/users/*/sessions/*}/contexts") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListContextsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getContextMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Contexts/GetContext") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/agent/sessions/*/contexts/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/agent/environments/*/users/*/sessions/*/contexts/*}", + "/v2/{name=projects/*/locations/*/agent/sessions/*/contexts/*}", + "/v2/{name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/contexts/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Context.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createContextMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Contexts/CreateContext") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent/sessions/*}/contexts", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/agent/environments/*/users/*/sessions/*}/contexts", + "/v2/{parent=projects/*/locations/*/agent/sessions/*}/contexts", + "/v2/{parent=projects/*/locations/*/agent/environments/*/users/*/sessions/*}/contexts") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("context", request.getContext())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Context.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateContextMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Contexts/UpdateContext") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{context.name=projects/*/agent/sessions/*/contexts/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "context.name", request.getContext().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{context.name=projects/*/agent/environments/*/users/*/sessions/*/contexts/*}", + "/v2/{context.name=projects/*/locations/*/agent/sessions/*/contexts/*}", + "/v2/{context.name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/contexts/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("context", request.getContext())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Context.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteContextMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Contexts/DeleteContext") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/agent/sessions/*/contexts/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/agent/environments/*/users/*/sessions/*/contexts/*}", + "/v2/{name=projects/*/locations/*/agent/sessions/*/contexts/*}", + "/v2/{name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/contexts/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteAllContextsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Contexts/DeleteAllContexts") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent/sessions/*}/contexts", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/agent/environments/*/users/*/sessions/*}/contexts", + "/v2/{parent=projects/*/locations/*/agent/sessions/*}/contexts", + "/v2/{parent=projects/*/locations/*/agent/environments/*/users/*/sessions/*}/contexts") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + 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 BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonContextsStub create(ContextsStubSettings settings) + throws IOException { + return new HttpJsonContextsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonContextsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonContextsStub( + ContextsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonContextsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonContextsStub( + ContextsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonContextsStub, 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 HttpJsonContextsStub(ContextsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonContextsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonContextsStub, 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 HttpJsonContextsStub( + ContextsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listContextsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listContextsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getContextTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getContextMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createContextTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createContextMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateContextTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateContextMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteContextTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteContextMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteAllContextsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteAllContextsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .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); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listContextsMethodDescriptor); + methodDescriptors.add(getContextMethodDescriptor); + methodDescriptors.add(createContextMethodDescriptor); + methodDescriptors.add(updateContextMethodDescriptor); + methodDescriptors.add(deleteContextMethodDescriptor); + methodDescriptors.add(deleteAllContextsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listContextsCallable() { + return listContextsCallable; + } + + @Override + public UnaryCallable listContextsPagedCallable() { + return listContextsPagedCallable; + } + + @Override + public UnaryCallable getContextCallable() { + return getContextCallable; + } + + @Override + public UnaryCallable createContextCallable() { + return createContextCallable; + } + + @Override + public UnaryCallable updateContextCallable() { + return updateContextCallable; + } + + @Override + public UnaryCallable deleteContextCallable() { + return deleteContextCallable; + } + + @Override + public UnaryCallable deleteAllContextsCallable() { + return deleteAllContextsCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationDatasetsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationDatasetsCallableFactory.java new file mode 100644 index 000000000000..dc2be709097b --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationDatasetsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ConversationDatasets service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonConversationDatasetsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationDatasetsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationDatasetsStub.java new file mode 100644 index 000000000000..f154362f6a99 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationDatasetsStub.java @@ -0,0 +1,541 @@ +/* + * Copyright 2022 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.ConversationDatasetsClient.ListConversationDatasetsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +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.ConversationDataset; +import com.google.cloud.dialogflow.v2.CreateConversationDatasetOperationMetadata; +import com.google.cloud.dialogflow.v2.CreateConversationDatasetRequest; +import com.google.cloud.dialogflow.v2.DeleteConversationDatasetOperationMetadata; +import com.google.cloud.dialogflow.v2.DeleteConversationDatasetRequest; +import com.google.cloud.dialogflow.v2.GetConversationDatasetRequest; +import com.google.cloud.dialogflow.v2.ImportConversationDataOperationMetadata; +import com.google.cloud.dialogflow.v2.ImportConversationDataOperationResponse; +import com.google.cloud.dialogflow.v2.ImportConversationDataRequest; +import com.google.cloud.dialogflow.v2.ListConversationDatasetsRequest; +import com.google.cloud.dialogflow.v2.ListConversationDatasetsResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ConversationDatasets service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonConversationDatasetsStub extends ConversationDatasetsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportConversationDataOperationResponse.getDescriptor()) + .add(ConversationDataset.getDescriptor()) + .add(Empty.getDescriptor()) + .add(DeleteConversationDatasetOperationMetadata.getDescriptor()) + .add(CreateConversationDatasetOperationMetadata.getDescriptor()) + .add(ImportConversationDataOperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createConversationDatasetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationDatasets/CreateConversationDataset") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*}/conversationDatasets", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("conversationDataset", request.getConversationDataset())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateConversationDatasetRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getConversationDatasetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationDatasets/GetConversationDataset") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/conversationDatasets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/conversationDatasets/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ConversationDataset.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListConversationDatasetsRequest, ListConversationDatasetsResponse> + listConversationDatasetsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationDatasets/ListConversationDatasets") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/conversationDatasets", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*}/conversationDatasets") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListConversationDatasetsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteConversationDatasetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationDatasets/DeleteConversationDataset") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/locations/*/conversationDatasets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteConversationDatasetRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importConversationDataMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationDatasets/ImportConversationData") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/conversationDatasets/*}:importConversationData", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/conversationDatasets/*}:importConversationData") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportConversationDataRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + createConversationDatasetCallable; + private final OperationCallable< + CreateConversationDatasetRequest, + ConversationDataset, + CreateConversationDatasetOperationMetadata> + createConversationDatasetOperationCallable; + private final UnaryCallable + getConversationDatasetCallable; + private final UnaryCallable + listConversationDatasetsCallable; + private final UnaryCallable< + ListConversationDatasetsRequest, ListConversationDatasetsPagedResponse> + listConversationDatasetsPagedCallable; + private final UnaryCallable + deleteConversationDatasetCallable; + private final OperationCallable< + DeleteConversationDatasetRequest, Empty, DeleteConversationDatasetOperationMetadata> + deleteConversationDatasetOperationCallable; + private final UnaryCallable + importConversationDataCallable; + private final OperationCallable< + ImportConversationDataRequest, + ImportConversationDataOperationResponse, + ImportConversationDataOperationMetadata> + importConversationDataOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonConversationDatasetsStub create( + ConversationDatasetsStubSettings settings) throws IOException { + return new HttpJsonConversationDatasetsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonConversationDatasetsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonConversationDatasetsStub( + ConversationDatasetsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonConversationDatasetsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonConversationDatasetsStub( + ConversationDatasetsStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonConversationDatasetsStub, 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 HttpJsonConversationDatasetsStub( + ConversationDatasetsStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonConversationDatasetsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonConversationDatasetsStub, 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 HttpJsonConversationDatasetsStub( + ConversationDatasetsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + createConversationDatasetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createConversationDatasetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getConversationDatasetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getConversationDatasetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listConversationDatasetsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listConversationDatasetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteConversationDatasetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteConversationDatasetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + importConversationDataTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importConversationDataMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createConversationDatasetCallable = + callableFactory.createUnaryCallable( + createConversationDatasetTransportSettings, + settings.createConversationDatasetSettings(), + clientContext); + this.createConversationDatasetOperationCallable = + callableFactory.createOperationCallable( + createConversationDatasetTransportSettings, + settings.createConversationDatasetOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getConversationDatasetCallable = + callableFactory.createUnaryCallable( + getConversationDatasetTransportSettings, + settings.getConversationDatasetSettings(), + clientContext); + this.listConversationDatasetsCallable = + callableFactory.createUnaryCallable( + listConversationDatasetsTransportSettings, + settings.listConversationDatasetsSettings(), + clientContext); + this.listConversationDatasetsPagedCallable = + callableFactory.createPagedCallable( + listConversationDatasetsTransportSettings, + settings.listConversationDatasetsSettings(), + clientContext); + this.deleteConversationDatasetCallable = + callableFactory.createUnaryCallable( + deleteConversationDatasetTransportSettings, + settings.deleteConversationDatasetSettings(), + clientContext); + this.deleteConversationDatasetOperationCallable = + callableFactory.createOperationCallable( + deleteConversationDatasetTransportSettings, + settings.deleteConversationDatasetOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importConversationDataCallable = + callableFactory.createUnaryCallable( + importConversationDataTransportSettings, + settings.importConversationDataSettings(), + clientContext); + this.importConversationDataOperationCallable = + callableFactory.createOperationCallable( + importConversationDataTransportSettings, + settings.importConversationDataOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createConversationDatasetMethodDescriptor); + methodDescriptors.add(getConversationDatasetMethodDescriptor); + methodDescriptors.add(listConversationDatasetsMethodDescriptor); + methodDescriptors.add(deleteConversationDatasetMethodDescriptor); + methodDescriptors.add(importConversationDataMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + createConversationDatasetCallable() { + return createConversationDatasetCallable; + } + + @Override + public OperationCallable< + CreateConversationDatasetRequest, + ConversationDataset, + CreateConversationDatasetOperationMetadata> + createConversationDatasetOperationCallable() { + return createConversationDatasetOperationCallable; + } + + @Override + public UnaryCallable + getConversationDatasetCallable() { + return getConversationDatasetCallable; + } + + @Override + public UnaryCallable + listConversationDatasetsCallable() { + return listConversationDatasetsCallable; + } + + @Override + public UnaryCallable + listConversationDatasetsPagedCallable() { + return listConversationDatasetsPagedCallable; + } + + @Override + public UnaryCallable + deleteConversationDatasetCallable() { + return deleteConversationDatasetCallable; + } + + @Override + public OperationCallable< + DeleteConversationDatasetRequest, Empty, DeleteConversationDatasetOperationMetadata> + deleteConversationDatasetOperationCallable() { + return deleteConversationDatasetOperationCallable; + } + + @Override + public UnaryCallable importConversationDataCallable() { + return importConversationDataCallable; + } + + @Override + public OperationCallable< + ImportConversationDataRequest, + ImportConversationDataOperationResponse, + ImportConversationDataOperationMetadata> + importConversationDataOperationCallable() { + return importConversationDataOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationModelsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationModelsCallableFactory.java new file mode 100644 index 000000000000..65ecca27e2e5 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationModelsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ConversationModels service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonConversationModelsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationModelsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationModelsStub.java new file mode 100644 index 000000000000..b5da866b98cb --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationModelsStub.java @@ -0,0 +1,847 @@ +/* + * Copyright 2022 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.ConversationModelsClient.ListConversationModelEvaluationsPagedResponse; +import static com.google.cloud.dialogflow.v2.ConversationModelsClient.ListConversationModelsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +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.ConversationModel; +import com.google.cloud.dialogflow.v2.ConversationModelEvaluation; +import com.google.cloud.dialogflow.v2.CreateConversationModelEvaluationOperationMetadata; +import com.google.cloud.dialogflow.v2.CreateConversationModelEvaluationRequest; +import com.google.cloud.dialogflow.v2.CreateConversationModelOperationMetadata; +import com.google.cloud.dialogflow.v2.CreateConversationModelRequest; +import com.google.cloud.dialogflow.v2.DeleteConversationModelOperationMetadata; +import com.google.cloud.dialogflow.v2.DeleteConversationModelRequest; +import com.google.cloud.dialogflow.v2.DeployConversationModelOperationMetadata; +import com.google.cloud.dialogflow.v2.DeployConversationModelRequest; +import com.google.cloud.dialogflow.v2.GetConversationModelEvaluationRequest; +import com.google.cloud.dialogflow.v2.GetConversationModelRequest; +import com.google.cloud.dialogflow.v2.ListConversationModelEvaluationsRequest; +import com.google.cloud.dialogflow.v2.ListConversationModelEvaluationsResponse; +import com.google.cloud.dialogflow.v2.ListConversationModelsRequest; +import com.google.cloud.dialogflow.v2.ListConversationModelsResponse; +import com.google.cloud.dialogflow.v2.UndeployConversationModelOperationMetadata; +import com.google.cloud.dialogflow.v2.UndeployConversationModelRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ConversationModels service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonConversationModelsStub extends ConversationModelsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(DeployConversationModelOperationMetadata.getDescriptor()) + .add(ConversationModel.getDescriptor()) + .add(CreateConversationModelEvaluationOperationMetadata.getDescriptor()) + .add(DeleteConversationModelOperationMetadata.getDescriptor()) + .add(ConversationModelEvaluation.getDescriptor()) + .add(CreateConversationModelOperationMetadata.getDescriptor()) + .add(UndeployConversationModelOperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createConversationModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationModels/CreateConversationModel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/conversationModels", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/conversationModels") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("conversationModel", request.getConversationModel())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateConversationModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getConversationModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationModels/GetConversationModel") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/conversationModels/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/conversationModels/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ConversationModel.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListConversationModelsRequest, ListConversationModelsResponse> + listConversationModelsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationModels/ListConversationModels") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/conversationModels", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/conversationModels") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListConversationModelsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteConversationModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationModels/DeleteConversationModel") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/conversationModels/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/conversationModels/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteConversationModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deployConversationModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationModels/DeployConversationModel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/conversationModels/*}:deploy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/conversationModels/*}:deploy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeployConversationModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + undeployConversationModelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationModels/UndeployConversationModel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/conversationModels/*}:undeploy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/conversationModels/*}:undeploy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UndeployConversationModelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor< + GetConversationModelEvaluationRequest, ConversationModelEvaluation> + getConversationModelEvaluationMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationModels/GetConversationModelEvaluation") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/conversationModels/*/evaluations/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/conversationModels/*/evaluations/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ConversationModelEvaluation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListConversationModelEvaluationsRequest, ListConversationModelEvaluationsResponse> + listConversationModelEvaluationsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationModels/ListConversationModelEvaluations") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/conversationModels/*}/evaluations", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/conversationModels/*}/evaluations") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance( + ListConversationModelEvaluationsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createConversationModelEvaluationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationModels/CreateConversationModelEvaluation") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v2/{parent=projects/*/locations/*/conversationModels/*}/evaluations", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateConversationModelEvaluationRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + createConversationModelCallable; + private final OperationCallable< + CreateConversationModelRequest, + ConversationModel, + CreateConversationModelOperationMetadata> + createConversationModelOperationCallable; + private final UnaryCallable + getConversationModelCallable; + private final UnaryCallable + listConversationModelsCallable; + private final UnaryCallable + listConversationModelsPagedCallable; + private final UnaryCallable + deleteConversationModelCallable; + private final OperationCallable< + DeleteConversationModelRequest, Empty, DeleteConversationModelOperationMetadata> + deleteConversationModelOperationCallable; + private final UnaryCallable + deployConversationModelCallable; + private final OperationCallable< + DeployConversationModelRequest, Empty, DeployConversationModelOperationMetadata> + deployConversationModelOperationCallable; + private final UnaryCallable + undeployConversationModelCallable; + private final OperationCallable< + UndeployConversationModelRequest, Empty, UndeployConversationModelOperationMetadata> + undeployConversationModelOperationCallable; + private final UnaryCallable + getConversationModelEvaluationCallable; + private final UnaryCallable< + ListConversationModelEvaluationsRequest, ListConversationModelEvaluationsResponse> + listConversationModelEvaluationsCallable; + private final UnaryCallable< + ListConversationModelEvaluationsRequest, ListConversationModelEvaluationsPagedResponse> + listConversationModelEvaluationsPagedCallable; + private final UnaryCallable + createConversationModelEvaluationCallable; + private final OperationCallable< + CreateConversationModelEvaluationRequest, + ConversationModelEvaluation, + CreateConversationModelEvaluationOperationMetadata> + createConversationModelEvaluationOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonConversationModelsStub create(ConversationModelsStubSettings settings) + throws IOException { + return new HttpJsonConversationModelsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonConversationModelsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonConversationModelsStub( + ConversationModelsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonConversationModelsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonConversationModelsStub( + ConversationModelsStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonConversationModelsStub, 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 HttpJsonConversationModelsStub( + ConversationModelsStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonConversationModelsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonConversationModelsStub, 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 HttpJsonConversationModelsStub( + ConversationModelsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + createConversationModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createConversationModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getConversationModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getConversationModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listConversationModelsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listConversationModelsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteConversationModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteConversationModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deployConversationModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deployConversationModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + undeployConversationModelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(undeployConversationModelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getConversationModelEvaluationTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(getConversationModelEvaluationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + ListConversationModelEvaluationsRequest, ListConversationModelEvaluationsResponse> + listConversationModelEvaluationsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listConversationModelEvaluationsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createConversationModelEvaluationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createConversationModelEvaluationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createConversationModelCallable = + callableFactory.createUnaryCallable( + createConversationModelTransportSettings, + settings.createConversationModelSettings(), + clientContext); + this.createConversationModelOperationCallable = + callableFactory.createOperationCallable( + createConversationModelTransportSettings, + settings.createConversationModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getConversationModelCallable = + callableFactory.createUnaryCallable( + getConversationModelTransportSettings, + settings.getConversationModelSettings(), + clientContext); + this.listConversationModelsCallable = + callableFactory.createUnaryCallable( + listConversationModelsTransportSettings, + settings.listConversationModelsSettings(), + clientContext); + this.listConversationModelsPagedCallable = + callableFactory.createPagedCallable( + listConversationModelsTransportSettings, + settings.listConversationModelsSettings(), + clientContext); + this.deleteConversationModelCallable = + callableFactory.createUnaryCallable( + deleteConversationModelTransportSettings, + settings.deleteConversationModelSettings(), + clientContext); + this.deleteConversationModelOperationCallable = + callableFactory.createOperationCallable( + deleteConversationModelTransportSettings, + settings.deleteConversationModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deployConversationModelCallable = + callableFactory.createUnaryCallable( + deployConversationModelTransportSettings, + settings.deployConversationModelSettings(), + clientContext); + this.deployConversationModelOperationCallable = + callableFactory.createOperationCallable( + deployConversationModelTransportSettings, + settings.deployConversationModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.undeployConversationModelCallable = + callableFactory.createUnaryCallable( + undeployConversationModelTransportSettings, + settings.undeployConversationModelSettings(), + clientContext); + this.undeployConversationModelOperationCallable = + callableFactory.createOperationCallable( + undeployConversationModelTransportSettings, + settings.undeployConversationModelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getConversationModelEvaluationCallable = + callableFactory.createUnaryCallable( + getConversationModelEvaluationTransportSettings, + settings.getConversationModelEvaluationSettings(), + clientContext); + this.listConversationModelEvaluationsCallable = + callableFactory.createUnaryCallable( + listConversationModelEvaluationsTransportSettings, + settings.listConversationModelEvaluationsSettings(), + clientContext); + this.listConversationModelEvaluationsPagedCallable = + callableFactory.createPagedCallable( + listConversationModelEvaluationsTransportSettings, + settings.listConversationModelEvaluationsSettings(), + clientContext); + this.createConversationModelEvaluationCallable = + callableFactory.createUnaryCallable( + createConversationModelEvaluationTransportSettings, + settings.createConversationModelEvaluationSettings(), + clientContext); + this.createConversationModelEvaluationOperationCallable = + callableFactory.createOperationCallable( + createConversationModelEvaluationTransportSettings, + settings.createConversationModelEvaluationOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createConversationModelMethodDescriptor); + methodDescriptors.add(getConversationModelMethodDescriptor); + methodDescriptors.add(listConversationModelsMethodDescriptor); + methodDescriptors.add(deleteConversationModelMethodDescriptor); + methodDescriptors.add(deployConversationModelMethodDescriptor); + methodDescriptors.add(undeployConversationModelMethodDescriptor); + methodDescriptors.add(getConversationModelEvaluationMethodDescriptor); + methodDescriptors.add(listConversationModelEvaluationsMethodDescriptor); + methodDescriptors.add(createConversationModelEvaluationMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + createConversationModelCallable() { + return createConversationModelCallable; + } + + @Override + public OperationCallable< + CreateConversationModelRequest, + ConversationModel, + CreateConversationModelOperationMetadata> + createConversationModelOperationCallable() { + return createConversationModelOperationCallable; + } + + @Override + public UnaryCallable + getConversationModelCallable() { + return getConversationModelCallable; + } + + @Override + public UnaryCallable + listConversationModelsCallable() { + return listConversationModelsCallable; + } + + @Override + public UnaryCallable + listConversationModelsPagedCallable() { + return listConversationModelsPagedCallable; + } + + @Override + public UnaryCallable + deleteConversationModelCallable() { + return deleteConversationModelCallable; + } + + @Override + public OperationCallable< + DeleteConversationModelRequest, Empty, DeleteConversationModelOperationMetadata> + deleteConversationModelOperationCallable() { + return deleteConversationModelOperationCallable; + } + + @Override + public UnaryCallable + deployConversationModelCallable() { + return deployConversationModelCallable; + } + + @Override + public OperationCallable< + DeployConversationModelRequest, Empty, DeployConversationModelOperationMetadata> + deployConversationModelOperationCallable() { + return deployConversationModelOperationCallable; + } + + @Override + public UnaryCallable + undeployConversationModelCallable() { + return undeployConversationModelCallable; + } + + @Override + public OperationCallable< + UndeployConversationModelRequest, Empty, UndeployConversationModelOperationMetadata> + undeployConversationModelOperationCallable() { + return undeployConversationModelOperationCallable; + } + + @Override + public UnaryCallable + getConversationModelEvaluationCallable() { + return getConversationModelEvaluationCallable; + } + + @Override + public UnaryCallable< + ListConversationModelEvaluationsRequest, ListConversationModelEvaluationsResponse> + listConversationModelEvaluationsCallable() { + return listConversationModelEvaluationsCallable; + } + + @Override + public UnaryCallable< + ListConversationModelEvaluationsRequest, ListConversationModelEvaluationsPagedResponse> + listConversationModelEvaluationsPagedCallable() { + return listConversationModelEvaluationsPagedCallable; + } + + @Override + public UnaryCallable + createConversationModelEvaluationCallable() { + return createConversationModelEvaluationCallable; + } + + @Override + public OperationCallable< + CreateConversationModelEvaluationRequest, + ConversationModelEvaluation, + CreateConversationModelEvaluationOperationMetadata> + createConversationModelEvaluationOperationCallable() { + return createConversationModelEvaluationOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationProfilesCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationProfilesCallableFactory.java new file mode 100644 index 000000000000..b81e5465b218 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationProfilesCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ConversationProfiles service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonConversationProfilesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationProfilesStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationProfilesStub.java new file mode 100644 index 000000000000..f95c3656f773 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationProfilesStub.java @@ -0,0 +1,650 @@ +/* + * Copyright 2022 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.ConversationProfilesClient.ListConversationProfilesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +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.ClearSuggestionFeatureConfigOperationMetadata; +import com.google.cloud.dialogflow.v2.ClearSuggestionFeatureConfigRequest; +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.CreateConversationProfileRequest; +import com.google.cloud.dialogflow.v2.DeleteConversationProfileRequest; +import com.google.cloud.dialogflow.v2.GetConversationProfileRequest; +import com.google.cloud.dialogflow.v2.ListConversationProfilesRequest; +import com.google.cloud.dialogflow.v2.ListConversationProfilesResponse; +import com.google.cloud.dialogflow.v2.SetSuggestionFeatureConfigOperationMetadata; +import com.google.cloud.dialogflow.v2.SetSuggestionFeatureConfigRequest; +import com.google.cloud.dialogflow.v2.UpdateConversationProfileRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ConversationProfiles service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonConversationProfilesStub extends ConversationProfilesStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(SetSuggestionFeatureConfigOperationMetadata.getDescriptor()) + .add(ClearSuggestionFeatureConfigOperationMetadata.getDescriptor()) + .add(ConversationProfile.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor< + ListConversationProfilesRequest, ListConversationProfilesResponse> + listConversationProfilesMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationProfiles/ListConversationProfiles") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/conversationProfiles", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*}/conversationProfiles") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListConversationProfilesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getConversationProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationProfiles/GetConversationProfile") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/conversationProfiles/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/conversationProfiles/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ConversationProfile.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createConversationProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationProfiles/CreateConversationProfile") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/conversationProfiles", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*}/conversationProfiles") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("conversationProfile", request.getConversationProfile())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ConversationProfile.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateConversationProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationProfiles/UpdateConversationProfile") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{conversationProfile.name=projects/*/conversationProfiles/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "conversationProfile.name", + request.getConversationProfile().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{conversationProfile.name=projects/*/locations/*/conversationProfiles/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("conversationProfile", request.getConversationProfile())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ConversationProfile.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteConversationProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationProfiles/DeleteConversationProfile") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/conversationProfiles/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/conversationProfiles/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setSuggestionFeatureConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationProfiles/SetSuggestionFeatureConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{conversationProfile=projects/*/conversationProfiles/*}:setSuggestionFeatureConfig", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "conversationProfile", request.getConversationProfile()); + return fields; + }) + .setAdditionalPaths( + "/v2/{conversationProfile=projects/*/locations/*/conversationProfiles/*}:setSuggestionFeatureConfig") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody( + "*", request.toBuilder().clearConversationProfile().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (SetSuggestionFeatureConfigRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + clearSuggestionFeatureConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.ConversationProfiles/ClearSuggestionFeatureConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{conversationProfile=projects/*/conversationProfiles/*}:clearSuggestionFeatureConfig", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "conversationProfile", request.getConversationProfile()); + return fields; + }) + .setAdditionalPaths( + "/v2/{conversationProfile=projects/*/locations/*/conversationProfiles/*}:clearSuggestionFeatureConfig") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody( + "*", request.toBuilder().clearConversationProfile().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ClearSuggestionFeatureConfigRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + listConversationProfilesCallable; + private final UnaryCallable< + ListConversationProfilesRequest, ListConversationProfilesPagedResponse> + listConversationProfilesPagedCallable; + private final UnaryCallable + getConversationProfileCallable; + private final UnaryCallable + createConversationProfileCallable; + private final UnaryCallable + updateConversationProfileCallable; + private final UnaryCallable + deleteConversationProfileCallable; + private final UnaryCallable + setSuggestionFeatureConfigCallable; + private final OperationCallable< + SetSuggestionFeatureConfigRequest, + ConversationProfile, + SetSuggestionFeatureConfigOperationMetadata> + setSuggestionFeatureConfigOperationCallable; + private final UnaryCallable + clearSuggestionFeatureConfigCallable; + private final OperationCallable< + ClearSuggestionFeatureConfigRequest, + ConversationProfile, + ClearSuggestionFeatureConfigOperationMetadata> + clearSuggestionFeatureConfigOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonConversationProfilesStub create( + ConversationProfilesStubSettings settings) throws IOException { + return new HttpJsonConversationProfilesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonConversationProfilesStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonConversationProfilesStub( + ConversationProfilesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonConversationProfilesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonConversationProfilesStub( + ConversationProfilesStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonConversationProfilesStub, 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 HttpJsonConversationProfilesStub( + ConversationProfilesStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonConversationProfilesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonConversationProfilesStub, 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 HttpJsonConversationProfilesStub( + ConversationProfilesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listConversationProfilesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listConversationProfilesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getConversationProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getConversationProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createConversationProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createConversationProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateConversationProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateConversationProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteConversationProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteConversationProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + setSuggestionFeatureConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setSuggestionFeatureConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + clearSuggestionFeatureConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(clearSuggestionFeatureConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listConversationProfilesCallable = + callableFactory.createUnaryCallable( + listConversationProfilesTransportSettings, + settings.listConversationProfilesSettings(), + clientContext); + this.listConversationProfilesPagedCallable = + callableFactory.createPagedCallable( + listConversationProfilesTransportSettings, + settings.listConversationProfilesSettings(), + clientContext); + this.getConversationProfileCallable = + callableFactory.createUnaryCallable( + getConversationProfileTransportSettings, + settings.getConversationProfileSettings(), + clientContext); + this.createConversationProfileCallable = + callableFactory.createUnaryCallable( + createConversationProfileTransportSettings, + settings.createConversationProfileSettings(), + clientContext); + this.updateConversationProfileCallable = + callableFactory.createUnaryCallable( + updateConversationProfileTransportSettings, + settings.updateConversationProfileSettings(), + clientContext); + this.deleteConversationProfileCallable = + callableFactory.createUnaryCallable( + deleteConversationProfileTransportSettings, + settings.deleteConversationProfileSettings(), + clientContext); + this.setSuggestionFeatureConfigCallable = + callableFactory.createUnaryCallable( + setSuggestionFeatureConfigTransportSettings, + settings.setSuggestionFeatureConfigSettings(), + clientContext); + this.setSuggestionFeatureConfigOperationCallable = + callableFactory.createOperationCallable( + setSuggestionFeatureConfigTransportSettings, + settings.setSuggestionFeatureConfigOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.clearSuggestionFeatureConfigCallable = + callableFactory.createUnaryCallable( + clearSuggestionFeatureConfigTransportSettings, + settings.clearSuggestionFeatureConfigSettings(), + clientContext); + this.clearSuggestionFeatureConfigOperationCallable = + callableFactory.createOperationCallable( + clearSuggestionFeatureConfigTransportSettings, + settings.clearSuggestionFeatureConfigOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listConversationProfilesMethodDescriptor); + methodDescriptors.add(getConversationProfileMethodDescriptor); + methodDescriptors.add(createConversationProfileMethodDescriptor); + methodDescriptors.add(updateConversationProfileMethodDescriptor); + methodDescriptors.add(deleteConversationProfileMethodDescriptor); + methodDescriptors.add(setSuggestionFeatureConfigMethodDescriptor); + methodDescriptors.add(clearSuggestionFeatureConfigMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + listConversationProfilesCallable() { + return listConversationProfilesCallable; + } + + @Override + public UnaryCallable + listConversationProfilesPagedCallable() { + return listConversationProfilesPagedCallable; + } + + @Override + public UnaryCallable + getConversationProfileCallable() { + return getConversationProfileCallable; + } + + @Override + public UnaryCallable + createConversationProfileCallable() { + return createConversationProfileCallable; + } + + @Override + public UnaryCallable + updateConversationProfileCallable() { + return updateConversationProfileCallable; + } + + @Override + public UnaryCallable + deleteConversationProfileCallable() { + return deleteConversationProfileCallable; + } + + @Override + public UnaryCallable + setSuggestionFeatureConfigCallable() { + return setSuggestionFeatureConfigCallable; + } + + @Override + public OperationCallable< + SetSuggestionFeatureConfigRequest, + ConversationProfile, + SetSuggestionFeatureConfigOperationMetadata> + setSuggestionFeatureConfigOperationCallable() { + return setSuggestionFeatureConfigOperationCallable; + } + + @Override + public UnaryCallable + clearSuggestionFeatureConfigCallable() { + return clearSuggestionFeatureConfigCallable; + } + + @Override + public OperationCallable< + ClearSuggestionFeatureConfigRequest, + ConversationProfile, + ClearSuggestionFeatureConfigOperationMetadata> + clearSuggestionFeatureConfigOperationCallable() { + return clearSuggestionFeatureConfigOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationsCallableFactory.java new file mode 100644 index 000000000000..5defbb311798 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Conversations service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonConversationsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationsStub.java new file mode 100644 index 000000000000..9cff45304923 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonConversationsStub.java @@ -0,0 +1,448 @@ +/* + * Copyright 2022 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.ConversationsClient.ListConversationsPagedResponse; +import static com.google.cloud.dialogflow.v2.ConversationsClient.ListMessagesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.CompleteConversationRequest; +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.CreateConversationRequest; +import com.google.cloud.dialogflow.v2.GetConversationRequest; +import com.google.cloud.dialogflow.v2.ListConversationsRequest; +import com.google.cloud.dialogflow.v2.ListConversationsResponse; +import com.google.cloud.dialogflow.v2.ListMessagesRequest; +import com.google.cloud.dialogflow.v2.ListMessagesResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Conversations service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonConversationsStub extends ConversationsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createConversationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Conversations/CreateConversation") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/conversations", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/conversations") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "conversationId", request.getConversationId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("conversation", request.getConversation())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Conversation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listConversationsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Conversations/ListConversations") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/conversations", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*}/conversations") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListConversationsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getConversationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Conversations/GetConversation") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/conversations/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/conversations/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Conversation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + completeConversationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Conversations/CompleteConversation") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/conversations/*}:complete", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/conversations/*}:complete") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Conversation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listMessagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Conversations/ListMessages") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/conversations/*}/messages", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/conversations/*}/messages") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListMessagesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createConversationCallable; + private final UnaryCallable + listConversationsCallable; + private final UnaryCallable + listConversationsPagedCallable; + private final UnaryCallable getConversationCallable; + private final UnaryCallable + completeConversationCallable; + private final UnaryCallable listMessagesCallable; + private final UnaryCallable + listMessagesPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonConversationsStub create(ConversationsStubSettings settings) + throws IOException { + return new HttpJsonConversationsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonConversationsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonConversationsStub( + ConversationsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonConversationsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonConversationsStub( + ConversationsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonConversationsStub, 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 HttpJsonConversationsStub( + ConversationsStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonConversationsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonConversationsStub, 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 HttpJsonConversationsStub( + ConversationsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + createConversationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createConversationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listConversationsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listConversationsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getConversationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getConversationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + completeConversationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(completeConversationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listMessagesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listMessagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createConversationCallable = + callableFactory.createUnaryCallable( + createConversationTransportSettings, + settings.createConversationSettings(), + clientContext); + this.listConversationsCallable = + callableFactory.createUnaryCallable( + listConversationsTransportSettings, + settings.listConversationsSettings(), + clientContext); + this.listConversationsPagedCallable = + callableFactory.createPagedCallable( + listConversationsTransportSettings, + settings.listConversationsSettings(), + clientContext); + this.getConversationCallable = + callableFactory.createUnaryCallable( + getConversationTransportSettings, settings.getConversationSettings(), clientContext); + this.completeConversationCallable = + callableFactory.createUnaryCallable( + completeConversationTransportSettings, + settings.completeConversationSettings(), + clientContext); + this.listMessagesCallable = + callableFactory.createUnaryCallable( + listMessagesTransportSettings, settings.listMessagesSettings(), clientContext); + this.listMessagesPagedCallable = + callableFactory.createPagedCallable( + listMessagesTransportSettings, settings.listMessagesSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createConversationMethodDescriptor); + methodDescriptors.add(listConversationsMethodDescriptor); + methodDescriptors.add(getConversationMethodDescriptor); + methodDescriptors.add(completeConversationMethodDescriptor); + methodDescriptors.add(listMessagesMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createConversationCallable() { + return createConversationCallable; + } + + @Override + public UnaryCallable + listConversationsCallable() { + return listConversationsCallable; + } + + @Override + public UnaryCallable + listConversationsPagedCallable() { + return listConversationsPagedCallable; + } + + @Override + public UnaryCallable getConversationCallable() { + return getConversationCallable; + } + + @Override + public UnaryCallable completeConversationCallable() { + return completeConversationCallable; + } + + @Override + public UnaryCallable listMessagesCallable() { + return listMessagesCallable; + } + + @Override + public UnaryCallable listMessagesPagedCallable() { + return listMessagesPagedCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonDocumentsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonDocumentsCallableFactory.java new file mode 100644 index 000000000000..3b4b6f9ddf56 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonDocumentsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Documents service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDocumentsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonDocumentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonDocumentsStub.java new file mode 100644 index 000000000000..6534cf030116 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonDocumentsStub.java @@ -0,0 +1,714 @@ +/* + * Copyright 2022 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.DocumentsClient.ListDocumentsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +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.CreateDocumentRequest; +import com.google.cloud.dialogflow.v2.DeleteDocumentRequest; +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.ExportDocumentRequest; +import com.google.cloud.dialogflow.v2.GetDocumentRequest; +import com.google.cloud.dialogflow.v2.ImportDocumentsRequest; +import com.google.cloud.dialogflow.v2.ImportDocumentsResponse; +import com.google.cloud.dialogflow.v2.KnowledgeOperationMetadata; +import com.google.cloud.dialogflow.v2.ListDocumentsRequest; +import com.google.cloud.dialogflow.v2.ListDocumentsResponse; +import com.google.cloud.dialogflow.v2.ReloadDocumentRequest; +import com.google.cloud.dialogflow.v2.UpdateDocumentRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Documents service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDocumentsStub extends DocumentsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Document.getDescriptor()) + .add(Empty.getDescriptor()) + .add(KnowledgeOperationMetadata.getDescriptor()) + .add(ImportDocumentsResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Documents/ListDocuments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/knowledgeBases/*}/documents", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/knowledgeBases/*}/documents", + "/v2/{parent=projects/*/agent/knowledgeBases/*}/documents") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDocumentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Documents/GetDocument") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/knowledgeBases/*/documents/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/knowledgeBases/*/documents/*}", + "/v2/{name=projects/*/agent/knowledgeBases/*/documents/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Document.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Documents/CreateDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/knowledgeBases/*}/documents", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/knowledgeBases/*}/documents", + "/v2/{parent=projects/*/agent/knowledgeBases/*}/documents") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("document", request.getDocument())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateDocumentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Documents/ImportDocuments") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/knowledgeBases/*}/documents:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/knowledgeBases/*}/documents:import") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportDocumentsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Documents/DeleteDocument") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/knowledgeBases/*/documents/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/knowledgeBases/*/documents/*}", + "/v2/{name=projects/*/agent/knowledgeBases/*/documents/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteDocumentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Documents/UpdateDocument") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{document.name=projects/*/knowledgeBases/*/documents/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "document.name", request.getDocument().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{document.name=projects/*/locations/*/knowledgeBases/*/documents/*}", + "/v2/{document.name=projects/*/agent/knowledgeBases/*/documents/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("document", request.getDocument())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateDocumentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + reloadDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Documents/ReloadDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/knowledgeBases/*/documents/*}:reload", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/knowledgeBases/*/documents/*}:reload", + "/v2/{name=projects/*/agent/knowledgeBases/*/documents/*}:reload") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ReloadDocumentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + exportDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Documents/ExportDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/knowledgeBases/*/documents/*}:export", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/knowledgeBases/*/documents/*}:export") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ExportDocumentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable listDocumentsCallable; + private final UnaryCallable + listDocumentsPagedCallable; + private final UnaryCallable getDocumentCallable; + private final UnaryCallable createDocumentCallable; + private final OperationCallable + createDocumentOperationCallable; + private final UnaryCallable importDocumentsCallable; + private final OperationCallable< + ImportDocumentsRequest, ImportDocumentsResponse, KnowledgeOperationMetadata> + importDocumentsOperationCallable; + private final UnaryCallable deleteDocumentCallable; + private final OperationCallable + deleteDocumentOperationCallable; + private final UnaryCallable updateDocumentCallable; + private final OperationCallable + updateDocumentOperationCallable; + private final UnaryCallable reloadDocumentCallable; + private final OperationCallable + reloadDocumentOperationCallable; + private final UnaryCallable exportDocumentCallable; + private final OperationCallable + exportDocumentOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonDocumentsStub create(DocumentsStubSettings settings) + throws IOException { + return new HttpJsonDocumentsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonDocumentsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonDocumentsStub( + DocumentsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonDocumentsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonDocumentsStub( + DocumentsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonDocumentsStub, 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 HttpJsonDocumentsStub(DocumentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonDocumentsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonDocumentsStub, 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 HttpJsonDocumentsStub( + DocumentsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings reloadDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(reloadDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings exportDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(exportDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listDocumentsCallable = + callableFactory.createUnaryCallable( + listDocumentsTransportSettings, settings.listDocumentsSettings(), clientContext); + this.listDocumentsPagedCallable = + callableFactory.createPagedCallable( + listDocumentsTransportSettings, settings.listDocumentsSettings(), clientContext); + this.getDocumentCallable = + callableFactory.createUnaryCallable( + getDocumentTransportSettings, settings.getDocumentSettings(), clientContext); + this.createDocumentCallable = + callableFactory.createUnaryCallable( + createDocumentTransportSettings, settings.createDocumentSettings(), clientContext); + this.createDocumentOperationCallable = + callableFactory.createOperationCallable( + createDocumentTransportSettings, + settings.createDocumentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importDocumentsCallable = + callableFactory.createUnaryCallable( + importDocumentsTransportSettings, settings.importDocumentsSettings(), clientContext); + this.importDocumentsOperationCallable = + callableFactory.createOperationCallable( + importDocumentsTransportSettings, + settings.importDocumentsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteDocumentCallable = + callableFactory.createUnaryCallable( + deleteDocumentTransportSettings, settings.deleteDocumentSettings(), clientContext); + this.deleteDocumentOperationCallable = + callableFactory.createOperationCallable( + deleteDocumentTransportSettings, + settings.deleteDocumentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateDocumentCallable = + callableFactory.createUnaryCallable( + updateDocumentTransportSettings, settings.updateDocumentSettings(), clientContext); + this.updateDocumentOperationCallable = + callableFactory.createOperationCallable( + updateDocumentTransportSettings, + settings.updateDocumentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.reloadDocumentCallable = + callableFactory.createUnaryCallable( + reloadDocumentTransportSettings, settings.reloadDocumentSettings(), clientContext); + this.reloadDocumentOperationCallable = + callableFactory.createOperationCallable( + reloadDocumentTransportSettings, + settings.reloadDocumentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.exportDocumentCallable = + callableFactory.createUnaryCallable( + exportDocumentTransportSettings, settings.exportDocumentSettings(), clientContext); + this.exportDocumentOperationCallable = + callableFactory.createOperationCallable( + exportDocumentTransportSettings, + settings.exportDocumentOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listDocumentsMethodDescriptor); + methodDescriptors.add(getDocumentMethodDescriptor); + methodDescriptors.add(createDocumentMethodDescriptor); + methodDescriptors.add(importDocumentsMethodDescriptor); + methodDescriptors.add(deleteDocumentMethodDescriptor); + methodDescriptors.add(updateDocumentMethodDescriptor); + methodDescriptors.add(reloadDocumentMethodDescriptor); + methodDescriptors.add(exportDocumentMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listDocumentsCallable() { + return listDocumentsCallable; + } + + @Override + public UnaryCallable + listDocumentsPagedCallable() { + return listDocumentsPagedCallable; + } + + @Override + public UnaryCallable getDocumentCallable() { + return getDocumentCallable; + } + + @Override + public UnaryCallable createDocumentCallable() { + return createDocumentCallable; + } + + @Override + public OperationCallable + createDocumentOperationCallable() { + return createDocumentOperationCallable; + } + + @Override + public UnaryCallable importDocumentsCallable() { + return importDocumentsCallable; + } + + @Override + public OperationCallable< + ImportDocumentsRequest, ImportDocumentsResponse, KnowledgeOperationMetadata> + importDocumentsOperationCallable() { + return importDocumentsOperationCallable; + } + + @Override + public UnaryCallable deleteDocumentCallable() { + return deleteDocumentCallable; + } + + @Override + public OperationCallable + deleteDocumentOperationCallable() { + return deleteDocumentOperationCallable; + } + + @Override + public UnaryCallable updateDocumentCallable() { + return updateDocumentCallable; + } + + @Override + public OperationCallable + updateDocumentOperationCallable() { + return updateDocumentOperationCallable; + } + + @Override + public UnaryCallable reloadDocumentCallable() { + return reloadDocumentCallable; + } + + @Override + public OperationCallable + reloadDocumentOperationCallable() { + return reloadDocumentOperationCallable; + } + + @Override + public UnaryCallable exportDocumentCallable() { + return exportDocumentCallable; + } + + @Override + public OperationCallable + exportDocumentOperationCallable() { + return exportDocumentOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEntityTypesCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEntityTypesCallableFactory.java new file mode 100644 index 000000000000..6b09cdfa614c --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEntityTypesCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the EntityTypes service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonEntityTypesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEntityTypesStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEntityTypesStub.java new file mode 100644 index 000000000000..cdee50053560 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEntityTypesStub.java @@ -0,0 +1,819 @@ +/* + * Copyright 2022 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.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +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.protobuf.Empty; +import com.google.protobuf.Struct; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the EntityTypes service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonEntityTypesStub extends EntityTypesStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(BatchUpdateEntityTypesResponse.getDescriptor()) + .add(Struct.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listEntityTypesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/ListEntityTypes") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent}/entityTypes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*/agent}/entityTypes") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListEntityTypesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/GetEntityType") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/agent/entityTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/agent/entityTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(EntityType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/CreateEntityType") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent}/entityTypes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*/agent}/entityTypes") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("entityType", request.getEntityType())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(EntityType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/UpdateEntityType") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{entityType.name=projects/*/agent/entityTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "entityType.name", request.getEntityType().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{entityType.name=projects/*/locations/*/agent/entityTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("entityType", request.getEntityType())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(EntityType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/DeleteEntityType") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/agent/entityTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/agent/entityTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchUpdateEntityTypesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/BatchUpdateEntityTypes") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent}/entityTypes:batchUpdate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/agent}/entityTypes:batchUpdate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchUpdateEntityTypesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + batchDeleteEntityTypesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/BatchDeleteEntityTypes") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent}/entityTypes:batchDelete", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/agent}/entityTypes:batchDelete") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchDeleteEntityTypesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + batchCreateEntitiesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/BatchCreateEntities") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent/entityTypes/*}/entities:batchCreate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/agent/entityTypes/*}/entities:batchCreate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchCreateEntitiesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + batchUpdateEntitiesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/BatchUpdateEntities") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent/entityTypes/*}/entities:batchUpdate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/agent/entityTypes/*}/entities:batchUpdate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchUpdateEntitiesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + batchDeleteEntitiesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/BatchDeleteEntities") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent/entityTypes/*}/entities:batchDelete", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/agent/entityTypes/*}/entities:batchDelete") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchDeleteEntitiesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + 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 BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonEntityTypesStub create(EntityTypesStubSettings settings) + throws IOException { + return new HttpJsonEntityTypesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonEntityTypesStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonEntityTypesStub( + EntityTypesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonEntityTypesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonEntityTypesStub( + EntityTypesStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonEntityTypesStub, 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 HttpJsonEntityTypesStub(EntityTypesStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonEntityTypesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonEntityTypesStub, 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 HttpJsonEntityTypesStub( + EntityTypesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listEntityTypesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listEntityTypesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchUpdateEntityTypesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchUpdateEntityTypesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchDeleteEntityTypesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchDeleteEntityTypesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchCreateEntitiesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchCreateEntitiesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchUpdateEntitiesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchUpdateEntitiesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchDeleteEntitiesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchDeleteEntitiesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .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, + httpJsonOperationsStub); + this.batchDeleteEntityTypesCallable = + callableFactory.createUnaryCallable( + batchDeleteEntityTypesTransportSettings, + settings.batchDeleteEntityTypesSettings(), + clientContext); + this.batchDeleteEntityTypesOperationCallable = + callableFactory.createOperationCallable( + batchDeleteEntityTypesTransportSettings, + settings.batchDeleteEntityTypesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.batchCreateEntitiesCallable = + callableFactory.createUnaryCallable( + batchCreateEntitiesTransportSettings, + settings.batchCreateEntitiesSettings(), + clientContext); + this.batchCreateEntitiesOperationCallable = + callableFactory.createOperationCallable( + batchCreateEntitiesTransportSettings, + settings.batchCreateEntitiesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.batchUpdateEntitiesCallable = + callableFactory.createUnaryCallable( + batchUpdateEntitiesTransportSettings, + settings.batchUpdateEntitiesSettings(), + clientContext); + this.batchUpdateEntitiesOperationCallable = + callableFactory.createOperationCallable( + batchUpdateEntitiesTransportSettings, + settings.batchUpdateEntitiesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.batchDeleteEntitiesCallable = + callableFactory.createUnaryCallable( + batchDeleteEntitiesTransportSettings, + settings.batchDeleteEntitiesSettings(), + clientContext); + this.batchDeleteEntitiesOperationCallable = + callableFactory.createOperationCallable( + batchDeleteEntitiesTransportSettings, + settings.batchDeleteEntitiesOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listEntityTypesMethodDescriptor); + methodDescriptors.add(getEntityTypeMethodDescriptor); + methodDescriptors.add(createEntityTypeMethodDescriptor); + methodDescriptors.add(updateEntityTypeMethodDescriptor); + methodDescriptors.add(deleteEntityTypeMethodDescriptor); + methodDescriptors.add(batchUpdateEntityTypesMethodDescriptor); + methodDescriptors.add(batchDeleteEntityTypesMethodDescriptor); + methodDescriptors.add(batchCreateEntitiesMethodDescriptor); + methodDescriptors.add(batchUpdateEntitiesMethodDescriptor); + methodDescriptors.add(batchDeleteEntitiesMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listEntityTypesCallable() { + return listEntityTypesCallable; + } + + @Override + public UnaryCallable + listEntityTypesPagedCallable() { + return listEntityTypesPagedCallable; + } + + @Override + public UnaryCallable getEntityTypeCallable() { + return getEntityTypeCallable; + } + + @Override + public UnaryCallable createEntityTypeCallable() { + return createEntityTypeCallable; + } + + @Override + public UnaryCallable updateEntityTypeCallable() { + return updateEntityTypeCallable; + } + + @Override + public UnaryCallable deleteEntityTypeCallable() { + return deleteEntityTypeCallable; + } + + @Override + public UnaryCallable batchUpdateEntityTypesCallable() { + return batchUpdateEntityTypesCallable; + } + + @Override + public OperationCallable + batchUpdateEntityTypesOperationCallable() { + return batchUpdateEntityTypesOperationCallable; + } + + @Override + public UnaryCallable batchDeleteEntityTypesCallable() { + return batchDeleteEntityTypesCallable; + } + + @Override + public OperationCallable + batchDeleteEntityTypesOperationCallable() { + return batchDeleteEntityTypesOperationCallable; + } + + @Override + public UnaryCallable batchCreateEntitiesCallable() { + return batchCreateEntitiesCallable; + } + + @Override + public OperationCallable + batchCreateEntitiesOperationCallable() { + return batchCreateEntitiesOperationCallable; + } + + @Override + public UnaryCallable batchUpdateEntitiesCallable() { + return batchUpdateEntitiesCallable; + } + + @Override + public OperationCallable + batchUpdateEntitiesOperationCallable() { + return batchUpdateEntitiesOperationCallable; + } + + @Override + public UnaryCallable batchDeleteEntitiesCallable() { + return batchDeleteEntitiesCallable; + } + + @Override + public OperationCallable + batchDeleteEntitiesOperationCallable() { + return batchDeleteEntitiesOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEnvironmentsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEnvironmentsCallableFactory.java new file mode 100644 index 000000000000..4f2d8a908a2a --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEnvironmentsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Environments service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonEnvironmentsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEnvironmentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEnvironmentsStub.java new file mode 100644 index 000000000000..764fdacb6bd4 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonEnvironmentsStub.java @@ -0,0 +1,506 @@ +/* + * Copyright 2022 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.EnvironmentsClient.GetEnvironmentHistoryPagedResponse; +import static com.google.cloud.dialogflow.v2.EnvironmentsClient.ListEnvironmentsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.CreateEnvironmentRequest; +import com.google.cloud.dialogflow.v2.DeleteEnvironmentRequest; +import com.google.cloud.dialogflow.v2.Environment; +import com.google.cloud.dialogflow.v2.EnvironmentHistory; +import com.google.cloud.dialogflow.v2.GetEnvironmentHistoryRequest; +import com.google.cloud.dialogflow.v2.GetEnvironmentRequest; +import com.google.cloud.dialogflow.v2.ListEnvironmentsRequest; +import com.google.cloud.dialogflow.v2.ListEnvironmentsResponse; +import com.google.cloud.dialogflow.v2.UpdateEnvironmentRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Environments service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonEnvironmentsStub extends EnvironmentsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listEnvironmentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Environments/ListEnvironments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent}/environments", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*/agent}/environments") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListEnvironmentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Environments/GetEnvironment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/agent/environments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/agent/environments/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Environment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Environments/CreateEnvironment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent}/environments", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*/agent}/environments") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "environmentId", request.getEnvironmentId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("environment", request.getEnvironment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Environment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Environments/UpdateEnvironment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{environment.name=projects/*/agent/environments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "environment.name", request.getEnvironment().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{environment.name=projects/*/locations/*/agent/environments/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, + "allowLoadToDraftAndDiscardChanges", + request.getAllowLoadToDraftAndDiscardChanges()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("environment", request.getEnvironment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Environment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Environments/DeleteEnvironment") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/agent/environments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/agent/environments/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getEnvironmentHistoryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Environments/GetEnvironmentHistory") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent/environments/*}/history", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/agent/environments/*}/history") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(EnvironmentHistory.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + listEnvironmentsCallable; + private final UnaryCallable + listEnvironmentsPagedCallable; + private final UnaryCallable getEnvironmentCallable; + private final UnaryCallable createEnvironmentCallable; + private final UnaryCallable updateEnvironmentCallable; + private final UnaryCallable deleteEnvironmentCallable; + private final UnaryCallable + getEnvironmentHistoryCallable; + private final UnaryCallable + getEnvironmentHistoryPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonEnvironmentsStub create(EnvironmentsStubSettings settings) + throws IOException { + return new HttpJsonEnvironmentsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonEnvironmentsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonEnvironmentsStub( + EnvironmentsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonEnvironmentsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonEnvironmentsStub( + EnvironmentsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonEnvironmentsStub, 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 HttpJsonEnvironmentsStub(EnvironmentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonEnvironmentsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonEnvironmentsStub, 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 HttpJsonEnvironmentsStub( + EnvironmentsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listEnvironmentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listEnvironmentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getEnvironmentHistoryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getEnvironmentHistoryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listEnvironmentsCallable = + callableFactory.createUnaryCallable( + listEnvironmentsTransportSettings, settings.listEnvironmentsSettings(), clientContext); + this.listEnvironmentsPagedCallable = + callableFactory.createPagedCallable( + listEnvironmentsTransportSettings, settings.listEnvironmentsSettings(), clientContext); + this.getEnvironmentCallable = + callableFactory.createUnaryCallable( + getEnvironmentTransportSettings, settings.getEnvironmentSettings(), clientContext); + this.createEnvironmentCallable = + callableFactory.createUnaryCallable( + createEnvironmentTransportSettings, + settings.createEnvironmentSettings(), + clientContext); + this.updateEnvironmentCallable = + callableFactory.createUnaryCallable( + updateEnvironmentTransportSettings, + settings.updateEnvironmentSettings(), + clientContext); + this.deleteEnvironmentCallable = + callableFactory.createUnaryCallable( + deleteEnvironmentTransportSettings, + settings.deleteEnvironmentSettings(), + clientContext); + this.getEnvironmentHistoryCallable = + callableFactory.createUnaryCallable( + getEnvironmentHistoryTransportSettings, + settings.getEnvironmentHistorySettings(), + clientContext); + this.getEnvironmentHistoryPagedCallable = + callableFactory.createPagedCallable( + getEnvironmentHistoryTransportSettings, + settings.getEnvironmentHistorySettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listEnvironmentsMethodDescriptor); + methodDescriptors.add(getEnvironmentMethodDescriptor); + methodDescriptors.add(createEnvironmentMethodDescriptor); + methodDescriptors.add(updateEnvironmentMethodDescriptor); + methodDescriptors.add(deleteEnvironmentMethodDescriptor); + methodDescriptors.add(getEnvironmentHistoryMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + listEnvironmentsCallable() { + return listEnvironmentsCallable; + } + + @Override + public UnaryCallable + listEnvironmentsPagedCallable() { + return listEnvironmentsPagedCallable; + } + + @Override + public UnaryCallable getEnvironmentCallable() { + return getEnvironmentCallable; + } + + @Override + public UnaryCallable createEnvironmentCallable() { + return createEnvironmentCallable; + } + + @Override + public UnaryCallable updateEnvironmentCallable() { + return updateEnvironmentCallable; + } + + @Override + public UnaryCallable deleteEnvironmentCallable() { + return deleteEnvironmentCallable; + } + + @Override + public UnaryCallable + getEnvironmentHistoryCallable() { + return getEnvironmentHistoryCallable; + } + + @Override + public UnaryCallable + getEnvironmentHistoryPagedCallable() { + return getEnvironmentHistoryPagedCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonFulfillmentsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonFulfillmentsCallableFactory.java new file mode 100644 index 000000000000..d2bb85c6fb59 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonFulfillmentsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Fulfillments service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonFulfillmentsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonFulfillmentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonFulfillmentsStub.java new file mode 100644 index 000000000000..550965224b74 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonFulfillmentsStub.java @@ -0,0 +1,250 @@ +/* + * Copyright 2022 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.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.Fulfillment; +import com.google.cloud.dialogflow.v2.GetFulfillmentRequest; +import com.google.cloud.dialogflow.v2.UpdateFulfillmentRequest; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Fulfillments service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonFulfillmentsStub extends FulfillmentsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + getFulfillmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Fulfillments/GetFulfillment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/agent/fulfillment}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/agent/fulfillment}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Fulfillment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateFulfillmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Fulfillments/UpdateFulfillment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{fulfillment.name=projects/*/agent/fulfillment}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "fulfillment.name", request.getFulfillment().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{fulfillment.name=projects/*/locations/*/agent/fulfillment}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("fulfillment", request.getFulfillment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Fulfillment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable getFulfillmentCallable; + private final UnaryCallable updateFulfillmentCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonFulfillmentsStub create(FulfillmentsStubSettings settings) + throws IOException { + return new HttpJsonFulfillmentsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonFulfillmentsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonFulfillmentsStub( + FulfillmentsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonFulfillmentsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonFulfillmentsStub( + FulfillmentsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonFulfillmentsStub, 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 HttpJsonFulfillmentsStub(FulfillmentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonFulfillmentsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonFulfillmentsStub, 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 HttpJsonFulfillmentsStub( + FulfillmentsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings getFulfillmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getFulfillmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateFulfillmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateFulfillmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.getFulfillmentCallable = + callableFactory.createUnaryCallable( + getFulfillmentTransportSettings, settings.getFulfillmentSettings(), clientContext); + this.updateFulfillmentCallable = + callableFactory.createUnaryCallable( + updateFulfillmentTransportSettings, + settings.updateFulfillmentSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(getFulfillmentMethodDescriptor); + methodDescriptors.add(updateFulfillmentMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable getFulfillmentCallable() { + return getFulfillmentCallable; + } + + @Override + public UnaryCallable updateFulfillmentCallable() { + return updateFulfillmentCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonIntentsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonIntentsCallableFactory.java new file mode 100644 index 000000000000..af09f42f1e2b --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonIntentsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Intents service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonIntentsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonIntentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonIntentsStub.java new file mode 100644 index 000000000000..2da88cd7397b --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonIntentsStub.java @@ -0,0 +1,589 @@ +/* + * Copyright 2022 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.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +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.protobuf.Empty; +import com.google.protobuf.Struct; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Intents service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonIntentsStub extends IntentsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(BatchUpdateIntentsResponse.getDescriptor()) + .add(Struct.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listIntentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Intents/ListIntents") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent}/intents", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/agent}/intents", + "/v2/{parent=projects/*/agent/environments/*}/intents", + "/v2/{parent=projects/*/locations/*/agent/environments/*}/intents") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "intentView", request.getIntentView()); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListIntentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getIntentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Intents/GetIntent") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/agent/intents/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/agent/intents/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "intentView", request.getIntentView()); + serializer.putQueryParam(fields, "languageCode", request.getLanguageCode()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Intent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createIntentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Intents/CreateIntent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent}/intents", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*/agent}/intents") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "intentView", request.getIntentView()); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("intent", request.getIntent())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Intent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateIntentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Intents/UpdateIntent") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{intent.name=projects/*/agent/intents/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "intent.name", request.getIntent().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{intent.name=projects/*/locations/*/agent/intents/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "intentView", request.getIntentView()); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("intent", request.getIntent())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Intent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteIntentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Intents/DeleteIntent") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/agent/intents/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/agent/intents/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchUpdateIntentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Intents/BatchUpdateIntents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent}/intents:batchUpdate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/agent}/intents:batchUpdate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchUpdateIntentsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + batchDeleteIntentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Intents/BatchDeleteIntents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent}/intents:batchDelete", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/agent}/intents:batchDelete") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchDeleteIntentsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + 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 BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonIntentsStub create(IntentsStubSettings settings) throws IOException { + return new HttpJsonIntentsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonIntentsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonIntentsStub(IntentsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonIntentsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonIntentsStub( + IntentsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonIntentsStub, 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 HttpJsonIntentsStub(IntentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonIntentsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonIntentsStub, 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 HttpJsonIntentsStub( + IntentsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings listIntentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listIntentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIntentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIntentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createIntentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createIntentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateIntentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateIntentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteIntentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteIntentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings batchUpdateIntentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchUpdateIntentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings batchDeleteIntentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchDeleteIntentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .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, + httpJsonOperationsStub); + this.batchDeleteIntentsCallable = + callableFactory.createUnaryCallable( + batchDeleteIntentsTransportSettings, + settings.batchDeleteIntentsSettings(), + clientContext); + this.batchDeleteIntentsOperationCallable = + callableFactory.createOperationCallable( + batchDeleteIntentsTransportSettings, + settings.batchDeleteIntentsOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listIntentsMethodDescriptor); + methodDescriptors.add(getIntentMethodDescriptor); + methodDescriptors.add(createIntentMethodDescriptor); + methodDescriptors.add(updateIntentMethodDescriptor); + methodDescriptors.add(deleteIntentMethodDescriptor); + methodDescriptors.add(batchUpdateIntentsMethodDescriptor); + methodDescriptors.add(batchDeleteIntentsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listIntentsCallable() { + return listIntentsCallable; + } + + @Override + public UnaryCallable listIntentsPagedCallable() { + return listIntentsPagedCallable; + } + + @Override + public UnaryCallable getIntentCallable() { + return getIntentCallable; + } + + @Override + public UnaryCallable createIntentCallable() { + return createIntentCallable; + } + + @Override + public UnaryCallable updateIntentCallable() { + return updateIntentCallable; + } + + @Override + public UnaryCallable deleteIntentCallable() { + return deleteIntentCallable; + } + + @Override + public UnaryCallable batchUpdateIntentsCallable() { + return batchUpdateIntentsCallable; + } + + @Override + public OperationCallable + batchUpdateIntentsOperationCallable() { + return batchUpdateIntentsOperationCallable; + } + + @Override + public UnaryCallable batchDeleteIntentsCallable() { + return batchDeleteIntentsCallable; + } + + @Override + public OperationCallable + batchDeleteIntentsOperationCallable() { + return batchDeleteIntentsOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonKnowledgeBasesCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonKnowledgeBasesCallableFactory.java new file mode 100644 index 000000000000..945398ff4c18 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonKnowledgeBasesCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the KnowledgeBases service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonKnowledgeBasesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonKnowledgeBasesStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonKnowledgeBasesStub.java new file mode 100644 index 000000000000..82c532b67b2a --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonKnowledgeBasesStub.java @@ -0,0 +1,446 @@ +/* + * Copyright 2022 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.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.CreateKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2.DeleteKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2.GetKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.ListKnowledgeBasesRequest; +import com.google.cloud.dialogflow.v2.ListKnowledgeBasesResponse; +import com.google.cloud.dialogflow.v2.UpdateKnowledgeBaseRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the KnowledgeBases service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonKnowledgeBasesStub extends KnowledgeBasesStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listKnowledgeBasesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.KnowledgeBases/ListKnowledgeBases") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/knowledgeBases", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*}/knowledgeBases", + "/v2/{parent=projects/*/agent}/knowledgeBases") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListKnowledgeBasesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getKnowledgeBaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.KnowledgeBases/GetKnowledgeBase") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/knowledgeBases/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/knowledgeBases/*}", + "/v2/{name=projects/*/agent/knowledgeBases/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(KnowledgeBase.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createKnowledgeBaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.KnowledgeBases/CreateKnowledgeBase") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/knowledgeBases", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*}/knowledgeBases", + "/v2/{parent=projects/*/agent}/knowledgeBases") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("knowledgeBase", request.getKnowledgeBase())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(KnowledgeBase.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteKnowledgeBaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.KnowledgeBases/DeleteKnowledgeBase") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/knowledgeBases/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/knowledgeBases/*}", + "/v2/{name=projects/*/agent/knowledgeBases/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "force", request.getForce()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateKnowledgeBaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.KnowledgeBases/UpdateKnowledgeBase") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{knowledgeBase.name=projects/*/knowledgeBases/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "knowledgeBase.name", request.getKnowledgeBase().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{knowledgeBase.name=projects/*/locations/*/knowledgeBases/*}", + "/v2/{knowledgeBase.name=projects/*/agent/knowledgeBases/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("knowledgeBase", request.getKnowledgeBase())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(KnowledgeBase.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + listKnowledgeBasesCallable; + private final UnaryCallable + listKnowledgeBasesPagedCallable; + private final UnaryCallable getKnowledgeBaseCallable; + private final UnaryCallable + createKnowledgeBaseCallable; + private final UnaryCallable deleteKnowledgeBaseCallable; + private final UnaryCallable + updateKnowledgeBaseCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonKnowledgeBasesStub create(KnowledgeBasesStubSettings settings) + throws IOException { + return new HttpJsonKnowledgeBasesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonKnowledgeBasesStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonKnowledgeBasesStub( + KnowledgeBasesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonKnowledgeBasesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonKnowledgeBasesStub( + KnowledgeBasesStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonKnowledgeBasesStub, 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 HttpJsonKnowledgeBasesStub( + KnowledgeBasesStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonKnowledgeBasesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonKnowledgeBasesStub, 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 HttpJsonKnowledgeBasesStub( + KnowledgeBasesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listKnowledgeBasesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listKnowledgeBasesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getKnowledgeBaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getKnowledgeBaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createKnowledgeBaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createKnowledgeBaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteKnowledgeBaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteKnowledgeBaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateKnowledgeBaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateKnowledgeBaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listKnowledgeBasesCallable = + callableFactory.createUnaryCallable( + listKnowledgeBasesTransportSettings, + settings.listKnowledgeBasesSettings(), + clientContext); + this.listKnowledgeBasesPagedCallable = + callableFactory.createPagedCallable( + listKnowledgeBasesTransportSettings, + settings.listKnowledgeBasesSettings(), + clientContext); + this.getKnowledgeBaseCallable = + callableFactory.createUnaryCallable( + getKnowledgeBaseTransportSettings, settings.getKnowledgeBaseSettings(), clientContext); + this.createKnowledgeBaseCallable = + callableFactory.createUnaryCallable( + createKnowledgeBaseTransportSettings, + settings.createKnowledgeBaseSettings(), + clientContext); + this.deleteKnowledgeBaseCallable = + callableFactory.createUnaryCallable( + deleteKnowledgeBaseTransportSettings, + settings.deleteKnowledgeBaseSettings(), + clientContext); + this.updateKnowledgeBaseCallable = + callableFactory.createUnaryCallable( + updateKnowledgeBaseTransportSettings, + settings.updateKnowledgeBaseSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listKnowledgeBasesMethodDescriptor); + methodDescriptors.add(getKnowledgeBaseMethodDescriptor); + methodDescriptors.add(createKnowledgeBaseMethodDescriptor); + methodDescriptors.add(deleteKnowledgeBaseMethodDescriptor); + methodDescriptors.add(updateKnowledgeBaseMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + listKnowledgeBasesCallable() { + return listKnowledgeBasesCallable; + } + + @Override + public UnaryCallable + listKnowledgeBasesPagedCallable() { + return listKnowledgeBasesPagedCallable; + } + + @Override + public UnaryCallable getKnowledgeBaseCallable() { + return getKnowledgeBaseCallable; + } + + @Override + public UnaryCallable createKnowledgeBaseCallable() { + return createKnowledgeBaseCallable; + } + + @Override + public UnaryCallable deleteKnowledgeBaseCallable() { + return deleteKnowledgeBaseCallable; + } + + @Override + public UnaryCallable updateKnowledgeBaseCallable() { + return updateKnowledgeBaseCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonParticipantsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonParticipantsCallableFactory.java new file mode 100644 index 000000000000..e3c5e54ba8e6 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonParticipantsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Participants service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonParticipantsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonParticipantsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonParticipantsStub.java new file mode 100644 index 000000000000..ff812ad3aace --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonParticipantsStub.java @@ -0,0 +1,612 @@ +/* + * Copyright 2022 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.ParticipantsClient.ListParticipantsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.AnalyzeContentRequest; +import com.google.cloud.dialogflow.v2.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2.CreateParticipantRequest; +import com.google.cloud.dialogflow.v2.GetParticipantRequest; +import com.google.cloud.dialogflow.v2.ListParticipantsRequest; +import com.google.cloud.dialogflow.v2.ListParticipantsResponse; +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.SuggestArticlesRequest; +import com.google.cloud.dialogflow.v2.SuggestArticlesResponse; +import com.google.cloud.dialogflow.v2.SuggestFaqAnswersRequest; +import com.google.cloud.dialogflow.v2.SuggestFaqAnswersResponse; +import com.google.cloud.dialogflow.v2.SuggestSmartRepliesRequest; +import com.google.cloud.dialogflow.v2.SuggestSmartRepliesResponse; +import com.google.cloud.dialogflow.v2.UpdateParticipantRequest; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Participants service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonParticipantsStub extends ParticipantsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createParticipantMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Participants/CreateParticipant") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/conversations/*}/participants", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/conversations/*}/participants") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("participant", request.getParticipant())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Participant.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getParticipantMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Participants/GetParticipant") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/conversations/*/participants/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/locations/*/conversations/*/participants/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Participant.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listParticipantsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Participants/ListParticipants") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/conversations/*}/participants", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/conversations/*}/participants") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListParticipantsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateParticipantMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Participants/UpdateParticipant") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{participant.name=projects/*/conversations/*/participants/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "participant.name", request.getParticipant().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{participant.name=projects/*/locations/*/conversations/*/participants/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("participant", request.getParticipant())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Participant.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + analyzeContentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Participants/AnalyzeContent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{participant=projects/*/conversations/*/participants/*}:analyzeContent", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "participant", request.getParticipant()); + return fields; + }) + .setAdditionalPaths( + "/v2/{participant=projects/*/locations/*/conversations/*/participants/*}:analyzeContent") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParticipant().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AnalyzeContentResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + suggestArticlesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Participants/SuggestArticles") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/conversations/*/participants/*}/suggestions:suggestArticles", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/conversations/*/participants/*}/suggestions:suggestArticles") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SuggestArticlesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + suggestFaqAnswersMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Participants/SuggestFaqAnswers") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/conversations/*/participants/*}/suggestions:suggestFaqAnswers", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/conversations/*/participants/*}/suggestions:suggestFaqAnswers") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SuggestFaqAnswersResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + suggestSmartRepliesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Participants/SuggestSmartReplies") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/conversations/*/participants/*}/suggestions:suggestSmartReplies", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/locations/*/conversations/*/participants/*}/suggestions:suggestSmartReplies") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SuggestSmartRepliesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createParticipantCallable; + private final UnaryCallable getParticipantCallable; + private final UnaryCallable + listParticipantsCallable; + private final UnaryCallable + listParticipantsPagedCallable; + private final UnaryCallable updateParticipantCallable; + private final UnaryCallable analyzeContentCallable; + private final UnaryCallable + suggestArticlesCallable; + private final UnaryCallable + suggestFaqAnswersCallable; + private final UnaryCallable + suggestSmartRepliesCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonParticipantsStub create(ParticipantsStubSettings settings) + throws IOException { + return new HttpJsonParticipantsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonParticipantsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonParticipantsStub( + ParticipantsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonParticipantsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonParticipantsStub( + ParticipantsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonParticipantsStub, 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 HttpJsonParticipantsStub(ParticipantsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonParticipantsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonParticipantsStub, 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 HttpJsonParticipantsStub( + ParticipantsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createParticipantTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createParticipantMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getParticipantTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getParticipantMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listParticipantsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listParticipantsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateParticipantTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateParticipantMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + analyzeContentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(analyzeContentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + suggestArticlesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(suggestArticlesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + suggestFaqAnswersTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(suggestFaqAnswersMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + suggestSmartRepliesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(suggestSmartRepliesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createParticipantCallable = + callableFactory.createUnaryCallable( + createParticipantTransportSettings, + settings.createParticipantSettings(), + clientContext); + this.getParticipantCallable = + callableFactory.createUnaryCallable( + getParticipantTransportSettings, settings.getParticipantSettings(), clientContext); + this.listParticipantsCallable = + callableFactory.createUnaryCallable( + listParticipantsTransportSettings, settings.listParticipantsSettings(), clientContext); + this.listParticipantsPagedCallable = + callableFactory.createPagedCallable( + listParticipantsTransportSettings, settings.listParticipantsSettings(), clientContext); + this.updateParticipantCallable = + callableFactory.createUnaryCallable( + updateParticipantTransportSettings, + settings.updateParticipantSettings(), + clientContext); + this.analyzeContentCallable = + callableFactory.createUnaryCallable( + analyzeContentTransportSettings, settings.analyzeContentSettings(), clientContext); + this.suggestArticlesCallable = + callableFactory.createUnaryCallable( + suggestArticlesTransportSettings, settings.suggestArticlesSettings(), clientContext); + this.suggestFaqAnswersCallable = + callableFactory.createUnaryCallable( + suggestFaqAnswersTransportSettings, + settings.suggestFaqAnswersSettings(), + clientContext); + this.suggestSmartRepliesCallable = + callableFactory.createUnaryCallable( + suggestSmartRepliesTransportSettings, + settings.suggestSmartRepliesSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createParticipantMethodDescriptor); + methodDescriptors.add(getParticipantMethodDescriptor); + methodDescriptors.add(listParticipantsMethodDescriptor); + methodDescriptors.add(updateParticipantMethodDescriptor); + methodDescriptors.add(analyzeContentMethodDescriptor); + methodDescriptors.add(suggestArticlesMethodDescriptor); + methodDescriptors.add(suggestFaqAnswersMethodDescriptor); + methodDescriptors.add(suggestSmartRepliesMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createParticipantCallable() { + return createParticipantCallable; + } + + @Override + public UnaryCallable getParticipantCallable() { + return getParticipantCallable; + } + + @Override + public UnaryCallable + listParticipantsCallable() { + return listParticipantsCallable; + } + + @Override + public UnaryCallable + listParticipantsPagedCallable() { + return listParticipantsPagedCallable; + } + + @Override + public UnaryCallable updateParticipantCallable() { + return updateParticipantCallable; + } + + @Override + public UnaryCallable analyzeContentCallable() { + return analyzeContentCallable; + } + + @Override + public UnaryCallable suggestArticlesCallable() { + return suggestArticlesCallable; + } + + @Override + public UnaryCallable + suggestFaqAnswersCallable() { + return suggestFaqAnswersCallable; + } + + @Override + public UnaryCallable + suggestSmartRepliesCallable() { + return suggestSmartRepliesCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionEntityTypesCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionEntityTypesCallableFactory.java new file mode 100644 index 000000000000..7719d40db526 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionEntityTypesCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the SessionEntityTypes service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSessionEntityTypesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionEntityTypesStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionEntityTypesStub.java new file mode 100644 index 000000000000..fd5fbf306b94 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionEntityTypesStub.java @@ -0,0 +1,470 @@ +/* + * Copyright 2022 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.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +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 com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the SessionEntityTypes service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSessionEntityTypesStub extends SessionEntityTypesStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse> + listSessionEntityTypesMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.SessionEntityTypes/ListSessionEntityTypes") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent/sessions/*}/entityTypes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/agent/environments/*/users/*/sessions/*}/entityTypes", + "/v2/{parent=projects/*/locations/*/agent/sessions/*}/entityTypes", + "/v2/{parent=projects/*/locations/*/agent/environments/*/users/*/sessions/*}/entityTypes") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListSessionEntityTypesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getSessionEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.SessionEntityTypes/GetSessionEntityType") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/agent/sessions/*/entityTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/agent/environments/*/users/*/sessions/*/entityTypes/*}", + "/v2/{name=projects/*/locations/*/agent/sessions/*/entityTypes/*}", + "/v2/{name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/entityTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SessionEntityType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createSessionEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.SessionEntityTypes/CreateSessionEntityType") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent/sessions/*}/entityTypes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2/{parent=projects/*/agent/environments/*/users/*/sessions/*}/entityTypes", + "/v2/{parent=projects/*/locations/*/agent/sessions/*}/entityTypes", + "/v2/{parent=projects/*/locations/*/agent/environments/*/users/*/sessions/*}/entityTypes") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("sessionEntityType", request.getSessionEntityType())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SessionEntityType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateSessionEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.SessionEntityTypes/UpdateSessionEntityType") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{sessionEntityType.name=projects/*/agent/sessions/*/entityTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "sessionEntityType.name", + request.getSessionEntityType().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{sessionEntityType.name=projects/*/agent/environments/*/users/*/sessions/*/entityTypes/*}", + "/v2/{sessionEntityType.name=projects/*/locations/*/agent/sessions/*/entityTypes/*}", + "/v2/{sessionEntityType.name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/entityTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("sessionEntityType", request.getSessionEntityType())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SessionEntityType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteSessionEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2.SessionEntityTypes/DeleteSessionEntityType") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/agent/sessions/*/entityTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{name=projects/*/agent/environments/*/users/*/sessions/*/entityTypes/*}", + "/v2/{name=projects/*/locations/*/agent/sessions/*/entityTypes/*}", + "/v2/{name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/entityTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + 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 BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSessionEntityTypesStub create(SessionEntityTypesStubSettings settings) + throws IOException { + return new HttpJsonSessionEntityTypesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSessionEntityTypesStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSessionEntityTypesStub( + SessionEntityTypesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSessionEntityTypesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSessionEntityTypesStub( + SessionEntityTypesStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonSessionEntityTypesStub, 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 HttpJsonSessionEntityTypesStub( + SessionEntityTypesStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonSessionEntityTypesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSessionEntityTypesStub, 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 HttpJsonSessionEntityTypesStub( + SessionEntityTypesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listSessionEntityTypesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listSessionEntityTypesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getSessionEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getSessionEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createSessionEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createSessionEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateSessionEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateSessionEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteSessionEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteSessionEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .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); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listSessionEntityTypesMethodDescriptor); + methodDescriptors.add(getSessionEntityTypeMethodDescriptor); + methodDescriptors.add(createSessionEntityTypeMethodDescriptor); + methodDescriptors.add(updateSessionEntityTypeMethodDescriptor); + methodDescriptors.add(deleteSessionEntityTypeMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + listSessionEntityTypesCallable() { + return listSessionEntityTypesCallable; + } + + @Override + public UnaryCallable + listSessionEntityTypesPagedCallable() { + return listSessionEntityTypesPagedCallable; + } + + @Override + public UnaryCallable + getSessionEntityTypeCallable() { + return getSessionEntityTypeCallable; + } + + @Override + public UnaryCallable + createSessionEntityTypeCallable() { + return createSessionEntityTypeCallable; + } + + @Override + public UnaryCallable + updateSessionEntityTypeCallable() { + return updateSessionEntityTypeCallable; + } + + @Override + public UnaryCallable deleteSessionEntityTypeCallable() { + return deleteSessionEntityTypeCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionsCallableFactory.java new file mode 100644 index 000000000000..ba060616b7d1 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Sessions service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSessionsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionsStub.java new file mode 100644 index 000000000000..b6b09aaae602 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonSessionsStub.java @@ -0,0 +1,197 @@ +/* + * Copyright 2022 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.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +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.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Sessions service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSessionsStub extends SessionsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + detectIntentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Sessions/DetectIntent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{session=projects/*/agent/sessions/*}:detectIntent", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "session", request.getSession()); + return fields; + }) + .setAdditionalPaths( + "/v2/{session=projects/*/agent/environments/*/users/*/sessions/*}:detectIntent", + "/v2/{session=projects/*/locations/*/agent/sessions/*}:detectIntent", + "/v2/{session=projects/*/locations/*/agent/environments/*/users/*/sessions/*}:detectIntent") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearSession().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DetectIntentResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable detectIntentCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSessionsStub create(SessionsStubSettings settings) + throws IOException { + return new HttpJsonSessionsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSessionsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonSessionsStub( + SessionsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSessionsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSessionsStub( + SessionsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSessionsStub, 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 HttpJsonSessionsStub(SessionsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonSessionsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSessionsStub, 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 HttpJsonSessionsStub( + SessionsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings detectIntentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(detectIntentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.detectIntentCallable = + callableFactory.createUnaryCallable( + detectIntentTransportSettings, settings.detectIntentSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(detectIntentMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable detectIntentCallable() { + return detectIntentCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonVersionsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonVersionsCallableFactory.java new file mode 100644 index 000000000000..0e9d27190261 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonVersionsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Versions service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonVersionsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonVersionsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonVersionsStub.java new file mode 100644 index 000000000000..0ce073fa16c0 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/HttpJsonVersionsStub.java @@ -0,0 +1,413 @@ +/* + * Copyright 2022 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.VersionsClient.ListVersionsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.CreateVersionRequest; +import com.google.cloud.dialogflow.v2.DeleteVersionRequest; +import com.google.cloud.dialogflow.v2.GetVersionRequest; +import com.google.cloud.dialogflow.v2.ListVersionsRequest; +import com.google.cloud.dialogflow.v2.ListVersionsResponse; +import com.google.cloud.dialogflow.v2.UpdateVersionRequest; +import com.google.cloud.dialogflow.v2.Version; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Versions service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonVersionsStub extends VersionsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listVersionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Versions/ListVersions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent}/versions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*/agent}/versions") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListVersionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getVersionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Versions/GetVersion") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/agent/versions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/agent/versions/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Version.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createVersionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Versions/CreateVersion") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*/agent}/versions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2/{parent=projects/*/locations/*/agent}/versions") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("version", request.getVersion())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Version.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateVersionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Versions/UpdateVersion") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{version.name=projects/*/agent/versions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "version.name", request.getVersion().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2/{version.name=projects/*/locations/*/agent/versions/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("version", request.getVersion())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Version.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteVersionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2.Versions/DeleteVersion") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=projects/*/agent/versions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2/{name=projects/*/locations/*/agent/versions/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listVersionsCallable; + private final UnaryCallable + listVersionsPagedCallable; + private final UnaryCallable getVersionCallable; + private final UnaryCallable createVersionCallable; + private final UnaryCallable updateVersionCallable; + private final UnaryCallable deleteVersionCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonVersionsStub create(VersionsStubSettings settings) + throws IOException { + return new HttpJsonVersionsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonVersionsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonVersionsStub( + VersionsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonVersionsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonVersionsStub( + VersionsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonVersionsStub, 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 HttpJsonVersionsStub(VersionsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonVersionsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonVersionsStub, 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 HttpJsonVersionsStub( + VersionsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listVersionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listVersionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getVersionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getVersionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createVersionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createVersionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateVersionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateVersionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteVersionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteVersionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listVersionsCallable = + callableFactory.createUnaryCallable( + listVersionsTransportSettings, settings.listVersionsSettings(), clientContext); + this.listVersionsPagedCallable = + callableFactory.createPagedCallable( + listVersionsTransportSettings, settings.listVersionsSettings(), clientContext); + this.getVersionCallable = + callableFactory.createUnaryCallable( + getVersionTransportSettings, settings.getVersionSettings(), clientContext); + this.createVersionCallable = + callableFactory.createUnaryCallable( + createVersionTransportSettings, settings.createVersionSettings(), clientContext); + this.updateVersionCallable = + callableFactory.createUnaryCallable( + updateVersionTransportSettings, settings.updateVersionSettings(), clientContext); + this.deleteVersionCallable = + callableFactory.createUnaryCallable( + deleteVersionTransportSettings, settings.deleteVersionSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listVersionsMethodDescriptor); + methodDescriptors.add(getVersionMethodDescriptor); + methodDescriptors.add(createVersionMethodDescriptor); + methodDescriptors.add(updateVersionMethodDescriptor); + methodDescriptors.add(deleteVersionMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listVersionsCallable() { + return listVersionsCallable; + } + + @Override + public UnaryCallable listVersionsPagedCallable() { + return listVersionsPagedCallable; + } + + @Override + public UnaryCallable getVersionCallable() { + return getVersionCallable; + } + + @Override + public UnaryCallable createVersionCallable() { + return createVersionCallable; + } + + @Override + public UnaryCallable updateVersionCallable() { + return updateVersionCallable; + } + + @Override + public UnaryCallable deleteVersionCallable() { + return deleteVersionCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStub.java index 8a4d50a5b6a1..61447342c80a 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStub.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStub.java @@ -47,7 +47,11 @@ public abstract class IntentsStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable listIntentsPagedCallable() { diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStubSettings.java index 41752a49b78f..f057441aa439 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -228,6 +231,11 @@ public IntentsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcIntentsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonIntentsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -260,29 +268,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(IntentsStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(IntentsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return IntentsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -427,6 +460,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listIntentsSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/KnowledgeBasesStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/KnowledgeBasesStubSettings.java index 70c5931ee033..226f07cf3320 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/KnowledgeBasesStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/KnowledgeBasesStubSettings.java @@ -27,6 +27,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -206,6 +209,11 @@ public KnowledgeBasesStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcKnowledgeBasesStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonKnowledgeBasesStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -238,18 +246,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(KnowledgeBasesStubSettings.class)) @@ -257,11 +272,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(KnowledgeBasesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return KnowledgeBasesStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -381,6 +415,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listKnowledgeBasesSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ParticipantsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ParticipantsStubSettings.java index ed0cadaf9600..cf1f79ed5e48 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ParticipantsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ParticipantsStubSettings.java @@ -27,6 +27,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -231,6 +234,11 @@ public ParticipantsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcParticipantsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonParticipantsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -263,18 +271,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ParticipantsStubSettings.class)) @@ -282,11 +297,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ParticipantsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ParticipantsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -441,6 +475,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createParticipantSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionEntityTypesStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionEntityTypesStubSettings.java index 1c296b7ce386..4cd8600fccba 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionEntityTypesStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionEntityTypesStubSettings.java @@ -27,6 +27,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -224,6 +227,11 @@ public SessionEntityTypesStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSessionEntityTypesStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSessionEntityTypesStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -256,18 +264,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(SessionEntityTypesStubSettings.class)) @@ -275,11 +290,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(SessionEntityTypesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SessionEntityTypesStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -403,6 +437,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listSessionEntityTypesSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionsStubSettings.java index 415e1782cb7b..d343f80c48f0 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionsStubSettings.java @@ -24,6 +24,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -108,6 +111,11 @@ public SessionsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSessionsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSessionsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -140,29 +148,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(SessionsStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(SessionsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SessionsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -267,6 +300,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .detectIntentSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/VersionsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/VersionsStubSettings.java index 369158d526e4..e5bbb7cfd41c 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/VersionsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/VersionsStubSettings.java @@ -27,6 +27,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -192,6 +195,11 @@ public VersionsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcVersionsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonVersionsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -224,29 +232,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(VersionsStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(VersionsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return VersionsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -362,6 +395,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listVersionsSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsClient.java index 1c685e3cc741..d0515067715e 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.dialogflow.v2beta1.stub.AgentsStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.Struct; import java.io.IOException; @@ -102,6 +102,20 @@ * AgentsClient agentsClient = AgentsClient.create(agentsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * AgentsSettings agentsSettings =
+ *     AgentsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             AgentsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * AgentsClient agentsClient = AgentsClient.create(agentsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -109,7 +123,8 @@ public class AgentsClient implements BackgroundResource { private final AgentsSettings settings; private final AgentsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of AgentsClient with default settings. */ public static final AgentsClient create() throws IOException { @@ -139,13 +154,17 @@ public static final AgentsClient create(AgentsStub stub) { protected AgentsClient(AgentsSettings settings) throws IOException { this.settings = settings; this.stub = ((AgentsStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected AgentsClient(AgentsStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final AgentsSettings getSettings() { @@ -160,10 +179,18 @@ public AgentsStub getStub() { * 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() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * 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 getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Retrieves the specified agent. diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsSettings.java index 165c5c3de87e..90d95ab1a91e 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -167,11 +168,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return AgentsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return AgentsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return AgentsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return AgentsStubSettings.defaultTransportChannelProvider(); } @@ -181,11 +189,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return AgentsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -223,6 +237,11 @@ private static Builder createDefault() { return new Builder(AgentsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(AgentsStubSettings.newHttpJsonBuilder()); + } + public AgentsStubSettings.Builder getStubSettingsBuilder() { return ((AgentsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AnswerRecordsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AnswerRecordsClient.java index d3598fa1888c..1dd635dd79b2 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AnswerRecordsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AnswerRecordsClient.java @@ -100,6 +100,20 @@ * AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * AnswerRecordsSettings answerRecordsSettings =
+ *     AnswerRecordsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             AnswerRecordsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AnswerRecordsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AnswerRecordsSettings.java index 23dd4f84d38e..e78e4999c1d6 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AnswerRecordsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AnswerRecordsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -118,11 +119,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return AnswerRecordsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return AnswerRecordsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return AnswerRecordsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return AnswerRecordsStubSettings.defaultTransportChannelProvider(); } @@ -132,11 +140,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return AnswerRecordsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -174,6 +188,11 @@ private static Builder createDefault() { return new Builder(AnswerRecordsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(AnswerRecordsStubSettings.newHttpJsonBuilder()); + } + public AnswerRecordsStubSettings.Builder getStubSettingsBuilder() { return ((AnswerRecordsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsClient.java index 38e3df5b0c01..73cd7e0aae28 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsClient.java @@ -100,6 +100,20 @@ * ContextsClient contextsClient = ContextsClient.create(contextsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ContextsSettings contextsSettings =
+ *     ContextsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ContextsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ContextsClient contextsClient = ContextsClient.create(contextsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsSettings.java index 2e1bde3c95df..7ae67a770065 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -127,11 +128,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ContextsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ContextsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ContextsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ContextsStubSettings.defaultTransportChannelProvider(); } @@ -141,11 +149,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ContextsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -183,6 +197,11 @@ private static Builder createDefault() { return new Builder(ContextsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ContextsStubSettings.newHttpJsonBuilder()); + } + public ContextsStubSettings.Builder getStubSettingsBuilder() { return ((ContextsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationProfilesClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationProfilesClient.java index 0cd618545e06..d5a46c34f462 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationProfilesClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationProfilesClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.dialogflow.v2beta1.stub.ConversationProfilesStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -110,6 +110,21 @@ * ConversationProfilesClient.create(conversationProfilesSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ConversationProfilesSettings conversationProfilesSettings =
+ *     ConversationProfilesSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ConversationProfilesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ConversationProfilesClient conversationProfilesClient =
+ *     ConversationProfilesClient.create(conversationProfilesSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -117,7 +132,8 @@ public class ConversationProfilesClient implements BackgroundResource { private final ConversationProfilesSettings settings; private final ConversationProfilesStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ConversationProfilesClient with default settings. */ public static final ConversationProfilesClient create() throws IOException { @@ -149,13 +165,17 @@ public static final ConversationProfilesClient create(ConversationProfilesStub s protected ConversationProfilesClient(ConversationProfilesSettings settings) throws IOException { this.settings = settings; this.stub = ((ConversationProfilesStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected ConversationProfilesClient(ConversationProfilesStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ConversationProfilesSettings getSettings() { @@ -170,10 +190,18 @@ public ConversationProfilesStub getStub() { * 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() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * 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 getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the list of all conversation profiles in the specified project. diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationProfilesSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationProfilesSettings.java index 5e0cd59a41f6..3824cc129bcd 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationProfilesSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationProfilesSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -172,11 +173,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ConversationProfilesStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ConversationProfilesStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ConversationProfilesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ConversationProfilesStubSettings.defaultTransportChannelProvider(); } @@ -186,11 +194,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ConversationProfilesStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -229,6 +243,11 @@ private static Builder createDefault() { return new Builder(ConversationProfilesStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ConversationProfilesStubSettings.newHttpJsonBuilder()); + } + public ConversationProfilesStubSettings.Builder getStubSettingsBuilder() { return ((ConversationProfilesStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationsClient.java index f729f66c935f..5e26f5d69220 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationsClient.java @@ -99,6 +99,20 @@ * ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ConversationsSettings conversationsSettings =
+ *     ConversationsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ConversationsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationsSettings.java index bf02a6b9d2ec..24e20dd40f0d 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ConversationsSettings.java @@ -24,6 +24,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -132,11 +133,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ConversationsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ConversationsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ConversationsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ConversationsStubSettings.defaultTransportChannelProvider(); } @@ -146,11 +154,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ConversationsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -188,6 +202,11 @@ private static Builder createDefault() { return new Builder(ConversationsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ConversationsStubSettings.newHttpJsonBuilder()); + } + public ConversationsStubSettings.Builder getStubSettingsBuilder() { return ((ConversationsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/DocumentsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/DocumentsClient.java index b9b819d65e88..0f415cf392b1 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/DocumentsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/DocumentsClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.dialogflow.v2beta1.stub.DocumentsStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -106,6 +106,20 @@ * DocumentsClient documentsClient = DocumentsClient.create(documentsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * DocumentsSettings documentsSettings =
+ *     DocumentsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             DocumentsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * DocumentsClient documentsClient = DocumentsClient.create(documentsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -113,7 +127,8 @@ public class DocumentsClient implements BackgroundResource { private final DocumentsSettings settings; private final DocumentsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of DocumentsClient with default settings. */ public static final DocumentsClient create() throws IOException { @@ -143,13 +158,17 @@ public static final DocumentsClient create(DocumentsStub stub) { protected DocumentsClient(DocumentsSettings settings) throws IOException { this.settings = settings; this.stub = ((DocumentsStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected DocumentsClient(DocumentsStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final DocumentsSettings getSettings() { @@ -164,10 +183,18 @@ public DocumentsStub getStub() { * 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() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * 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 getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the list of all documents of the knowledge base. diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/DocumentsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/DocumentsSettings.java index e85cb590c569..04cc6cc1e0e7 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/DocumentsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/DocumentsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -165,11 +166,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return DocumentsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return DocumentsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return DocumentsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return DocumentsStubSettings.defaultTransportChannelProvider(); } @@ -179,11 +187,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return DocumentsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -221,6 +235,11 @@ private static Builder createDefault() { return new Builder(DocumentsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(DocumentsStubSettings.newHttpJsonBuilder()); + } + public DocumentsStubSettings.Builder getStubSettingsBuilder() { return ((DocumentsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesClient.java index e7d2aad39e28..7b5bdb3f3101 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.dialogflow.v2beta1.stub.EntityTypesStubSettings; import com.google.common.util.concurrent.MoreExecutors; 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; @@ -105,6 +105,20 @@ * EntityTypesClient entityTypesClient = EntityTypesClient.create(entityTypesSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * EntityTypesSettings entityTypesSettings =
+ *     EntityTypesSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             EntityTypesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * EntityTypesClient entityTypesClient = EntityTypesClient.create(entityTypesSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -112,7 +126,8 @@ public class EntityTypesClient implements BackgroundResource { private final EntityTypesSettings settings; private final EntityTypesStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of EntityTypesClient with default settings. */ public static final EntityTypesClient create() throws IOException { @@ -143,13 +158,17 @@ public static final EntityTypesClient create(EntityTypesStub stub) { protected EntityTypesClient(EntityTypesSettings settings) throws IOException { this.settings = settings; this.stub = ((EntityTypesStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected EntityTypesClient(EntityTypesStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final EntityTypesSettings getSettings() { @@ -164,10 +183,18 @@ public EntityTypesStub getStub() { * 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() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * 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 getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the list of all entity types in the specified agent. diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesSettings.java index cdbf77be4177..ff00337f94c0 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -184,11 +185,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return EntityTypesStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return EntityTypesStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return EntityTypesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return EntityTypesStubSettings.defaultTransportChannelProvider(); } @@ -198,11 +206,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return EntityTypesStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -240,6 +254,11 @@ private static Builder createDefault() { return new Builder(EntityTypesStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(EntityTypesStubSettings.newHttpJsonBuilder()); + } + public EntityTypesStubSettings.Builder getStubSettingsBuilder() { return ((EntityTypesStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EnvironmentsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EnvironmentsClient.java index 5a15104eed3e..a31ebc711a41 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EnvironmentsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EnvironmentsClient.java @@ -103,6 +103,20 @@ * EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * EnvironmentsSettings environmentsSettings =
+ *     EnvironmentsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             EnvironmentsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EnvironmentsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EnvironmentsSettings.java index 73ce5933e6f5..50f3de85fa74 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EnvironmentsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EnvironmentsSettings.java @@ -24,6 +24,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -132,11 +133,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return EnvironmentsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return EnvironmentsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return EnvironmentsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return EnvironmentsStubSettings.defaultTransportChannelProvider(); } @@ -146,11 +154,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return EnvironmentsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -188,6 +202,11 @@ private static Builder createDefault() { return new Builder(EnvironmentsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(EnvironmentsStubSettings.newHttpJsonBuilder()); + } + public EnvironmentsStubSettings.Builder getStubSettingsBuilder() { return ((EnvironmentsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/FulfillmentsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/FulfillmentsClient.java index 2bca1dbdcbc4..832acf2b68db 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/FulfillmentsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/FulfillmentsClient.java @@ -91,6 +91,20 @@ * FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create(fulfillmentsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * FulfillmentsSettings fulfillmentsSettings =
+ *     FulfillmentsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             FulfillmentsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create(fulfillmentsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/FulfillmentsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/FulfillmentsSettings.java index a2063df1e60b..8576ba009a58 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/FulfillmentsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/FulfillmentsSettings.java @@ -21,6 +21,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -103,11 +104,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return FulfillmentsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return FulfillmentsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return FulfillmentsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return FulfillmentsStubSettings.defaultTransportChannelProvider(); } @@ -117,11 +125,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return FulfillmentsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -159,6 +173,11 @@ private static Builder createDefault() { return new Builder(FulfillmentsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(FulfillmentsStubSettings.newHttpJsonBuilder()); + } + public FulfillmentsStubSettings.Builder getStubSettingsBuilder() { return ((FulfillmentsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsClient.java index 0d39869347eb..732f3166b1ca 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.dialogflow.v2beta1.stub.IntentsStubSettings; import com.google.common.util.concurrent.MoreExecutors; 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; @@ -103,6 +103,20 @@ * IntentsClient intentsClient = IntentsClient.create(intentsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * IntentsSettings intentsSettings =
+ *     IntentsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             IntentsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * IntentsClient intentsClient = IntentsClient.create(intentsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -110,7 +124,8 @@ public class IntentsClient implements BackgroundResource { private final IntentsSettings settings; private final IntentsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of IntentsClient with default settings. */ public static final IntentsClient create() throws IOException { @@ -140,13 +155,17 @@ public static final IntentsClient create(IntentsStub stub) { protected IntentsClient(IntentsSettings settings) throws IOException { this.settings = settings; this.stub = ((IntentsStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected IntentsClient(IntentsStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final IntentsSettings getSettings() { @@ -161,10 +180,18 @@ public IntentsStub getStub() { * 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() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * 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 getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the list of all intents in the specified agent. diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsSettings.java index cc3eaf0924c2..066e89c952f5 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -147,11 +148,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return IntentsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return IntentsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return IntentsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return IntentsStubSettings.defaultTransportChannelProvider(); } @@ -161,11 +169,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return IntentsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -203,6 +217,11 @@ private static Builder createDefault() { return new Builder(IntentsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(IntentsStubSettings.newHttpJsonBuilder()); + } + public IntentsStubSettings.Builder getStubSettingsBuilder() { return ((IntentsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/KnowledgeBasesClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/KnowledgeBasesClient.java index 338609e6468b..6222bf4c3642 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/KnowledgeBasesClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/KnowledgeBasesClient.java @@ -101,6 +101,20 @@ * KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create(knowledgeBasesSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * KnowledgeBasesSettings knowledgeBasesSettings =
+ *     KnowledgeBasesSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             KnowledgeBasesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create(knowledgeBasesSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/KnowledgeBasesSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/KnowledgeBasesSettings.java index 2e22a9d2a841..eb3155ca447f 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/KnowledgeBasesSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/KnowledgeBasesSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -127,11 +128,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return KnowledgeBasesStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return KnowledgeBasesStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return KnowledgeBasesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return KnowledgeBasesStubSettings.defaultTransportChannelProvider(); } @@ -141,11 +149,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return KnowledgeBasesStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -183,6 +197,11 @@ private static Builder createDefault() { return new Builder(KnowledgeBasesStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(KnowledgeBasesStubSettings.newHttpJsonBuilder()); + } + public KnowledgeBasesStubSettings.Builder getStubSettingsBuilder() { return ((KnowledgeBasesStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ParticipantsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ParticipantsClient.java index c7e12a29b3e6..99d20f9fd2c3 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ParticipantsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ParticipantsClient.java @@ -102,6 +102,20 @@ * ParticipantsClient participantsClient = ParticipantsClient.create(participantsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ParticipantsSettings participantsSettings =
+ *     ParticipantsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ParticipantsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ParticipantsClient participantsClient = ParticipantsClient.create(participantsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ParticipantsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ParticipantsSettings.java index ecae1a3f90f1..f84bb6fc536a 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ParticipantsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ParticipantsSettings.java @@ -24,6 +24,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -172,11 +173,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ParticipantsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ParticipantsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ParticipantsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ParticipantsStubSettings.defaultTransportChannelProvider(); } @@ -186,11 +194,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ParticipantsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -228,6 +242,11 @@ private static Builder createDefault() { return new Builder(ParticipantsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ParticipantsStubSettings.newHttpJsonBuilder()); + } + public ParticipantsStubSettings.Builder getStubSettingsBuilder() { return ((ParticipantsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesClient.java index fc4f5947b02e..67a403d13087 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesClient.java @@ -105,6 +105,21 @@ * SessionEntityTypesClient.create(sessionEntityTypesSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * SessionEntityTypesSettings sessionEntityTypesSettings =
+ *     SessionEntityTypesSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SessionEntityTypesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SessionEntityTypesClient sessionEntityTypesClient =
+ *     SessionEntityTypesClient.create(sessionEntityTypesSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesSettings.java index e69f62958aea..42ae22ee58a2 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -132,11 +133,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SessionEntityTypesStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return SessionEntityTypesStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SessionEntityTypesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SessionEntityTypesStubSettings.defaultTransportChannelProvider(); } @@ -146,11 +154,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SessionEntityTypesStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -188,6 +202,11 @@ private static Builder createDefault() { return new Builder(SessionEntityTypesStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SessionEntityTypesStubSettings.newHttpJsonBuilder()); + } + public SessionEntityTypesStubSettings.Builder getStubSettingsBuilder() { return ((SessionEntityTypesStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsClient.java index f546e73675ac..0614dea16154 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsClient.java @@ -94,6 +94,20 @@ * SessionsClient sessionsClient = SessionsClient.create(sessionsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * SessionsSettings sessionsSettings =
+ *     SessionsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SessionsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SessionsClient sessionsClient = SessionsClient.create(sessionsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsSettings.java index ec9c965d70b9..55a6b3fa663d 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsSettings.java @@ -21,6 +21,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -104,11 +105,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SessionsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return SessionsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SessionsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SessionsStubSettings.defaultTransportChannelProvider(); } @@ -118,11 +126,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SessionsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -160,6 +174,11 @@ private static Builder createDefault() { return new Builder(SessionsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SessionsStubSettings.newHttpJsonBuilder()); + } + public SessionsStubSettings.Builder getStubSettingsBuilder() { return ((SessionsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/VersionsClient.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/VersionsClient.java index 88c9e425ab0b..df030b3c00ca 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/VersionsClient.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/VersionsClient.java @@ -99,6 +99,20 @@ * VersionsClient versionsClient = VersionsClient.create(versionsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * VersionsSettings versionsSettings =
+ *     VersionsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             VersionsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * VersionsClient versionsClient = VersionsClient.create(versionsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/VersionsSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/VersionsSettings.java index cf16d6ef9f42..fc163e091a7a 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/VersionsSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/VersionsSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -122,11 +123,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return VersionsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return VersionsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return VersionsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return VersionsStubSettings.defaultTransportChannelProvider(); } @@ -136,11 +144,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return VersionsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -178,6 +192,11 @@ private static Builder createDefault() { return new Builder(VersionsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(VersionsStubSettings.newHttpJsonBuilder()); + } + public VersionsStubSettings.Builder getStubSettingsBuilder() { return ((VersionsStubSettings.Builder) getStubSettings()); } diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStub.java index c0204b8617c7..e1655ebc22e3 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStub.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStub.java @@ -52,7 +52,11 @@ public abstract class AgentsStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable getAgentCallable() { diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStubSettings.java index dc98c48f08ae..52e820c52e42 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -259,6 +262,11 @@ public AgentsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcAgentsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonAgentsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -291,29 +299,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(AgentsStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(AgentsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return AgentsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -474,6 +507,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .getAgentSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AnswerRecordsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AnswerRecordsStubSettings.java index 870267c29828..917fc54c6336 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AnswerRecordsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AnswerRecordsStubSettings.java @@ -27,6 +27,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -194,6 +197,11 @@ public AnswerRecordsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcAnswerRecordsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonAnswerRecordsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -226,18 +234,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(AnswerRecordsStubSettings.class)) @@ -245,11 +260,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(AnswerRecordsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return AnswerRecordsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -351,6 +385,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .getAnswerRecordSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ContextsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ContextsStubSettings.java index ed4736080ca4..ae0ad5fe5559 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ContextsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ContextsStubSettings.java @@ -27,6 +27,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -200,6 +203,11 @@ public ContextsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcContextsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonContextsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -232,29 +240,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(ContextsStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(ContextsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ContextsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -377,6 +410,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listContextsSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ConversationProfilesStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ConversationProfilesStub.java index 2faf04e95f1e..f9b1c0785b12 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ConversationProfilesStub.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ConversationProfilesStub.java @@ -49,7 +49,11 @@ public abstract class ConversationProfilesStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ConversationProfilesStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ConversationProfilesStubSettings.java index 6707f8293da4..5de2a7f01342 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ConversationProfilesStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ConversationProfilesStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -283,6 +286,11 @@ public ConversationProfilesStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcConversationProfilesStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonConversationProfilesStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -315,18 +323,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ConversationProfilesStubSettings.class)) @@ -334,11 +349,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ConversationProfilesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ConversationProfilesStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -499,6 +533,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listConversationProfilesSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ConversationsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ConversationsStubSettings.java index 09ff2eb3b415..b2e7772fe838 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ConversationsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ConversationsStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -274,6 +277,11 @@ public ConversationsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcConversationsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonConversationsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -306,18 +314,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ConversationsStubSettings.class)) @@ -325,11 +340,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ConversationsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ConversationsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -457,6 +491,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createConversationSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/DocumentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/DocumentsStub.java index f59e90ab595c..54f53627bd83 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/DocumentsStub.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/DocumentsStub.java @@ -49,7 +49,11 @@ public abstract class DocumentsStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/DocumentsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/DocumentsStubSettings.java index cd62204e6bee..9741ceeede3b 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/DocumentsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/DocumentsStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -256,6 +259,11 @@ public DocumentsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDocumentsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonDocumentsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -288,29 +296,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(DocumentsStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(DocumentsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DocumentsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -473,6 +506,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listDocumentsSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStub.java index 6779650534cb..c864a364ecbc 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStub.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStub.java @@ -52,7 +52,11 @@ public abstract class EntityTypesStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStubSettings.java index 97ce724e4c1c..0dee1a6135dd 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -289,6 +292,11 @@ public EntityTypesStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcEntityTypesStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonEntityTypesStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -321,18 +329,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(EntityTypesStubSettings.class)) @@ -340,11 +355,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(EntityTypesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return EntityTypesStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -534,6 +568,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listEntityTypesSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EnvironmentsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EnvironmentsStubSettings.java index 15452ebcac9e..ad2a4b623453 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EnvironmentsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EnvironmentsStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -276,6 +279,11 @@ public EnvironmentsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcEnvironmentsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonEnvironmentsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -308,18 +316,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(EnvironmentsStubSettings.class)) @@ -327,11 +342,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(EnvironmentsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return EnvironmentsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -460,6 +494,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listEnvironmentsSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/FulfillmentsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/FulfillmentsStubSettings.java index 694ac19e6486..8fae52e2177a 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/FulfillmentsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/FulfillmentsStubSettings.java @@ -24,6 +24,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -106,6 +109,11 @@ public FulfillmentsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcFulfillmentsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonFulfillmentsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -138,18 +146,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(FulfillmentsStubSettings.class)) @@ -157,11 +172,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(FulfillmentsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return FulfillmentsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -257,6 +291,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .getFulfillmentSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAgentsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAgentsCallableFactory.java new file mode 100644 index 000000000000..7bb9dc8f702c --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAgentsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Agents service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonAgentsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAgentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAgentsStub.java new file mode 100644 index 000000000000..3b1fdeb1462c --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAgentsStub.java @@ -0,0 +1,705 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import static com.google.cloud.dialogflow.v2beta1.AgentsClient.SearchAgentsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +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.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.DeleteAgentRequest; +import com.google.cloud.dialogflow.v2beta1.ExportAgentRequest; +import com.google.cloud.dialogflow.v2beta1.ExportAgentResponse; +import com.google.cloud.dialogflow.v2beta1.GetAgentRequest; +import com.google.cloud.dialogflow.v2beta1.GetValidationResultRequest; +import com.google.cloud.dialogflow.v2beta1.ImportAgentRequest; +import com.google.cloud.dialogflow.v2beta1.RestoreAgentRequest; +import com.google.cloud.dialogflow.v2beta1.SearchAgentsRequest; +import com.google.cloud.dialogflow.v2beta1.SearchAgentsResponse; +import com.google.cloud.dialogflow.v2beta1.SetAgentRequest; +import com.google.cloud.dialogflow.v2beta1.TrainAgentRequest; +import com.google.cloud.dialogflow.v2beta1.ValidationResult; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Agents service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonAgentsStub extends AgentsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(ExportAgentResponse.getDescriptor()) + .add(Struct.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor getAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Agents/GetAgent") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/agent", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*}/agent") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Agent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor setAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Agents/SetAgent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{agent.parent=projects/*}/agent", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "agent.parent", request.getAgent().getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{agent.parent=projects/*/locations/*}/agent") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> ProtoRestSerializer.create().toBody("agent", request.getAgent())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Agent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor deleteAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Agents/DeleteAgent") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/agent", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*}/agent") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + searchAgentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Agents/SearchAgents") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/agent:search", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*}/agent:search") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SearchAgentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + trainAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Agents/TrainAgent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/agent:train", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*}/agent:train") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (TrainAgentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + exportAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Agents/ExportAgent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/agent:export", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*}/agent:export") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ExportAgentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Agents/ImportAgent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/agent:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*}/agent:import") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportAgentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + restoreAgentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Agents/RestoreAgent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/agent:restore", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*}/agent:restore") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RestoreAgentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getValidationResultMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Agents/GetValidationResult") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/agent/validationResult", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*}/agent/validationResult") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ValidationResult.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable getAgentCallable; + private final UnaryCallable setAgentCallable; + private final UnaryCallable deleteAgentCallable; + 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 UnaryCallable + getValidationResultCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonAgentsStub create(AgentsStubSettings settings) throws IOException { + return new HttpJsonAgentsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonAgentsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonAgentsStub(AgentsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonAgentsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonAgentsStub( + AgentsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonAgentsStub, 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 HttpJsonAgentsStub(AgentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonAgentsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonAgentsStub, 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 HttpJsonAgentsStub( + AgentsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings getAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings searchAgentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(searchAgentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings trainAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(trainAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings exportAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(exportAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings restoreAgentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(restoreAgentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getValidationResultTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getValidationResultMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.getAgentCallable = + callableFactory.createUnaryCallable( + getAgentTransportSettings, settings.getAgentSettings(), clientContext); + this.setAgentCallable = + callableFactory.createUnaryCallable( + setAgentTransportSettings, settings.setAgentSettings(), clientContext); + this.deleteAgentCallable = + callableFactory.createUnaryCallable( + deleteAgentTransportSettings, settings.deleteAgentSettings(), 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, + httpJsonOperationsStub); + this.exportAgentCallable = + callableFactory.createUnaryCallable( + exportAgentTransportSettings, settings.exportAgentSettings(), clientContext); + this.exportAgentOperationCallable = + callableFactory.createOperationCallable( + exportAgentTransportSettings, + settings.exportAgentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importAgentCallable = + callableFactory.createUnaryCallable( + importAgentTransportSettings, settings.importAgentSettings(), clientContext); + this.importAgentOperationCallable = + callableFactory.createOperationCallable( + importAgentTransportSettings, + settings.importAgentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.restoreAgentCallable = + callableFactory.createUnaryCallable( + restoreAgentTransportSettings, settings.restoreAgentSettings(), clientContext); + this.restoreAgentOperationCallable = + callableFactory.createOperationCallable( + restoreAgentTransportSettings, + settings.restoreAgentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getValidationResultCallable = + callableFactory.createUnaryCallable( + getValidationResultTransportSettings, + settings.getValidationResultSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(getAgentMethodDescriptor); + methodDescriptors.add(setAgentMethodDescriptor); + methodDescriptors.add(deleteAgentMethodDescriptor); + methodDescriptors.add(searchAgentsMethodDescriptor); + methodDescriptors.add(trainAgentMethodDescriptor); + methodDescriptors.add(exportAgentMethodDescriptor); + methodDescriptors.add(importAgentMethodDescriptor); + methodDescriptors.add(restoreAgentMethodDescriptor); + methodDescriptors.add(getValidationResultMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable getAgentCallable() { + return getAgentCallable; + } + + @Override + public UnaryCallable setAgentCallable() { + return setAgentCallable; + } + + @Override + public UnaryCallable deleteAgentCallable() { + return deleteAgentCallable; + } + + @Override + public UnaryCallable searchAgentsCallable() { + return searchAgentsCallable; + } + + @Override + public UnaryCallable searchAgentsPagedCallable() { + return searchAgentsPagedCallable; + } + + @Override + public UnaryCallable trainAgentCallable() { + return trainAgentCallable; + } + + @Override + public OperationCallable trainAgentOperationCallable() { + return trainAgentOperationCallable; + } + + @Override + public UnaryCallable exportAgentCallable() { + return exportAgentCallable; + } + + @Override + public OperationCallable + exportAgentOperationCallable() { + return exportAgentOperationCallable; + } + + @Override + public UnaryCallable importAgentCallable() { + return importAgentCallable; + } + + @Override + public OperationCallable importAgentOperationCallable() { + return importAgentOperationCallable; + } + + @Override + public UnaryCallable restoreAgentCallable() { + return restoreAgentCallable; + } + + @Override + public OperationCallable restoreAgentOperationCallable() { + return restoreAgentOperationCallable; + } + + @Override + public UnaryCallable getValidationResultCallable() { + return getValidationResultCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAnswerRecordsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAnswerRecordsCallableFactory.java new file mode 100644 index 000000000000..96b6150f9431 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAnswerRecordsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the AnswerRecords service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonAnswerRecordsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAnswerRecordsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAnswerRecordsStub.java new file mode 100644 index 000000000000..87e09a49f653 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonAnswerRecordsStub.java @@ -0,0 +1,324 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import static com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient.ListAnswerRecordsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2beta1.AnswerRecord; +import com.google.cloud.dialogflow.v2beta1.GetAnswerRecordRequest; +import com.google.cloud.dialogflow.v2beta1.ListAnswerRecordsRequest; +import com.google.cloud.dialogflow.v2beta1.ListAnswerRecordsResponse; +import com.google.cloud.dialogflow.v2beta1.UpdateAnswerRecordRequest; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the AnswerRecords service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonAnswerRecordsStub extends AnswerRecordsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + getAnswerRecordMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.AnswerRecords/GetAnswerRecord") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/answerRecords/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{name=projects/*/locations/*/answerRecords/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AnswerRecord.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listAnswerRecordsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.AnswerRecords/ListAnswerRecords") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/answerRecords", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*}/answerRecords") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListAnswerRecordsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateAnswerRecordMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.AnswerRecords/UpdateAnswerRecord") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{answerRecord.name=projects/*/answerRecords/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "answerRecord.name", request.getAnswerRecord().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{answerRecord.name=projects/*/locations/*/answerRecords/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("answerRecord", request.getAnswerRecord())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AnswerRecord.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable getAnswerRecordCallable; + private final UnaryCallable + listAnswerRecordsCallable; + private final UnaryCallable + listAnswerRecordsPagedCallable; + private final UnaryCallable updateAnswerRecordCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonAnswerRecordsStub create(AnswerRecordsStubSettings settings) + throws IOException { + return new HttpJsonAnswerRecordsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonAnswerRecordsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonAnswerRecordsStub( + AnswerRecordsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonAnswerRecordsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonAnswerRecordsStub( + AnswerRecordsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonAnswerRecordsStub, 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 HttpJsonAnswerRecordsStub( + AnswerRecordsStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonAnswerRecordsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonAnswerRecordsStub, 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 HttpJsonAnswerRecordsStub( + AnswerRecordsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings getAnswerRecordTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getAnswerRecordMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listAnswerRecordsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listAnswerRecordsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateAnswerRecordTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateAnswerRecordMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.getAnswerRecordCallable = + callableFactory.createUnaryCallable( + getAnswerRecordTransportSettings, settings.getAnswerRecordSettings(), clientContext); + this.listAnswerRecordsCallable = + callableFactory.createUnaryCallable( + listAnswerRecordsTransportSettings, + settings.listAnswerRecordsSettings(), + clientContext); + this.listAnswerRecordsPagedCallable = + callableFactory.createPagedCallable( + listAnswerRecordsTransportSettings, + settings.listAnswerRecordsSettings(), + clientContext); + this.updateAnswerRecordCallable = + callableFactory.createUnaryCallable( + updateAnswerRecordTransportSettings, + settings.updateAnswerRecordSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(getAnswerRecordMethodDescriptor); + methodDescriptors.add(listAnswerRecordsMethodDescriptor); + methodDescriptors.add(updateAnswerRecordMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable getAnswerRecordCallable() { + return getAnswerRecordCallable; + } + + @Override + public UnaryCallable + listAnswerRecordsCallable() { + return listAnswerRecordsCallable; + } + + @Override + public UnaryCallable + listAnswerRecordsPagedCallable() { + return listAnswerRecordsPagedCallable; + } + + @Override + public UnaryCallable updateAnswerRecordCallable() { + return updateAnswerRecordCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonContextsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonContextsCallableFactory.java new file mode 100644 index 000000000000..65941012b0e6 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonContextsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Contexts service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonContextsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonContextsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonContextsStub.java new file mode 100644 index 000000000000..761106f58103 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonContextsStub.java @@ -0,0 +1,482 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import static com.google.cloud.dialogflow.v2beta1.ContextsClient.ListContextsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.CreateContextRequest; +import com.google.cloud.dialogflow.v2beta1.DeleteAllContextsRequest; +import com.google.cloud.dialogflow.v2beta1.DeleteContextRequest; +import com.google.cloud.dialogflow.v2beta1.GetContextRequest; +import com.google.cloud.dialogflow.v2beta1.ListContextsRequest; +import com.google.cloud.dialogflow.v2beta1.ListContextsResponse; +import com.google.cloud.dialogflow.v2beta1.UpdateContextRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Contexts service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonContextsStub extends ContextsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listContextsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Contexts/ListContexts") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent/sessions/*}/contexts", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/agent/environments/*/users/*/sessions/*}/contexts", + "/v2beta1/{parent=projects/*/locations/*/agent/sessions/*}/contexts", + "/v2beta1/{parent=projects/*/locations/*/agent/environments/*/users/*/sessions/*}/contexts") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListContextsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getContextMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Contexts/GetContext") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/agent/sessions/*/contexts/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/agent/environments/*/users/*/sessions/*/contexts/*}", + "/v2beta1/{name=projects/*/locations/*/agent/sessions/*/contexts/*}", + "/v2beta1/{name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/contexts/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Context.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createContextMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Contexts/CreateContext") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent/sessions/*}/contexts", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/agent/environments/*/users/*/sessions/*}/contexts", + "/v2beta1/{parent=projects/*/locations/*/agent/sessions/*}/contexts", + "/v2beta1/{parent=projects/*/locations/*/agent/environments/*/users/*/sessions/*}/contexts") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("context", request.getContext())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Context.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateContextMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Contexts/UpdateContext") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{context.name=projects/*/agent/sessions/*/contexts/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "context.name", request.getContext().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{context.name=projects/*/agent/environments/*/users/*/sessions/*/contexts/*}", + "/v2beta1/{context.name=projects/*/locations/*/agent/sessions/*/contexts/*}", + "/v2beta1/{context.name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/contexts/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("context", request.getContext())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Context.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteContextMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Contexts/DeleteContext") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/agent/sessions/*/contexts/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/agent/environments/*/users/*/sessions/*/contexts/*}", + "/v2beta1/{name=projects/*/locations/*/agent/sessions/*/contexts/*}", + "/v2beta1/{name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/contexts/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteAllContextsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Contexts/DeleteAllContexts") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent/sessions/*}/contexts", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/agent/environments/*/users/*/sessions/*}/contexts", + "/v2beta1/{parent=projects/*/locations/*/agent/sessions/*}/contexts", + "/v2beta1/{parent=projects/*/locations/*/agent/environments/*/users/*/sessions/*}/contexts") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + 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 BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonContextsStub create(ContextsStubSettings settings) + throws IOException { + return new HttpJsonContextsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonContextsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonContextsStub( + ContextsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonContextsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonContextsStub( + ContextsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonContextsStub, 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 HttpJsonContextsStub(ContextsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonContextsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonContextsStub, 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 HttpJsonContextsStub( + ContextsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listContextsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listContextsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getContextTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getContextMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createContextTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createContextMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateContextTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateContextMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteContextTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteContextMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteAllContextsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteAllContextsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .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); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listContextsMethodDescriptor); + methodDescriptors.add(getContextMethodDescriptor); + methodDescriptors.add(createContextMethodDescriptor); + methodDescriptors.add(updateContextMethodDescriptor); + methodDescriptors.add(deleteContextMethodDescriptor); + methodDescriptors.add(deleteAllContextsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listContextsCallable() { + return listContextsCallable; + } + + @Override + public UnaryCallable listContextsPagedCallable() { + return listContextsPagedCallable; + } + + @Override + public UnaryCallable getContextCallable() { + return getContextCallable; + } + + @Override + public UnaryCallable createContextCallable() { + return createContextCallable; + } + + @Override + public UnaryCallable updateContextCallable() { + return updateContextCallable; + } + + @Override + public UnaryCallable deleteContextCallable() { + return deleteContextCallable; + } + + @Override + public UnaryCallable deleteAllContextsCallable() { + return deleteAllContextsCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationProfilesCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationProfilesCallableFactory.java new file mode 100644 index 000000000000..a453705b61ff --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationProfilesCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ConversationProfiles service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonConversationProfilesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationProfilesStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationProfilesStub.java new file mode 100644 index 000000000000..11997f76c106 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationProfilesStub.java @@ -0,0 +1,650 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import static com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient.ListConversationProfilesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +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.v2beta1.ClearSuggestionFeatureConfigOperationMetadata; +import com.google.cloud.dialogflow.v2beta1.ClearSuggestionFeatureConfigRequest; +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.CreateConversationProfileRequest; +import com.google.cloud.dialogflow.v2beta1.DeleteConversationProfileRequest; +import com.google.cloud.dialogflow.v2beta1.GetConversationProfileRequest; +import com.google.cloud.dialogflow.v2beta1.ListConversationProfilesRequest; +import com.google.cloud.dialogflow.v2beta1.ListConversationProfilesResponse; +import com.google.cloud.dialogflow.v2beta1.SetSuggestionFeatureConfigOperationMetadata; +import com.google.cloud.dialogflow.v2beta1.SetSuggestionFeatureConfigRequest; +import com.google.cloud.dialogflow.v2beta1.UpdateConversationProfileRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ConversationProfiles service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonConversationProfilesStub extends ConversationProfilesStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ClearSuggestionFeatureConfigOperationMetadata.getDescriptor()) + .add(SetSuggestionFeatureConfigOperationMetadata.getDescriptor()) + .add(ConversationProfile.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor< + ListConversationProfilesRequest, ListConversationProfilesResponse> + listConversationProfilesMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.ConversationProfiles/ListConversationProfiles") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/conversationProfiles", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*}/conversationProfiles") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListConversationProfilesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getConversationProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.ConversationProfiles/GetConversationProfile") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/conversationProfiles/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/conversationProfiles/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ConversationProfile.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createConversationProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.ConversationProfiles/CreateConversationProfile") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/conversationProfiles", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*}/conversationProfiles") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("conversationProfile", request.getConversationProfile())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ConversationProfile.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateConversationProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.ConversationProfiles/UpdateConversationProfile") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{conversationProfile.name=projects/*/conversationProfiles/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "conversationProfile.name", + request.getConversationProfile().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{conversationProfile.name=projects/*/locations/*/conversationProfiles/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("conversationProfile", request.getConversationProfile())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ConversationProfile.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteConversationProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.ConversationProfiles/DeleteConversationProfile") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/conversationProfiles/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/conversationProfiles/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setSuggestionFeatureConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.ConversationProfiles/SetSuggestionFeatureConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{conversationProfile=projects/*/conversationProfiles/*}:setSuggestionFeatureConfig", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "conversationProfile", request.getConversationProfile()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{conversationProfile=projects/*/locations/*/conversationProfiles/*}:setSuggestionFeatureConfig") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody( + "*", request.toBuilder().clearConversationProfile().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (SetSuggestionFeatureConfigRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + clearSuggestionFeatureConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.ConversationProfiles/ClearSuggestionFeatureConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{conversationProfile=projects/*/conversationProfiles/*}:clearSuggestionFeatureConfig", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "conversationProfile", request.getConversationProfile()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{conversationProfile=projects/*/locations/*/conversationProfiles/*}:clearSuggestionFeatureConfig") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody( + "*", request.toBuilder().clearConversationProfile().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ClearSuggestionFeatureConfigRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + listConversationProfilesCallable; + private final UnaryCallable< + ListConversationProfilesRequest, ListConversationProfilesPagedResponse> + listConversationProfilesPagedCallable; + private final UnaryCallable + getConversationProfileCallable; + private final UnaryCallable + createConversationProfileCallable; + private final UnaryCallable + updateConversationProfileCallable; + private final UnaryCallable + deleteConversationProfileCallable; + private final UnaryCallable + setSuggestionFeatureConfigCallable; + private final OperationCallable< + SetSuggestionFeatureConfigRequest, + ConversationProfile, + SetSuggestionFeatureConfigOperationMetadata> + setSuggestionFeatureConfigOperationCallable; + private final UnaryCallable + clearSuggestionFeatureConfigCallable; + private final OperationCallable< + ClearSuggestionFeatureConfigRequest, + ConversationProfile, + ClearSuggestionFeatureConfigOperationMetadata> + clearSuggestionFeatureConfigOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonConversationProfilesStub create( + ConversationProfilesStubSettings settings) throws IOException { + return new HttpJsonConversationProfilesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonConversationProfilesStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonConversationProfilesStub( + ConversationProfilesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonConversationProfilesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonConversationProfilesStub( + ConversationProfilesStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonConversationProfilesStub, 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 HttpJsonConversationProfilesStub( + ConversationProfilesStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonConversationProfilesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonConversationProfilesStub, 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 HttpJsonConversationProfilesStub( + ConversationProfilesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listConversationProfilesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listConversationProfilesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getConversationProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getConversationProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createConversationProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createConversationProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateConversationProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateConversationProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteConversationProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteConversationProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + setSuggestionFeatureConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setSuggestionFeatureConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + clearSuggestionFeatureConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(clearSuggestionFeatureConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listConversationProfilesCallable = + callableFactory.createUnaryCallable( + listConversationProfilesTransportSettings, + settings.listConversationProfilesSettings(), + clientContext); + this.listConversationProfilesPagedCallable = + callableFactory.createPagedCallable( + listConversationProfilesTransportSettings, + settings.listConversationProfilesSettings(), + clientContext); + this.getConversationProfileCallable = + callableFactory.createUnaryCallable( + getConversationProfileTransportSettings, + settings.getConversationProfileSettings(), + clientContext); + this.createConversationProfileCallable = + callableFactory.createUnaryCallable( + createConversationProfileTransportSettings, + settings.createConversationProfileSettings(), + clientContext); + this.updateConversationProfileCallable = + callableFactory.createUnaryCallable( + updateConversationProfileTransportSettings, + settings.updateConversationProfileSettings(), + clientContext); + this.deleteConversationProfileCallable = + callableFactory.createUnaryCallable( + deleteConversationProfileTransportSettings, + settings.deleteConversationProfileSettings(), + clientContext); + this.setSuggestionFeatureConfigCallable = + callableFactory.createUnaryCallable( + setSuggestionFeatureConfigTransportSettings, + settings.setSuggestionFeatureConfigSettings(), + clientContext); + this.setSuggestionFeatureConfigOperationCallable = + callableFactory.createOperationCallable( + setSuggestionFeatureConfigTransportSettings, + settings.setSuggestionFeatureConfigOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.clearSuggestionFeatureConfigCallable = + callableFactory.createUnaryCallable( + clearSuggestionFeatureConfigTransportSettings, + settings.clearSuggestionFeatureConfigSettings(), + clientContext); + this.clearSuggestionFeatureConfigOperationCallable = + callableFactory.createOperationCallable( + clearSuggestionFeatureConfigTransportSettings, + settings.clearSuggestionFeatureConfigOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listConversationProfilesMethodDescriptor); + methodDescriptors.add(getConversationProfileMethodDescriptor); + methodDescriptors.add(createConversationProfileMethodDescriptor); + methodDescriptors.add(updateConversationProfileMethodDescriptor); + methodDescriptors.add(deleteConversationProfileMethodDescriptor); + methodDescriptors.add(setSuggestionFeatureConfigMethodDescriptor); + methodDescriptors.add(clearSuggestionFeatureConfigMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + listConversationProfilesCallable() { + return listConversationProfilesCallable; + } + + @Override + public UnaryCallable + listConversationProfilesPagedCallable() { + return listConversationProfilesPagedCallable; + } + + @Override + public UnaryCallable + getConversationProfileCallable() { + return getConversationProfileCallable; + } + + @Override + public UnaryCallable + createConversationProfileCallable() { + return createConversationProfileCallable; + } + + @Override + public UnaryCallable + updateConversationProfileCallable() { + return updateConversationProfileCallable; + } + + @Override + public UnaryCallable + deleteConversationProfileCallable() { + return deleteConversationProfileCallable; + } + + @Override + public UnaryCallable + setSuggestionFeatureConfigCallable() { + return setSuggestionFeatureConfigCallable; + } + + @Override + public OperationCallable< + SetSuggestionFeatureConfigRequest, + ConversationProfile, + SetSuggestionFeatureConfigOperationMetadata> + setSuggestionFeatureConfigOperationCallable() { + return setSuggestionFeatureConfigOperationCallable; + } + + @Override + public UnaryCallable + clearSuggestionFeatureConfigCallable() { + return clearSuggestionFeatureConfigCallable; + } + + @Override + public OperationCallable< + ClearSuggestionFeatureConfigRequest, + ConversationProfile, + ClearSuggestionFeatureConfigOperationMetadata> + clearSuggestionFeatureConfigOperationCallable() { + return clearSuggestionFeatureConfigOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationsCallableFactory.java new file mode 100644 index 000000000000..4d57babbc0e3 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Conversations service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonConversationsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationsStub.java new file mode 100644 index 000000000000..5cdc4a6f8641 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonConversationsStub.java @@ -0,0 +1,511 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import static com.google.cloud.dialogflow.v2beta1.ConversationsClient.ListConversationsPagedResponse; +import static com.google.cloud.dialogflow.v2beta1.ConversationsClient.ListMessagesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2beta1.BatchCreateMessagesRequest; +import com.google.cloud.dialogflow.v2beta1.BatchCreateMessagesResponse; +import com.google.cloud.dialogflow.v2beta1.CompleteConversationRequest; +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.CreateConversationRequest; +import com.google.cloud.dialogflow.v2beta1.GetConversationRequest; +import com.google.cloud.dialogflow.v2beta1.ListConversationsRequest; +import com.google.cloud.dialogflow.v2beta1.ListConversationsResponse; +import com.google.cloud.dialogflow.v2beta1.ListMessagesRequest; +import com.google.cloud.dialogflow.v2beta1.ListMessagesResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Conversations service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonConversationsStub extends ConversationsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createConversationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Conversations/CreateConversation") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/conversations", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*}/conversations") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "conversationId", request.getConversationId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("conversation", request.getConversation())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Conversation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listConversationsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Conversations/ListConversations") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/conversations", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*}/conversations") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListConversationsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getConversationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Conversations/GetConversation") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/conversations/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{name=projects/*/locations/*/conversations/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Conversation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + completeConversationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.Conversations/CompleteConversation") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/conversations/*}:complete", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/conversations/*}:complete") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Conversation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchCreateMessagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.Conversations/BatchCreateMessages") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/conversations/*}/messages:batchCreate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/conversations/*}/messages:batchCreate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BatchCreateMessagesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listMessagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Conversations/ListMessages") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/conversations/*}/messages", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/conversations/*}/messages") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListMessagesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createConversationCallable; + private final UnaryCallable + listConversationsCallable; + private final UnaryCallable + listConversationsPagedCallable; + private final UnaryCallable getConversationCallable; + private final UnaryCallable + completeConversationCallable; + private final UnaryCallable + batchCreateMessagesCallable; + private final UnaryCallable listMessagesCallable; + private final UnaryCallable + listMessagesPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonConversationsStub create(ConversationsStubSettings settings) + throws IOException { + return new HttpJsonConversationsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonConversationsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonConversationsStub( + ConversationsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonConversationsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonConversationsStub( + ConversationsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonConversationsStub, 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 HttpJsonConversationsStub( + ConversationsStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonConversationsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonConversationsStub, 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 HttpJsonConversationsStub( + ConversationsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + createConversationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createConversationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listConversationsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listConversationsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getConversationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getConversationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + completeConversationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(completeConversationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchCreateMessagesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(batchCreateMessagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listMessagesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listMessagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createConversationCallable = + callableFactory.createUnaryCallable( + createConversationTransportSettings, + settings.createConversationSettings(), + clientContext); + this.listConversationsCallable = + callableFactory.createUnaryCallable( + listConversationsTransportSettings, + settings.listConversationsSettings(), + clientContext); + this.listConversationsPagedCallable = + callableFactory.createPagedCallable( + listConversationsTransportSettings, + settings.listConversationsSettings(), + clientContext); + this.getConversationCallable = + callableFactory.createUnaryCallable( + getConversationTransportSettings, settings.getConversationSettings(), clientContext); + this.completeConversationCallable = + callableFactory.createUnaryCallable( + completeConversationTransportSettings, + settings.completeConversationSettings(), + clientContext); + this.batchCreateMessagesCallable = + callableFactory.createUnaryCallable( + batchCreateMessagesTransportSettings, + settings.batchCreateMessagesSettings(), + clientContext); + this.listMessagesCallable = + callableFactory.createUnaryCallable( + listMessagesTransportSettings, settings.listMessagesSettings(), clientContext); + this.listMessagesPagedCallable = + callableFactory.createPagedCallable( + listMessagesTransportSettings, settings.listMessagesSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createConversationMethodDescriptor); + methodDescriptors.add(listConversationsMethodDescriptor); + methodDescriptors.add(getConversationMethodDescriptor); + methodDescriptors.add(completeConversationMethodDescriptor); + methodDescriptors.add(batchCreateMessagesMethodDescriptor); + methodDescriptors.add(listMessagesMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createConversationCallable() { + return createConversationCallable; + } + + @Override + public UnaryCallable + listConversationsCallable() { + return listConversationsCallable; + } + + @Override + public UnaryCallable + listConversationsPagedCallable() { + return listConversationsPagedCallable; + } + + @Override + public UnaryCallable getConversationCallable() { + return getConversationCallable; + } + + @Override + public UnaryCallable completeConversationCallable() { + return completeConversationCallable; + } + + @Override + public UnaryCallable + batchCreateMessagesCallable() { + return batchCreateMessagesCallable; + } + + @Override + public UnaryCallable listMessagesCallable() { + return listMessagesCallable; + } + + @Override + public UnaryCallable listMessagesPagedCallable() { + return listMessagesPagedCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonDocumentsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonDocumentsCallableFactory.java new file mode 100644 index 000000000000..aa28ff6ae2be --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonDocumentsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Documents service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonDocumentsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonDocumentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonDocumentsStub.java new file mode 100644 index 000000000000..c374273783b3 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonDocumentsStub.java @@ -0,0 +1,647 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import static com.google.cloud.dialogflow.v2beta1.DocumentsClient.ListDocumentsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +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.v2beta1.CreateDocumentRequest; +import com.google.cloud.dialogflow.v2beta1.DeleteDocumentRequest; +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.GetDocumentRequest; +import com.google.cloud.dialogflow.v2beta1.ImportDocumentsRequest; +import com.google.cloud.dialogflow.v2beta1.ImportDocumentsResponse; +import com.google.cloud.dialogflow.v2beta1.KnowledgeOperationMetadata; +import com.google.cloud.dialogflow.v2beta1.ListDocumentsRequest; +import com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse; +import com.google.cloud.dialogflow.v2beta1.ReloadDocumentRequest; +import com.google.cloud.dialogflow.v2beta1.UpdateDocumentRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Documents service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonDocumentsStub extends DocumentsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ImportDocumentsResponse.getDescriptor()) + .add(Empty.getDescriptor()) + .add(Document.getDescriptor()) + .add(KnowledgeOperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Documents/ListDocuments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/knowledgeBases/*}/documents", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/knowledgeBases/*}/documents", + "/v2beta1/{parent=projects/*/agent/knowledgeBases/*}/documents") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDocumentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Documents/GetDocument") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/knowledgeBases/*/documents/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/knowledgeBases/*/documents/*}", + "/v2beta1/{name=projects/*/agent/knowledgeBases/*/documents/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Document.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Documents/CreateDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/knowledgeBases/*}/documents", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/knowledgeBases/*}/documents", + "/v2beta1/{parent=projects/*/agent/knowledgeBases/*}/documents") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, + "importGcsCustomMetadata", + request.getImportGcsCustomMetadata()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("document", request.getDocument())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateDocumentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Documents/ImportDocuments") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/knowledgeBases/*}/documents:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/knowledgeBases/*}/documents:import") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportDocumentsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Documents/DeleteDocument") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/knowledgeBases/*/documents/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/knowledgeBases/*/documents/*}", + "/v2beta1/{name=projects/*/agent/knowledgeBases/*/documents/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteDocumentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Documents/UpdateDocument") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{document.name=projects/*/knowledgeBases/*/documents/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "document.name", request.getDocument().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{document.name=projects/*/locations/*/knowledgeBases/*/documents/*}", + "/v2beta1/{document.name=projects/*/agent/knowledgeBases/*/documents/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("document", request.getDocument())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateDocumentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + reloadDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Documents/ReloadDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/knowledgeBases/*/documents/*}:reload", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/knowledgeBases/*/documents/*}:reload", + "/v2beta1/{name=projects/*/agent/knowledgeBases/*/documents/*}:reload") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ReloadDocumentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable listDocumentsCallable; + private final UnaryCallable + listDocumentsPagedCallable; + private final UnaryCallable getDocumentCallable; + private final UnaryCallable createDocumentCallable; + private final OperationCallable + createDocumentOperationCallable; + private final UnaryCallable importDocumentsCallable; + private final OperationCallable< + ImportDocumentsRequest, ImportDocumentsResponse, KnowledgeOperationMetadata> + importDocumentsOperationCallable; + private final UnaryCallable deleteDocumentCallable; + private final OperationCallable + deleteDocumentOperationCallable; + private final UnaryCallable updateDocumentCallable; + private final OperationCallable + updateDocumentOperationCallable; + private final UnaryCallable reloadDocumentCallable; + private final OperationCallable + reloadDocumentOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonDocumentsStub create(DocumentsStubSettings settings) + throws IOException { + return new HttpJsonDocumentsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonDocumentsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonDocumentsStub( + DocumentsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonDocumentsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonDocumentsStub( + DocumentsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonDocumentsStub, 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 HttpJsonDocumentsStub(DocumentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonDocumentsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonDocumentsStub, 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 HttpJsonDocumentsStub( + DocumentsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings reloadDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(reloadDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listDocumentsCallable = + callableFactory.createUnaryCallable( + listDocumentsTransportSettings, settings.listDocumentsSettings(), clientContext); + this.listDocumentsPagedCallable = + callableFactory.createPagedCallable( + listDocumentsTransportSettings, settings.listDocumentsSettings(), clientContext); + this.getDocumentCallable = + callableFactory.createUnaryCallable( + getDocumentTransportSettings, settings.getDocumentSettings(), clientContext); + this.createDocumentCallable = + callableFactory.createUnaryCallable( + createDocumentTransportSettings, settings.createDocumentSettings(), clientContext); + this.createDocumentOperationCallable = + callableFactory.createOperationCallable( + createDocumentTransportSettings, + settings.createDocumentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importDocumentsCallable = + callableFactory.createUnaryCallable( + importDocumentsTransportSettings, settings.importDocumentsSettings(), clientContext); + this.importDocumentsOperationCallable = + callableFactory.createOperationCallable( + importDocumentsTransportSettings, + settings.importDocumentsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteDocumentCallable = + callableFactory.createUnaryCallable( + deleteDocumentTransportSettings, settings.deleteDocumentSettings(), clientContext); + this.deleteDocumentOperationCallable = + callableFactory.createOperationCallable( + deleteDocumentTransportSettings, + settings.deleteDocumentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateDocumentCallable = + callableFactory.createUnaryCallable( + updateDocumentTransportSettings, settings.updateDocumentSettings(), clientContext); + this.updateDocumentOperationCallable = + callableFactory.createOperationCallable( + updateDocumentTransportSettings, + settings.updateDocumentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.reloadDocumentCallable = + callableFactory.createUnaryCallable( + reloadDocumentTransportSettings, settings.reloadDocumentSettings(), clientContext); + this.reloadDocumentOperationCallable = + callableFactory.createOperationCallable( + reloadDocumentTransportSettings, + settings.reloadDocumentOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listDocumentsMethodDescriptor); + methodDescriptors.add(getDocumentMethodDescriptor); + methodDescriptors.add(createDocumentMethodDescriptor); + methodDescriptors.add(importDocumentsMethodDescriptor); + methodDescriptors.add(deleteDocumentMethodDescriptor); + methodDescriptors.add(updateDocumentMethodDescriptor); + methodDescriptors.add(reloadDocumentMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listDocumentsCallable() { + return listDocumentsCallable; + } + + @Override + public UnaryCallable + listDocumentsPagedCallable() { + return listDocumentsPagedCallable; + } + + @Override + public UnaryCallable getDocumentCallable() { + return getDocumentCallable; + } + + @Override + public UnaryCallable createDocumentCallable() { + return createDocumentCallable; + } + + @Override + public OperationCallable + createDocumentOperationCallable() { + return createDocumentOperationCallable; + } + + @Override + public UnaryCallable importDocumentsCallable() { + return importDocumentsCallable; + } + + @Override + public OperationCallable< + ImportDocumentsRequest, ImportDocumentsResponse, KnowledgeOperationMetadata> + importDocumentsOperationCallable() { + return importDocumentsOperationCallable; + } + + @Override + public UnaryCallable deleteDocumentCallable() { + return deleteDocumentCallable; + } + + @Override + public OperationCallable + deleteDocumentOperationCallable() { + return deleteDocumentOperationCallable; + } + + @Override + public UnaryCallable updateDocumentCallable() { + return updateDocumentCallable; + } + + @Override + public OperationCallable + updateDocumentOperationCallable() { + return updateDocumentOperationCallable; + } + + @Override + public UnaryCallable reloadDocumentCallable() { + return reloadDocumentCallable; + } + + @Override + public OperationCallable + reloadDocumentOperationCallable() { + return reloadDocumentOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEntityTypesCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEntityTypesCallableFactory.java new file mode 100644 index 000000000000..cc90ebdbcdd1 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEntityTypesCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the EntityTypes service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonEntityTypesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEntityTypesStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEntityTypesStub.java new file mode 100644 index 000000000000..6c1b26592223 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEntityTypesStub.java @@ -0,0 +1,825 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import static com.google.cloud.dialogflow.v2beta1.EntityTypesClient.ListEntityTypesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +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.v2beta1.BatchCreateEntitiesRequest; +import com.google.cloud.dialogflow.v2beta1.BatchDeleteEntitiesRequest; +import com.google.cloud.dialogflow.v2beta1.BatchDeleteEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateEntitiesRequest; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateEntityTypesResponse; +import com.google.cloud.dialogflow.v2beta1.CreateEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.DeleteEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.GetEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.ListEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.ListEntityTypesResponse; +import com.google.cloud.dialogflow.v2beta1.UpdateEntityTypeRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the EntityTypes service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonEntityTypesStub extends EntityTypesStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(BatchUpdateEntityTypesResponse.getDescriptor()) + .add(Struct.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listEntityTypesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.EntityTypes/ListEntityTypes") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent}/entityTypes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/agent}/entityTypes") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListEntityTypesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.EntityTypes/GetEntityType") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/agent/entityTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/agent/entityTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(EntityType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.EntityTypes/CreateEntityType") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent}/entityTypes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/agent}/entityTypes") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("entityType", request.getEntityType())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(EntityType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.EntityTypes/UpdateEntityType") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{entityType.name=projects/*/agent/entityTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "entityType.name", request.getEntityType().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{entityType.name=projects/*/locations/*/agent/entityTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("entityType", request.getEntityType())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(EntityType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.EntityTypes/DeleteEntityType") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/agent/entityTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/agent/entityTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchUpdateEntityTypesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.EntityTypes/BatchUpdateEntityTypes") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent}/entityTypes:batchUpdate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/agent}/entityTypes:batchUpdate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchUpdateEntityTypesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + batchDeleteEntityTypesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.EntityTypes/BatchDeleteEntityTypes") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent}/entityTypes:batchDelete", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/agent}/entityTypes:batchDelete") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchDeleteEntityTypesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + batchCreateEntitiesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.EntityTypes/BatchCreateEntities") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent/entityTypes/*}/entities:batchCreate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/agent/entityTypes/*}/entities:batchCreate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchCreateEntitiesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + batchUpdateEntitiesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.EntityTypes/BatchUpdateEntities") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent/entityTypes/*}/entities:batchUpdate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/agent/entityTypes/*}/entities:batchUpdate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchUpdateEntitiesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + batchDeleteEntitiesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.EntityTypes/BatchDeleteEntities") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent/entityTypes/*}/entities:batchDelete", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/agent/entityTypes/*}/entities:batchDelete") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchDeleteEntitiesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + 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 BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonEntityTypesStub create(EntityTypesStubSettings settings) + throws IOException { + return new HttpJsonEntityTypesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonEntityTypesStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonEntityTypesStub( + EntityTypesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonEntityTypesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonEntityTypesStub( + EntityTypesStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonEntityTypesStub, 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 HttpJsonEntityTypesStub(EntityTypesStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonEntityTypesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonEntityTypesStub, 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 HttpJsonEntityTypesStub( + EntityTypesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listEntityTypesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listEntityTypesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchUpdateEntityTypesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchUpdateEntityTypesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchDeleteEntityTypesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchDeleteEntityTypesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchCreateEntitiesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchCreateEntitiesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchUpdateEntitiesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchUpdateEntitiesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchDeleteEntitiesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchDeleteEntitiesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .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, + httpJsonOperationsStub); + this.batchDeleteEntityTypesCallable = + callableFactory.createUnaryCallable( + batchDeleteEntityTypesTransportSettings, + settings.batchDeleteEntityTypesSettings(), + clientContext); + this.batchDeleteEntityTypesOperationCallable = + callableFactory.createOperationCallable( + batchDeleteEntityTypesTransportSettings, + settings.batchDeleteEntityTypesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.batchCreateEntitiesCallable = + callableFactory.createUnaryCallable( + batchCreateEntitiesTransportSettings, + settings.batchCreateEntitiesSettings(), + clientContext); + this.batchCreateEntitiesOperationCallable = + callableFactory.createOperationCallable( + batchCreateEntitiesTransportSettings, + settings.batchCreateEntitiesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.batchUpdateEntitiesCallable = + callableFactory.createUnaryCallable( + batchUpdateEntitiesTransportSettings, + settings.batchUpdateEntitiesSettings(), + clientContext); + this.batchUpdateEntitiesOperationCallable = + callableFactory.createOperationCallable( + batchUpdateEntitiesTransportSettings, + settings.batchUpdateEntitiesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.batchDeleteEntitiesCallable = + callableFactory.createUnaryCallable( + batchDeleteEntitiesTransportSettings, + settings.batchDeleteEntitiesSettings(), + clientContext); + this.batchDeleteEntitiesOperationCallable = + callableFactory.createOperationCallable( + batchDeleteEntitiesTransportSettings, + settings.batchDeleteEntitiesOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listEntityTypesMethodDescriptor); + methodDescriptors.add(getEntityTypeMethodDescriptor); + methodDescriptors.add(createEntityTypeMethodDescriptor); + methodDescriptors.add(updateEntityTypeMethodDescriptor); + methodDescriptors.add(deleteEntityTypeMethodDescriptor); + methodDescriptors.add(batchUpdateEntityTypesMethodDescriptor); + methodDescriptors.add(batchDeleteEntityTypesMethodDescriptor); + methodDescriptors.add(batchCreateEntitiesMethodDescriptor); + methodDescriptors.add(batchUpdateEntitiesMethodDescriptor); + methodDescriptors.add(batchDeleteEntitiesMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listEntityTypesCallable() { + return listEntityTypesCallable; + } + + @Override + public UnaryCallable + listEntityTypesPagedCallable() { + return listEntityTypesPagedCallable; + } + + @Override + public UnaryCallable getEntityTypeCallable() { + return getEntityTypeCallable; + } + + @Override + public UnaryCallable createEntityTypeCallable() { + return createEntityTypeCallable; + } + + @Override + public UnaryCallable updateEntityTypeCallable() { + return updateEntityTypeCallable; + } + + @Override + public UnaryCallable deleteEntityTypeCallable() { + return deleteEntityTypeCallable; + } + + @Override + public UnaryCallable batchUpdateEntityTypesCallable() { + return batchUpdateEntityTypesCallable; + } + + @Override + public OperationCallable + batchUpdateEntityTypesOperationCallable() { + return batchUpdateEntityTypesOperationCallable; + } + + @Override + public UnaryCallable batchDeleteEntityTypesCallable() { + return batchDeleteEntityTypesCallable; + } + + @Override + public OperationCallable + batchDeleteEntityTypesOperationCallable() { + return batchDeleteEntityTypesOperationCallable; + } + + @Override + public UnaryCallable batchCreateEntitiesCallable() { + return batchCreateEntitiesCallable; + } + + @Override + public OperationCallable + batchCreateEntitiesOperationCallable() { + return batchCreateEntitiesOperationCallable; + } + + @Override + public UnaryCallable batchUpdateEntitiesCallable() { + return batchUpdateEntitiesCallable; + } + + @Override + public OperationCallable + batchUpdateEntitiesOperationCallable() { + return batchUpdateEntitiesOperationCallable; + } + + @Override + public UnaryCallable batchDeleteEntitiesCallable() { + return batchDeleteEntitiesCallable; + } + + @Override + public OperationCallable + batchDeleteEntitiesOperationCallable() { + return batchDeleteEntitiesOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEnvironmentsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEnvironmentsCallableFactory.java new file mode 100644 index 000000000000..41f3cd5e88a5 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEnvironmentsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Environments service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonEnvironmentsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEnvironmentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEnvironmentsStub.java new file mode 100644 index 000000000000..f5c0c3becd3a --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonEnvironmentsStub.java @@ -0,0 +1,511 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import static com.google.cloud.dialogflow.v2beta1.EnvironmentsClient.GetEnvironmentHistoryPagedResponse; +import static com.google.cloud.dialogflow.v2beta1.EnvironmentsClient.ListEnvironmentsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2beta1.CreateEnvironmentRequest; +import com.google.cloud.dialogflow.v2beta1.DeleteEnvironmentRequest; +import com.google.cloud.dialogflow.v2beta1.Environment; +import com.google.cloud.dialogflow.v2beta1.EnvironmentHistory; +import com.google.cloud.dialogflow.v2beta1.GetEnvironmentHistoryRequest; +import com.google.cloud.dialogflow.v2beta1.GetEnvironmentRequest; +import com.google.cloud.dialogflow.v2beta1.ListEnvironmentsRequest; +import com.google.cloud.dialogflow.v2beta1.ListEnvironmentsResponse; +import com.google.cloud.dialogflow.v2beta1.UpdateEnvironmentRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Environments service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonEnvironmentsStub extends EnvironmentsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listEnvironmentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Environments/ListEnvironments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent}/environments", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/agent}/environments") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListEnvironmentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Environments/GetEnvironment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/agent/environments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/agent/environments/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Environment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Environments/CreateEnvironment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent}/environments", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/agent}/environments") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "environmentId", request.getEnvironmentId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("environment", request.getEnvironment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Environment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Environments/UpdateEnvironment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{environment.name=projects/*/agent/environments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "environment.name", request.getEnvironment().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{environment.name=projects/*/locations/*/agent/environments/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, + "allowLoadToDraftAndDiscardChanges", + request.getAllowLoadToDraftAndDiscardChanges()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("environment", request.getEnvironment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Environment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Environments/DeleteEnvironment") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/agent/environments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/agent/environments/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getEnvironmentHistoryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.Environments/GetEnvironmentHistory") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent/environments/*}/history", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/agent/environments/*}/history") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(EnvironmentHistory.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + listEnvironmentsCallable; + private final UnaryCallable + listEnvironmentsPagedCallable; + private final UnaryCallable getEnvironmentCallable; + private final UnaryCallable createEnvironmentCallable; + private final UnaryCallable updateEnvironmentCallable; + private final UnaryCallable deleteEnvironmentCallable; + private final UnaryCallable + getEnvironmentHistoryCallable; + private final UnaryCallable + getEnvironmentHistoryPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonEnvironmentsStub create(EnvironmentsStubSettings settings) + throws IOException { + return new HttpJsonEnvironmentsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonEnvironmentsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonEnvironmentsStub( + EnvironmentsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonEnvironmentsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonEnvironmentsStub( + EnvironmentsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonEnvironmentsStub, 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 HttpJsonEnvironmentsStub(EnvironmentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonEnvironmentsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonEnvironmentsStub, 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 HttpJsonEnvironmentsStub( + EnvironmentsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listEnvironmentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listEnvironmentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getEnvironmentHistoryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getEnvironmentHistoryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listEnvironmentsCallable = + callableFactory.createUnaryCallable( + listEnvironmentsTransportSettings, settings.listEnvironmentsSettings(), clientContext); + this.listEnvironmentsPagedCallable = + callableFactory.createPagedCallable( + listEnvironmentsTransportSettings, settings.listEnvironmentsSettings(), clientContext); + this.getEnvironmentCallable = + callableFactory.createUnaryCallable( + getEnvironmentTransportSettings, settings.getEnvironmentSettings(), clientContext); + this.createEnvironmentCallable = + callableFactory.createUnaryCallable( + createEnvironmentTransportSettings, + settings.createEnvironmentSettings(), + clientContext); + this.updateEnvironmentCallable = + callableFactory.createUnaryCallable( + updateEnvironmentTransportSettings, + settings.updateEnvironmentSettings(), + clientContext); + this.deleteEnvironmentCallable = + callableFactory.createUnaryCallable( + deleteEnvironmentTransportSettings, + settings.deleteEnvironmentSettings(), + clientContext); + this.getEnvironmentHistoryCallable = + callableFactory.createUnaryCallable( + getEnvironmentHistoryTransportSettings, + settings.getEnvironmentHistorySettings(), + clientContext); + this.getEnvironmentHistoryPagedCallable = + callableFactory.createPagedCallable( + getEnvironmentHistoryTransportSettings, + settings.getEnvironmentHistorySettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listEnvironmentsMethodDescriptor); + methodDescriptors.add(getEnvironmentMethodDescriptor); + methodDescriptors.add(createEnvironmentMethodDescriptor); + methodDescriptors.add(updateEnvironmentMethodDescriptor); + methodDescriptors.add(deleteEnvironmentMethodDescriptor); + methodDescriptors.add(getEnvironmentHistoryMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + listEnvironmentsCallable() { + return listEnvironmentsCallable; + } + + @Override + public UnaryCallable + listEnvironmentsPagedCallable() { + return listEnvironmentsPagedCallable; + } + + @Override + public UnaryCallable getEnvironmentCallable() { + return getEnvironmentCallable; + } + + @Override + public UnaryCallable createEnvironmentCallable() { + return createEnvironmentCallable; + } + + @Override + public UnaryCallable updateEnvironmentCallable() { + return updateEnvironmentCallable; + } + + @Override + public UnaryCallable deleteEnvironmentCallable() { + return deleteEnvironmentCallable; + } + + @Override + public UnaryCallable + getEnvironmentHistoryCallable() { + return getEnvironmentHistoryCallable; + } + + @Override + public UnaryCallable + getEnvironmentHistoryPagedCallable() { + return getEnvironmentHistoryPagedCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonFulfillmentsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonFulfillmentsCallableFactory.java new file mode 100644 index 000000000000..4fc0bf181a39 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonFulfillmentsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Fulfillments service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonFulfillmentsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonFulfillmentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonFulfillmentsStub.java new file mode 100644 index 000000000000..900ce9684515 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonFulfillmentsStub.java @@ -0,0 +1,251 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2beta1.Fulfillment; +import com.google.cloud.dialogflow.v2beta1.GetFulfillmentRequest; +import com.google.cloud.dialogflow.v2beta1.UpdateFulfillmentRequest; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Fulfillments service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonFulfillmentsStub extends FulfillmentsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + getFulfillmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Fulfillments/GetFulfillment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/agent/fulfillment}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/agent/fulfillment}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Fulfillment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateFulfillmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Fulfillments/UpdateFulfillment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{fulfillment.name=projects/*/agent/fulfillment}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "fulfillment.name", request.getFulfillment().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{fulfillment.name=projects/*/locations/*/agent/fulfillment}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("fulfillment", request.getFulfillment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Fulfillment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable getFulfillmentCallable; + private final UnaryCallable updateFulfillmentCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonFulfillmentsStub create(FulfillmentsStubSettings settings) + throws IOException { + return new HttpJsonFulfillmentsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonFulfillmentsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonFulfillmentsStub( + FulfillmentsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonFulfillmentsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonFulfillmentsStub( + FulfillmentsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonFulfillmentsStub, 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 HttpJsonFulfillmentsStub(FulfillmentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonFulfillmentsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonFulfillmentsStub, 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 HttpJsonFulfillmentsStub( + FulfillmentsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings getFulfillmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getFulfillmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateFulfillmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateFulfillmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.getFulfillmentCallable = + callableFactory.createUnaryCallable( + getFulfillmentTransportSettings, settings.getFulfillmentSettings(), clientContext); + this.updateFulfillmentCallable = + callableFactory.createUnaryCallable( + updateFulfillmentTransportSettings, + settings.updateFulfillmentSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(getFulfillmentMethodDescriptor); + methodDescriptors.add(updateFulfillmentMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable getFulfillmentCallable() { + return getFulfillmentCallable; + } + + @Override + public UnaryCallable updateFulfillmentCallable() { + return updateFulfillmentCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonIntentsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonIntentsCallableFactory.java new file mode 100644 index 000000000000..53e6fe714d9b --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonIntentsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Intents service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonIntentsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonIntentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonIntentsStub.java new file mode 100644 index 000000000000..2f4b7ff14f81 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonIntentsStub.java @@ -0,0 +1,589 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import static com.google.cloud.dialogflow.v2beta1.IntentsClient.ListIntentsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +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.v2beta1.BatchDeleteIntentsRequest; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsRequest; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2beta1.CreateIntentRequest; +import com.google.cloud.dialogflow.v2beta1.DeleteIntentRequest; +import com.google.cloud.dialogflow.v2beta1.GetIntentRequest; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.ListIntentsRequest; +import com.google.cloud.dialogflow.v2beta1.ListIntentsResponse; +import com.google.cloud.dialogflow.v2beta1.UpdateIntentRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Intents service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonIntentsStub extends IntentsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(BatchUpdateIntentsResponse.getDescriptor()) + .add(Struct.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listIntentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Intents/ListIntents") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent}/intents", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/agent}/intents", + "/v2beta1/{parent=projects/*/agent/environments/*}/intents", + "/v2beta1/{parent=projects/*/locations/*/agent/environments/*}/intents") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "intentView", request.getIntentView()); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListIntentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getIntentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Intents/GetIntent") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/agent/intents/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{name=projects/*/locations/*/agent/intents/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "intentView", request.getIntentView()); + serializer.putQueryParam(fields, "languageCode", request.getLanguageCode()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Intent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createIntentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Intents/CreateIntent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent}/intents", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*/agent}/intents") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "intentView", request.getIntentView()); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("intent", request.getIntent())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Intent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateIntentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Intents/UpdateIntent") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{intent.name=projects/*/agent/intents/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "intent.name", request.getIntent().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{intent.name=projects/*/locations/*/agent/intents/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "intentView", request.getIntentView()); + serializer.putQueryParam( + fields, "languageCode", request.getLanguageCode()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("intent", request.getIntent())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Intent.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteIntentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Intents/DeleteIntent") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/agent/intents/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{name=projects/*/locations/*/agent/intents/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchUpdateIntentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Intents/BatchUpdateIntents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent}/intents:batchUpdate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/agent}/intents:batchUpdate") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchUpdateIntentsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + batchDeleteIntentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Intents/BatchDeleteIntents") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent}/intents:batchDelete", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/agent}/intents:batchDelete") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchDeleteIntentsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + 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 BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonIntentsStub create(IntentsStubSettings settings) throws IOException { + return new HttpJsonIntentsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonIntentsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonIntentsStub(IntentsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonIntentsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonIntentsStub( + IntentsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonIntentsStub, 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 HttpJsonIntentsStub(IntentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonIntentsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonIntentsStub, 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 HttpJsonIntentsStub( + IntentsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings listIntentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listIntentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIntentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIntentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createIntentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createIntentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateIntentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateIntentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteIntentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteIntentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings batchUpdateIntentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchUpdateIntentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings batchDeleteIntentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchDeleteIntentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .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, + httpJsonOperationsStub); + this.batchDeleteIntentsCallable = + callableFactory.createUnaryCallable( + batchDeleteIntentsTransportSettings, + settings.batchDeleteIntentsSettings(), + clientContext); + this.batchDeleteIntentsOperationCallable = + callableFactory.createOperationCallable( + batchDeleteIntentsTransportSettings, + settings.batchDeleteIntentsOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listIntentsMethodDescriptor); + methodDescriptors.add(getIntentMethodDescriptor); + methodDescriptors.add(createIntentMethodDescriptor); + methodDescriptors.add(updateIntentMethodDescriptor); + methodDescriptors.add(deleteIntentMethodDescriptor); + methodDescriptors.add(batchUpdateIntentsMethodDescriptor); + methodDescriptors.add(batchDeleteIntentsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listIntentsCallable() { + return listIntentsCallable; + } + + @Override + public UnaryCallable listIntentsPagedCallable() { + return listIntentsPagedCallable; + } + + @Override + public UnaryCallable getIntentCallable() { + return getIntentCallable; + } + + @Override + public UnaryCallable createIntentCallable() { + return createIntentCallable; + } + + @Override + public UnaryCallable updateIntentCallable() { + return updateIntentCallable; + } + + @Override + public UnaryCallable deleteIntentCallable() { + return deleteIntentCallable; + } + + @Override + public UnaryCallable batchUpdateIntentsCallable() { + return batchUpdateIntentsCallable; + } + + @Override + public OperationCallable + batchUpdateIntentsOperationCallable() { + return batchUpdateIntentsOperationCallable; + } + + @Override + public UnaryCallable batchDeleteIntentsCallable() { + return batchDeleteIntentsCallable; + } + + @Override + public OperationCallable + batchDeleteIntentsOperationCallable() { + return batchDeleteIntentsOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonKnowledgeBasesCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonKnowledgeBasesCallableFactory.java new file mode 100644 index 000000000000..637685697aac --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonKnowledgeBasesCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the KnowledgeBases service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonKnowledgeBasesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonKnowledgeBasesStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonKnowledgeBasesStub.java new file mode 100644 index 000000000000..a6fa57342433 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonKnowledgeBasesStub.java @@ -0,0 +1,450 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import static com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2beta1.CreateKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2beta1.DeleteKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2beta1.GetKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.ListKnowledgeBasesRequest; +import com.google.cloud.dialogflow.v2beta1.ListKnowledgeBasesResponse; +import com.google.cloud.dialogflow.v2beta1.UpdateKnowledgeBaseRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the KnowledgeBases service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonKnowledgeBasesStub extends KnowledgeBasesStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listKnowledgeBasesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.KnowledgeBases/ListKnowledgeBases") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/knowledgeBases", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*}/knowledgeBases", + "/v2beta1/{parent=projects/*/agent}/knowledgeBases") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListKnowledgeBasesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getKnowledgeBaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.KnowledgeBases/GetKnowledgeBase") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/knowledgeBases/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/knowledgeBases/*}", + "/v2beta1/{name=projects/*/agent/knowledgeBases/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(KnowledgeBase.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createKnowledgeBaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.KnowledgeBases/CreateKnowledgeBase") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*}/knowledgeBases", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*}/knowledgeBases", + "/v2beta1/{parent=projects/*/agent}/knowledgeBases") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("knowledgeBase", request.getKnowledgeBase())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(KnowledgeBase.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteKnowledgeBaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.KnowledgeBases/DeleteKnowledgeBase") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/knowledgeBases/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/knowledgeBases/*}", + "/v2beta1/{name=projects/*/agent/knowledgeBases/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "force", request.getForce()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateKnowledgeBaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.KnowledgeBases/UpdateKnowledgeBase") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{knowledgeBase.name=projects/*/knowledgeBases/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "knowledgeBase.name", request.getKnowledgeBase().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{knowledgeBase.name=projects/*/locations/*/knowledgeBases/*}", + "/v2beta1/{knowledgeBase.name=projects/*/agent/knowledgeBases/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("knowledgeBase", request.getKnowledgeBase())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(KnowledgeBase.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + listKnowledgeBasesCallable; + private final UnaryCallable + listKnowledgeBasesPagedCallable; + private final UnaryCallable getKnowledgeBaseCallable; + private final UnaryCallable + createKnowledgeBaseCallable; + private final UnaryCallable deleteKnowledgeBaseCallable; + private final UnaryCallable + updateKnowledgeBaseCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonKnowledgeBasesStub create(KnowledgeBasesStubSettings settings) + throws IOException { + return new HttpJsonKnowledgeBasesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonKnowledgeBasesStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonKnowledgeBasesStub( + KnowledgeBasesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonKnowledgeBasesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonKnowledgeBasesStub( + KnowledgeBasesStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonKnowledgeBasesStub, 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 HttpJsonKnowledgeBasesStub( + KnowledgeBasesStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonKnowledgeBasesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonKnowledgeBasesStub, 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 HttpJsonKnowledgeBasesStub( + KnowledgeBasesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listKnowledgeBasesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listKnowledgeBasesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getKnowledgeBaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getKnowledgeBaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createKnowledgeBaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createKnowledgeBaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteKnowledgeBaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteKnowledgeBaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateKnowledgeBaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateKnowledgeBaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listKnowledgeBasesCallable = + callableFactory.createUnaryCallable( + listKnowledgeBasesTransportSettings, + settings.listKnowledgeBasesSettings(), + clientContext); + this.listKnowledgeBasesPagedCallable = + callableFactory.createPagedCallable( + listKnowledgeBasesTransportSettings, + settings.listKnowledgeBasesSettings(), + clientContext); + this.getKnowledgeBaseCallable = + callableFactory.createUnaryCallable( + getKnowledgeBaseTransportSettings, settings.getKnowledgeBaseSettings(), clientContext); + this.createKnowledgeBaseCallable = + callableFactory.createUnaryCallable( + createKnowledgeBaseTransportSettings, + settings.createKnowledgeBaseSettings(), + clientContext); + this.deleteKnowledgeBaseCallable = + callableFactory.createUnaryCallable( + deleteKnowledgeBaseTransportSettings, + settings.deleteKnowledgeBaseSettings(), + clientContext); + this.updateKnowledgeBaseCallable = + callableFactory.createUnaryCallable( + updateKnowledgeBaseTransportSettings, + settings.updateKnowledgeBaseSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listKnowledgeBasesMethodDescriptor); + methodDescriptors.add(getKnowledgeBaseMethodDescriptor); + methodDescriptors.add(createKnowledgeBaseMethodDescriptor); + methodDescriptors.add(deleteKnowledgeBaseMethodDescriptor); + methodDescriptors.add(updateKnowledgeBaseMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + listKnowledgeBasesCallable() { + return listKnowledgeBasesCallable; + } + + @Override + public UnaryCallable + listKnowledgeBasesPagedCallable() { + return listKnowledgeBasesPagedCallable; + } + + @Override + public UnaryCallable getKnowledgeBaseCallable() { + return getKnowledgeBaseCallable; + } + + @Override + public UnaryCallable createKnowledgeBaseCallable() { + return createKnowledgeBaseCallable; + } + + @Override + public UnaryCallable deleteKnowledgeBaseCallable() { + return deleteKnowledgeBaseCallable; + } + + @Override + public UnaryCallable updateKnowledgeBaseCallable() { + return updateKnowledgeBaseCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonParticipantsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonParticipantsCallableFactory.java new file mode 100644 index 000000000000..712e4844c3e3 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonParticipantsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Participants service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonParticipantsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonParticipantsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonParticipantsStub.java new file mode 100644 index 000000000000..0135b361446f --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonParticipantsStub.java @@ -0,0 +1,737 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import static com.google.cloud.dialogflow.v2beta1.ParticipantsClient.ListParticipantsPagedResponse; +import static com.google.cloud.dialogflow.v2beta1.ParticipantsClient.ListSuggestionsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2beta1.AnalyzeContentRequest; +import com.google.cloud.dialogflow.v2beta1.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2beta1.CompileSuggestionRequest; +import com.google.cloud.dialogflow.v2beta1.CompileSuggestionResponse; +import com.google.cloud.dialogflow.v2beta1.CreateParticipantRequest; +import com.google.cloud.dialogflow.v2beta1.GetParticipantRequest; +import com.google.cloud.dialogflow.v2beta1.ListParticipantsRequest; +import com.google.cloud.dialogflow.v2beta1.ListParticipantsResponse; +import com.google.cloud.dialogflow.v2beta1.ListSuggestionsRequest; +import com.google.cloud.dialogflow.v2beta1.ListSuggestionsResponse; +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.SuggestArticlesRequest; +import com.google.cloud.dialogflow.v2beta1.SuggestArticlesResponse; +import com.google.cloud.dialogflow.v2beta1.SuggestFaqAnswersRequest; +import com.google.cloud.dialogflow.v2beta1.SuggestFaqAnswersResponse; +import com.google.cloud.dialogflow.v2beta1.SuggestSmartRepliesRequest; +import com.google.cloud.dialogflow.v2beta1.SuggestSmartRepliesResponse; +import com.google.cloud.dialogflow.v2beta1.UpdateParticipantRequest; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Participants service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonParticipantsStub extends ParticipantsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createParticipantMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Participants/CreateParticipant") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/conversations/*}/participants", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/conversations/*}/participants") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("participant", request.getParticipant())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Participant.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getParticipantMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Participants/GetParticipant") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/conversations/*/participants/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/locations/*/conversations/*/participants/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Participant.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listParticipantsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Participants/ListParticipants") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/conversations/*}/participants", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/conversations/*}/participants") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListParticipantsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateParticipantMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Participants/UpdateParticipant") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{participant.name=projects/*/conversations/*/participants/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "participant.name", request.getParticipant().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{participant.name=projects/*/locations/*/conversations/*/participants/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("participant", request.getParticipant())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Participant.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + analyzeContentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Participants/AnalyzeContent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{participant=projects/*/conversations/*/participants/*}:analyzeContent", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "participant", request.getParticipant()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{participant=projects/*/locations/*/conversations/*/participants/*}:analyzeContent") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParticipant().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AnalyzeContentResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + suggestArticlesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Participants/SuggestArticles") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/conversations/*/participants/*}/suggestions:suggestArticles", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/conversations/*/participants/*}/suggestions:suggestArticles") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SuggestArticlesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + suggestFaqAnswersMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Participants/SuggestFaqAnswers") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/conversations/*/participants/*}/suggestions:suggestFaqAnswers", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/conversations/*/participants/*}/suggestions:suggestFaqAnswers") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SuggestFaqAnswersResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + suggestSmartRepliesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Participants/SuggestSmartReplies") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/conversations/*/participants/*}/suggestions:suggestSmartReplies", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/locations/*/conversations/*/participants/*}/suggestions:suggestSmartReplies") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SuggestSmartRepliesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listSuggestionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Participants/ListSuggestions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/conversations/*/participants/*}/suggestions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListSuggestionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + compileSuggestionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Participants/CompileSuggestion") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/conversations/*/participants/*}/suggestions:compile", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CompileSuggestionResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createParticipantCallable; + private final UnaryCallable getParticipantCallable; + private final UnaryCallable + listParticipantsCallable; + private final UnaryCallable + listParticipantsPagedCallable; + private final UnaryCallable updateParticipantCallable; + private final UnaryCallable analyzeContentCallable; + private final UnaryCallable + suggestArticlesCallable; + private final UnaryCallable + suggestFaqAnswersCallable; + private final UnaryCallable + suggestSmartRepliesCallable; + private final UnaryCallable + listSuggestionsCallable; + private final UnaryCallable + listSuggestionsPagedCallable; + private final UnaryCallable + compileSuggestionCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonParticipantsStub create(ParticipantsStubSettings settings) + throws IOException { + return new HttpJsonParticipantsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonParticipantsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonParticipantsStub( + ParticipantsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonParticipantsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonParticipantsStub( + ParticipantsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonParticipantsStub, 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 HttpJsonParticipantsStub(ParticipantsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonParticipantsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonParticipantsStub, 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 HttpJsonParticipantsStub( + ParticipantsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createParticipantTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createParticipantMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getParticipantTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getParticipantMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listParticipantsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listParticipantsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateParticipantTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateParticipantMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + analyzeContentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(analyzeContentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + suggestArticlesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(suggestArticlesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + suggestFaqAnswersTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(suggestFaqAnswersMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + suggestSmartRepliesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(suggestSmartRepliesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listSuggestionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listSuggestionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + compileSuggestionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(compileSuggestionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createParticipantCallable = + callableFactory.createUnaryCallable( + createParticipantTransportSettings, + settings.createParticipantSettings(), + clientContext); + this.getParticipantCallable = + callableFactory.createUnaryCallable( + getParticipantTransportSettings, settings.getParticipantSettings(), clientContext); + this.listParticipantsCallable = + callableFactory.createUnaryCallable( + listParticipantsTransportSettings, settings.listParticipantsSettings(), clientContext); + this.listParticipantsPagedCallable = + callableFactory.createPagedCallable( + listParticipantsTransportSettings, settings.listParticipantsSettings(), clientContext); + this.updateParticipantCallable = + callableFactory.createUnaryCallable( + updateParticipantTransportSettings, + settings.updateParticipantSettings(), + clientContext); + this.analyzeContentCallable = + callableFactory.createUnaryCallable( + analyzeContentTransportSettings, settings.analyzeContentSettings(), clientContext); + this.suggestArticlesCallable = + callableFactory.createUnaryCallable( + suggestArticlesTransportSettings, settings.suggestArticlesSettings(), clientContext); + this.suggestFaqAnswersCallable = + callableFactory.createUnaryCallable( + suggestFaqAnswersTransportSettings, + settings.suggestFaqAnswersSettings(), + clientContext); + this.suggestSmartRepliesCallable = + callableFactory.createUnaryCallable( + suggestSmartRepliesTransportSettings, + settings.suggestSmartRepliesSettings(), + clientContext); + this.listSuggestionsCallable = + callableFactory.createUnaryCallable( + listSuggestionsTransportSettings, settings.listSuggestionsSettings(), clientContext); + this.listSuggestionsPagedCallable = + callableFactory.createPagedCallable( + listSuggestionsTransportSettings, settings.listSuggestionsSettings(), clientContext); + this.compileSuggestionCallable = + callableFactory.createUnaryCallable( + compileSuggestionTransportSettings, + settings.compileSuggestionSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createParticipantMethodDescriptor); + methodDescriptors.add(getParticipantMethodDescriptor); + methodDescriptors.add(listParticipantsMethodDescriptor); + methodDescriptors.add(updateParticipantMethodDescriptor); + methodDescriptors.add(analyzeContentMethodDescriptor); + methodDescriptors.add(suggestArticlesMethodDescriptor); + methodDescriptors.add(suggestFaqAnswersMethodDescriptor); + methodDescriptors.add(suggestSmartRepliesMethodDescriptor); + methodDescriptors.add(listSuggestionsMethodDescriptor); + methodDescriptors.add(compileSuggestionMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createParticipantCallable() { + return createParticipantCallable; + } + + @Override + public UnaryCallable getParticipantCallable() { + return getParticipantCallable; + } + + @Override + public UnaryCallable + listParticipantsCallable() { + return listParticipantsCallable; + } + + @Override + public UnaryCallable + listParticipantsPagedCallable() { + return listParticipantsPagedCallable; + } + + @Override + public UnaryCallable updateParticipantCallable() { + return updateParticipantCallable; + } + + @Override + public UnaryCallable analyzeContentCallable() { + return analyzeContentCallable; + } + + @Override + public UnaryCallable suggestArticlesCallable() { + return suggestArticlesCallable; + } + + @Override + public UnaryCallable + suggestFaqAnswersCallable() { + return suggestFaqAnswersCallable; + } + + @Override + public UnaryCallable + suggestSmartRepliesCallable() { + return suggestSmartRepliesCallable; + } + + @Override + public UnaryCallable listSuggestionsCallable() { + return listSuggestionsCallable; + } + + @Override + public UnaryCallable + listSuggestionsPagedCallable() { + return listSuggestionsPagedCallable; + } + + @Override + public UnaryCallable + compileSuggestionCallable() { + return compileSuggestionCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionEntityTypesCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionEntityTypesCallableFactory.java new file mode 100644 index 000000000000..e3ce4459b596 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionEntityTypesCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the SessionEntityTypes service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSessionEntityTypesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionEntityTypesStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionEntityTypesStub.java new file mode 100644 index 000000000000..834e864df950 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionEntityTypesStub.java @@ -0,0 +1,470 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import static com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient.ListSessionEntityTypesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2beta1.CreateSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.DeleteSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.GetSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.ListSessionEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.ListSessionEntityTypesResponse; +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.UpdateSessionEntityTypeRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the SessionEntityTypes service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSessionEntityTypesStub extends SessionEntityTypesStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse> + listSessionEntityTypesMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.SessionEntityTypes/ListSessionEntityTypes") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent/sessions/*}/entityTypes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/agent/environments/*/users/*/sessions/*}/entityTypes", + "/v2beta1/{parent=projects/*/locations/*/agent/sessions/*}/entityTypes", + "/v2beta1/{parent=projects/*/locations/*/agent/environments/*/users/*/sessions/*}/entityTypes") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListSessionEntityTypesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getSessionEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.SessionEntityTypes/GetSessionEntityType") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/agent/sessions/*/entityTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/agent/environments/*/users/*/sessions/*/entityTypes/*}", + "/v2beta1/{name=projects/*/locations/*/agent/sessions/*/entityTypes/*}", + "/v2beta1/{name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/entityTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SessionEntityType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createSessionEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.SessionEntityTypes/CreateSessionEntityType") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent/sessions/*}/entityTypes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{parent=projects/*/agent/environments/*/users/*/sessions/*}/entityTypes", + "/v2beta1/{parent=projects/*/locations/*/agent/sessions/*}/entityTypes", + "/v2beta1/{parent=projects/*/locations/*/agent/environments/*/users/*/sessions/*}/entityTypes") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("sessionEntityType", request.getSessionEntityType())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SessionEntityType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateSessionEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.SessionEntityTypes/UpdateSessionEntityType") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{sessionEntityType.name=projects/*/agent/sessions/*/entityTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "sessionEntityType.name", + request.getSessionEntityType().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{sessionEntityType.name=projects/*/agent/environments/*/users/*/sessions/*/entityTypes/*}", + "/v2beta1/{sessionEntityType.name=projects/*/locations/*/agent/sessions/*/entityTypes/*}", + "/v2beta1/{sessionEntityType.name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/entityTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("sessionEntityType", request.getSessionEntityType())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SessionEntityType.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteSessionEntityTypeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.dialogflow.v2beta1.SessionEntityTypes/DeleteSessionEntityType") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/agent/sessions/*/entityTypes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{name=projects/*/agent/environments/*/users/*/sessions/*/entityTypes/*}", + "/v2beta1/{name=projects/*/locations/*/agent/sessions/*/entityTypes/*}", + "/v2beta1/{name=projects/*/locations/*/agent/environments/*/users/*/sessions/*/entityTypes/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + 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 BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSessionEntityTypesStub create(SessionEntityTypesStubSettings settings) + throws IOException { + return new HttpJsonSessionEntityTypesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSessionEntityTypesStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSessionEntityTypesStub( + SessionEntityTypesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSessionEntityTypesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSessionEntityTypesStub( + SessionEntityTypesStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonSessionEntityTypesStub, 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 HttpJsonSessionEntityTypesStub( + SessionEntityTypesStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonSessionEntityTypesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSessionEntityTypesStub, 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 HttpJsonSessionEntityTypesStub( + SessionEntityTypesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listSessionEntityTypesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listSessionEntityTypesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getSessionEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getSessionEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createSessionEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createSessionEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateSessionEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateSessionEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteSessionEntityTypeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteSessionEntityTypeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .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); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listSessionEntityTypesMethodDescriptor); + methodDescriptors.add(getSessionEntityTypeMethodDescriptor); + methodDescriptors.add(createSessionEntityTypeMethodDescriptor); + methodDescriptors.add(updateSessionEntityTypeMethodDescriptor); + methodDescriptors.add(deleteSessionEntityTypeMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + listSessionEntityTypesCallable() { + return listSessionEntityTypesCallable; + } + + @Override + public UnaryCallable + listSessionEntityTypesPagedCallable() { + return listSessionEntityTypesPagedCallable; + } + + @Override + public UnaryCallable + getSessionEntityTypeCallable() { + return getSessionEntityTypeCallable; + } + + @Override + public UnaryCallable + createSessionEntityTypeCallable() { + return createSessionEntityTypeCallable; + } + + @Override + public UnaryCallable + updateSessionEntityTypeCallable() { + return updateSessionEntityTypeCallable; + } + + @Override + public UnaryCallable deleteSessionEntityTypeCallable() { + return deleteSessionEntityTypeCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionsCallableFactory.java new file mode 100644 index 000000000000..ff245e11e231 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Sessions service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSessionsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionsStub.java new file mode 100644 index 000000000000..89cc28f751d5 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonSessionsStub.java @@ -0,0 +1,197 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2beta1.DetectIntentRequest; +import com.google.cloud.dialogflow.v2beta1.DetectIntentResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Sessions service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSessionsStub extends SessionsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + detectIntentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Sessions/DetectIntent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{session=projects/*/agent/sessions/*}:detectIntent", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "session", request.getSession()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{session=projects/*/agent/environments/*/users/*/sessions/*}:detectIntent", + "/v2beta1/{session=projects/*/locations/*/agent/sessions/*}:detectIntent", + "/v2beta1/{session=projects/*/locations/*/agent/environments/*/users/*/sessions/*}:detectIntent") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearSession().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DetectIntentResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable detectIntentCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSessionsStub create(SessionsStubSettings settings) + throws IOException { + return new HttpJsonSessionsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSessionsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonSessionsStub( + SessionsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSessionsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSessionsStub( + SessionsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSessionsStub, 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 HttpJsonSessionsStub(SessionsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonSessionsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSessionsStub, 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 HttpJsonSessionsStub( + SessionsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings detectIntentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(detectIntentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.detectIntentCallable = + callableFactory.createUnaryCallable( + detectIntentTransportSettings, settings.detectIntentSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(detectIntentMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable detectIntentCallable() { + return detectIntentCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonVersionsCallableFactory.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonVersionsCallableFactory.java new file mode 100644 index 000000000000..437a5caf4dd1 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonVersionsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Versions service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonVersionsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonVersionsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonVersionsStub.java new file mode 100644 index 000000000000..d097595f4e47 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/HttpJsonVersionsStub.java @@ -0,0 +1,413 @@ +/* + * Copyright 2022 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.v2beta1.stub; + +import static com.google.cloud.dialogflow.v2beta1.VersionsClient.ListVersionsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2beta1.CreateVersionRequest; +import com.google.cloud.dialogflow.v2beta1.DeleteVersionRequest; +import com.google.cloud.dialogflow.v2beta1.GetVersionRequest; +import com.google.cloud.dialogflow.v2beta1.ListVersionsRequest; +import com.google.cloud.dialogflow.v2beta1.ListVersionsResponse; +import com.google.cloud.dialogflow.v2beta1.UpdateVersionRequest; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Versions service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonVersionsStub extends VersionsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listVersionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Versions/ListVersions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent}/versions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*/agent}/versions") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListVersionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getVersionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Versions/GetVersion") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/agent/versions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{name=projects/*/locations/*/agent/versions/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Version.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createVersionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Versions/CreateVersion") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{parent=projects/*/agent}/versions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{parent=projects/*/locations/*/agent}/versions") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("version", request.getVersion())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Version.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateVersionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Versions/UpdateVersion") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{version.name=projects/*/agent/versions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "version.name", request.getVersion().getName()); + return fields; + }) + .setAdditionalPaths( + "/v2beta1/{version.name=projects/*/locations/*/agent/versions/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("version", request.getVersion())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Version.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteVersionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.dialogflow.v2beta1.Versions/DeleteVersion") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta1/{name=projects/*/agent/versions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths("/v2beta1/{name=projects/*/locations/*/agent/versions/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listVersionsCallable; + private final UnaryCallable + listVersionsPagedCallable; + private final UnaryCallable getVersionCallable; + private final UnaryCallable createVersionCallable; + private final UnaryCallable updateVersionCallable; + private final UnaryCallable deleteVersionCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonVersionsStub create(VersionsStubSettings settings) + throws IOException { + return new HttpJsonVersionsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonVersionsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonVersionsStub( + VersionsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonVersionsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonVersionsStub( + VersionsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonVersionsStub, 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 HttpJsonVersionsStub(VersionsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonVersionsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonVersionsStub, 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 HttpJsonVersionsStub( + VersionsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listVersionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listVersionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getVersionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getVersionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createVersionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createVersionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateVersionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateVersionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteVersionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteVersionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listVersionsCallable = + callableFactory.createUnaryCallable( + listVersionsTransportSettings, settings.listVersionsSettings(), clientContext); + this.listVersionsPagedCallable = + callableFactory.createPagedCallable( + listVersionsTransportSettings, settings.listVersionsSettings(), clientContext); + this.getVersionCallable = + callableFactory.createUnaryCallable( + getVersionTransportSettings, settings.getVersionSettings(), clientContext); + this.createVersionCallable = + callableFactory.createUnaryCallable( + createVersionTransportSettings, settings.createVersionSettings(), clientContext); + this.updateVersionCallable = + callableFactory.createUnaryCallable( + updateVersionTransportSettings, settings.updateVersionSettings(), clientContext); + this.deleteVersionCallable = + callableFactory.createUnaryCallable( + deleteVersionTransportSettings, settings.deleteVersionSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listVersionsMethodDescriptor); + methodDescriptors.add(getVersionMethodDescriptor); + methodDescriptors.add(createVersionMethodDescriptor); + methodDescriptors.add(updateVersionMethodDescriptor); + methodDescriptors.add(deleteVersionMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listVersionsCallable() { + return listVersionsCallable; + } + + @Override + public UnaryCallable listVersionsPagedCallable() { + return listVersionsPagedCallable; + } + + @Override + public UnaryCallable getVersionCallable() { + return getVersionCallable; + } + + @Override + public UnaryCallable createVersionCallable() { + return createVersionCallable; + } + + @Override + public UnaryCallable updateVersionCallable() { + return updateVersionCallable; + } + + @Override + public UnaryCallable deleteVersionCallable() { + return deleteVersionCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStub.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStub.java index 3499829bd55c..599de90f1ee0 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStub.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStub.java @@ -49,7 +49,11 @@ public abstract class IntentsStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable listIntentsPagedCallable() { diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStubSettings.java index 3b3b2a2dc3ce..bc3ea13a0b2f 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -229,6 +232,11 @@ public IntentsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcIntentsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonIntentsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -261,29 +269,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(IntentsStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(IntentsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return IntentsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -428,6 +461,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listIntentsSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/KnowledgeBasesStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/KnowledgeBasesStubSettings.java index 484cc531016d..291187036965 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/KnowledgeBasesStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/KnowledgeBasesStubSettings.java @@ -27,6 +27,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -207,6 +210,11 @@ public KnowledgeBasesStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcKnowledgeBasesStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonKnowledgeBasesStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -239,18 +247,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(KnowledgeBasesStubSettings.class)) @@ -258,11 +273,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(KnowledgeBasesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return KnowledgeBasesStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -382,6 +416,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listKnowledgeBasesSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ParticipantsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ParticipantsStubSettings.java index 2781bb10e5d3..bcfec466a000 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ParticipantsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ParticipantsStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -334,6 +337,11 @@ public ParticipantsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcParticipantsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonParticipantsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -366,18 +374,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ParticipantsStubSettings.class)) @@ -385,11 +400,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ParticipantsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ParticipantsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -575,6 +609,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createParticipantSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionEntityTypesStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionEntityTypesStubSettings.java index 9012b9e86db0..d0d7fae9e661 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionEntityTypesStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionEntityTypesStubSettings.java @@ -27,6 +27,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -225,6 +228,11 @@ public SessionEntityTypesStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSessionEntityTypesStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSessionEntityTypesStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -257,18 +265,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(SessionEntityTypesStubSettings.class)) @@ -276,11 +291,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(SessionEntityTypesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SessionEntityTypesStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -404,6 +438,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listSessionEntityTypesSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionsStubSettings.java index 18b4a867702e..bc8303ccd044 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionsStubSettings.java @@ -24,6 +24,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -109,6 +112,11 @@ public SessionsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSessionsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSessionsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -141,29 +149,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(SessionsStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(SessionsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SessionsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -268,6 +301,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .detectIntentSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/VersionsStubSettings.java b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/VersionsStubSettings.java index 0b8eaf3859b6..2ef329644dc2 100644 --- a/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/VersionsStubSettings.java +++ b/java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/VersionsStubSettings.java @@ -27,6 +27,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -193,6 +196,11 @@ public VersionsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcVersionsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonVersionsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -225,29 +233,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(VersionsStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(VersionsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return VersionsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -363,6 +396,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listVersionsSettings() diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/AgentsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/AgentsClientHttpJsonTest.java new file mode 100644 index 000000000000..cf00bff089df --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/AgentsClientHttpJsonTest.java @@ -0,0 +1,1002 @@ +/* + * Copyright 2022 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonAgentsStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class AgentsClientHttpJsonTest { + private static MockHttpService mockService; + private static AgentsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonAgentsStub.getMethodDescriptors(), AgentsSettings.getDefaultEndpoint()); + AgentsSettings settings = + AgentsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + AgentsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = AgentsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void getAgentTest() throws Exception { + Agent expectedResponse = + Agent.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setDefaultLanguageCode("defaultLanguageCode2069633606") + .addAllSupportedLanguageCodes(new ArrayList()) + .setTimeZone("timeZone-2077180903") + .setDescription("description-1724546052") + .setAvatarUri("avatarUri-428646061") + .setEnableLogging(true) + .setClassificationThreshold(1115810642) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + Agent actualResponse = client.getAgent(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.getAgent(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAgentTest2() throws Exception { + Agent expectedResponse = + Agent.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setDefaultLanguageCode("defaultLanguageCode2069633606") + .addAllSupportedLanguageCodes(new ArrayList()) + .setTimeZone("timeZone-2077180903") + .setDescription("description-1724546052") + .setAvatarUri("avatarUri-428646061") + .setEnableLogging(true) + .setClassificationThreshold(1115810642) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + Agent actualResponse = client.getAgent(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getAgentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.getAgent(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAgentTest3() throws Exception { + Agent expectedResponse = + Agent.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setDefaultLanguageCode("defaultLanguageCode2069633606") + .addAllSupportedLanguageCodes(new ArrayList()) + .setTimeZone("timeZone-2077180903") + .setDescription("description-1724546052") + .setAvatarUri("avatarUri-428646061") + .setEnableLogging(true) + .setClassificationThreshold(1115810642) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + Agent actualResponse = client.getAgent(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getAgentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.getAgent(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setAgentTest() throws Exception { + Agent expectedResponse = + Agent.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setDefaultLanguageCode("defaultLanguageCode2069633606") + .addAllSupportedLanguageCodes(new ArrayList()) + .setTimeZone("timeZone-2077180903") + .setDescription("description-1724546052") + .setAvatarUri("avatarUri-428646061") + .setEnableLogging(true) + .setClassificationThreshold(1115810642) + .build(); + mockService.addResponse(expectedResponse); + + Agent agent = + Agent.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setDefaultLanguageCode("defaultLanguageCode2069633606") + .addAllSupportedLanguageCodes(new ArrayList()) + .setTimeZone("timeZone-2077180903") + .setDescription("description-1724546052") + .setAvatarUri("avatarUri-428646061") + .setEnableLogging(true) + .setClassificationThreshold(1115810642) + .build(); + + Agent actualResponse = client.setAgent(agent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Agent agent = + Agent.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setDefaultLanguageCode("defaultLanguageCode2069633606") + .addAllSupportedLanguageCodes(new ArrayList()) + .setTimeZone("timeZone-2077180903") + .setDescription("description-1724546052") + .setAvatarUri("avatarUri-428646061") + .setEnableLogging(true) + .setClassificationThreshold(1115810642) + .build(); + client.setAgent(agent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteAgentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + client.deleteAgent(parent); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.deleteAgent(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteAgentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + client.deleteAgent(parent); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteAgentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.deleteAgent(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteAgentTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + client.deleteAgent(parent); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteAgentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.deleteAgent(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void searchAgentsTest() throws Exception { + Agent responsesElement = Agent.newBuilder().build(); + SearchAgentsResponse expectedResponse = + SearchAgentsResponse.newBuilder() + .setNextPageToken("") + .addAllAgents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void searchAgentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.searchAgents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void searchAgentsTest2() throws Exception { + Agent responsesElement = Agent.newBuilder().build(); + SearchAgentsResponse expectedResponse = + SearchAgentsResponse.newBuilder() + .setNextPageToken("") + .addAllAgents(Arrays.asList(responsesElement)) + .build(); + mockService.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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void searchAgentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.searchAgents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void searchAgentsTest3() throws Exception { + Agent responsesElement = Agent.newBuilder().build(); + SearchAgentsResponse expectedResponse = + SearchAgentsResponse.newBuilder() + .setNextPageToken("") + .addAllAgents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void searchAgentsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.searchAgents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void trainAgentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("trainAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + client.trainAgentAsync(parent).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void trainAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.trainAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void trainAgentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("trainAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + client.trainAgentAsync(parent).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void trainAgentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.trainAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void trainAgentTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("trainAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2353"; + + client.trainAgentAsync(parent).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void trainAgentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.trainAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportAgentTest() throws Exception { + ExportAgentResponse expectedResponse = ExportAgentResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ExportAgentResponse actualResponse = client.exportAgentAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void exportAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.exportAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportAgentTest2() throws Exception { + ExportAgentResponse expectedResponse = ExportAgentResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ExportAgentResponse actualResponse = client.exportAgentAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void exportAgentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.exportAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportAgentTest3() throws Exception { + ExportAgentResponse expectedResponse = ExportAgentResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2353"; + + ExportAgentResponse actualResponse = client.exportAgentAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void exportAgentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.exportAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importAgentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportAgentRequest request = + ImportAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + + client.importAgentAsync(request).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportAgentRequest request = + ImportAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + client.importAgentAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void restoreAgentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("restoreAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RestoreAgentRequest request = + RestoreAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + + client.restoreAgentAsync(request).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void restoreAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestoreAgentRequest request = + RestoreAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .build(); + client.restoreAgentAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getValidationResultTest() throws Exception { + ValidationResult expectedResponse = + ValidationResult.newBuilder() + .addAllValidationErrors(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + GetValidationResultRequest request = + GetValidationResultRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .build(); + + ValidationResult actualResponse = client.getValidationResult(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getValidationResultExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetValidationResultRequest request = + GetValidationResultRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .build(); + client.getValidationResult(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/AnswerRecordsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/AnswerRecordsClientHttpJsonTest.java new file mode 100644 index 000000000000..6ef2b4865dc1 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/AnswerRecordsClientHttpJsonTest.java @@ -0,0 +1,289 @@ +/* + * Copyright 2022 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.AnswerRecordsClient.ListAnswerRecordsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonAnswerRecordsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class AnswerRecordsClientHttpJsonTest { + private static MockHttpService mockService; + private static AnswerRecordsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonAnswerRecordsStub.getMethodDescriptors(), + AnswerRecordsSettings.getDefaultEndpoint()); + AnswerRecordsSettings settings = + AnswerRecordsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + AnswerRecordsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = AnswerRecordsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listAnswerRecordsTest() throws Exception { + AnswerRecord responsesElement = AnswerRecord.newBuilder().build(); + ListAnswerRecordsResponse expectedResponse = + ListAnswerRecordsResponse.newBuilder() + .setNextPageToken("") + .addAllAnswerRecords(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListAnswerRecordsPagedResponse pagedListResponse = client.listAnswerRecords(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getAnswerRecordsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAnswerRecordsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listAnswerRecords(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAnswerRecordsTest2() throws Exception { + AnswerRecord responsesElement = AnswerRecord.newBuilder().build(); + ListAnswerRecordsResponse expectedResponse = + ListAnswerRecordsResponse.newBuilder() + .setNextPageToken("") + .addAllAnswerRecords(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListAnswerRecordsPagedResponse pagedListResponse = client.listAnswerRecords(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getAnswerRecordsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAnswerRecordsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listAnswerRecords(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAnswerRecordsTest3() throws Exception { + AnswerRecord responsesElement = AnswerRecord.newBuilder().build(); + ListAnswerRecordsResponse expectedResponse = + ListAnswerRecordsResponse.newBuilder() + .setNextPageToken("") + .addAllAnswerRecords(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListAnswerRecordsPagedResponse pagedListResponse = client.listAnswerRecords(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getAnswerRecordsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAnswerRecordsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listAnswerRecords(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateAnswerRecordTest() throws Exception { + AnswerRecord expectedResponse = + AnswerRecord.newBuilder() + .setName( + AnswerRecordName.ofProjectAnswerRecordName("[PROJECT]", "[ANSWER_RECORD]") + .toString()) + .setAnswerFeedback(AnswerFeedback.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + AnswerRecord answerRecord = + AnswerRecord.newBuilder() + .setName( + AnswerRecordName.ofProjectAnswerRecordName("[PROJECT]", "[ANSWER_RECORD]") + .toString()) + .setAnswerFeedback(AnswerFeedback.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + AnswerRecord actualResponse = client.updateAnswerRecord(answerRecord, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateAnswerRecordExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AnswerRecord answerRecord = + AnswerRecord.newBuilder() + .setName( + AnswerRecordName.ofProjectAnswerRecordName("[PROJECT]", "[ANSWER_RECORD]") + .toString()) + .setAnswerFeedback(AnswerFeedback.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateAnswerRecord(answerRecord, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ContextsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ContextsClientHttpJsonTest.java new file mode 100644 index 000000000000..dff62b938f5c --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ContextsClientHttpJsonTest.java @@ -0,0 +1,603 @@ +/* + * Copyright 2022 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonContextsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ContextsClientHttpJsonTest { + private static MockHttpService mockService; + private static ContextsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonContextsStub.getMethodDescriptors(), ContextsSettings.getDefaultEndpoint()); + ContextsSettings settings = + ContextsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ContextsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ContextsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listContextsTest() throws Exception { + Context responsesElement = Context.newBuilder().build(); + ListContextsResponse expectedResponse = + ListContextsResponse.newBuilder() + .setNextPageToken("") + .addAllContexts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SessionName parent = SessionName.ofProjectSessionName("[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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listContextsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + client.listContexts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listContextsTest2() throws Exception { + Context responsesElement = Context.newBuilder().build(); + ListContextsResponse expectedResponse = + ListContextsResponse.newBuilder() + .setNextPageToken("") + .addAllContexts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6494/agent/sessions/session-6494"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listContextsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6494/agent/sessions/session-6494"; + client.listContexts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getContextTest() throws Exception { + Context expectedResponse = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ContextName name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"); + + Context actualResponse = client.getContext(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getContextExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ContextName name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"); + client.getContext(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getContextTest2() throws Exception { + Context expectedResponse = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-8115/agent/sessions/session-8115/contexts/context-8115"; + + Context actualResponse = client.getContext(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getContextExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-8115/agent/sessions/session-8115/contexts/context-8115"; + client.getContext(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createContextTest() throws Exception { + Context expectedResponse = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + Context context = Context.newBuilder().build(); + + Context actualResponse = client.createContext(parent, context); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createContextExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + Context context = Context.newBuilder().build(); + client.createContext(parent, context); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createContextTest2() throws Exception { + Context expectedResponse = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6494/agent/sessions/session-6494"; + Context context = Context.newBuilder().build(); + + Context actualResponse = client.createContext(parent, context); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createContextExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6494/agent/sessions/session-6494"; + Context context = Context.newBuilder().build(); + client.createContext(parent, context); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateContextTest() throws Exception { + Context expectedResponse = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Context context = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Context actualResponse = client.updateContext(context, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateContextExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Context context = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateContext(context, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteContextTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ContextName name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"); + + client.deleteContext(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteContextExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ContextName name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"); + client.deleteContext(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteContextTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-8115/agent/sessions/session-8115/contexts/context-8115"; + + client.deleteContext(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteContextExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-8115/agent/sessions/session-8115/contexts/context-8115"; + client.deleteContext(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteAllContextsTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + + client.deleteAllContexts(parent); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteAllContextsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + client.deleteAllContexts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteAllContextsTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6494/agent/sessions/session-6494"; + + client.deleteAllContexts(parent); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteAllContextsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6494/agent/sessions/session-6494"; + client.deleteAllContexts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationDatasetsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationDatasetsClientHttpJsonTest.java new file mode 100644 index 000000000000..a0b2498d2a4b --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationDatasetsClientHttpJsonTest.java @@ -0,0 +1,509 @@ +/* + * Copyright 2022 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.ConversationDatasetsClient.ListConversationDatasetsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonConversationDatasetsStub; +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.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ConversationDatasetsClientHttpJsonTest { + private static MockHttpService mockService; + private static ConversationDatasetsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonConversationDatasetsStub.getMethodDescriptors(), + ConversationDatasetsSettings.getDefaultEndpoint()); + ConversationDatasetsSettings settings = + ConversationDatasetsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ConversationDatasetsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ConversationDatasetsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createConversationDatasetTest() throws Exception { + ConversationDataset expectedResponse = + ConversationDataset.newBuilder() + .setName( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setInputConfig(InputConfig.newBuilder().build()) + .setConversationInfo(ConversationInfo.newBuilder().build()) + .setConversationCount(1994187347) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createConversationDatasetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + ConversationDataset conversationDataset = ConversationDataset.newBuilder().build(); + + ConversationDataset actualResponse = + client.createConversationDatasetAsync(parent, conversationDataset).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationDatasetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + ConversationDataset conversationDataset = ConversationDataset.newBuilder().build(); + client.createConversationDatasetAsync(parent, conversationDataset).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getConversationDatasetTest() throws Exception { + ConversationDataset expectedResponse = + ConversationDataset.newBuilder() + .setName( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setInputConfig(InputConfig.newBuilder().build()) + .setConversationInfo(ConversationInfo.newBuilder().build()) + .setConversationCount(1994187347) + .build(); + mockService.addResponse(expectedResponse); + + ConversationDatasetName name = + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]"); + + ConversationDataset actualResponse = client.getConversationDataset(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getConversationDatasetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationDatasetName name = + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]"); + client.getConversationDataset(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConversationDatasetTest2() throws Exception { + ConversationDataset expectedResponse = + ConversationDataset.newBuilder() + .setName( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setInputConfig(InputConfig.newBuilder().build()) + .setConversationInfo(ConversationInfo.newBuilder().build()) + .setConversationCount(1994187347) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9960/conversationDatasets/conversationDataset-9960"; + + ConversationDataset actualResponse = client.getConversationDataset(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getConversationDatasetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9960/conversationDatasets/conversationDataset-9960"; + client.getConversationDataset(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationDatasetsTest() throws Exception { + ConversationDataset responsesElement = ConversationDataset.newBuilder().build(); + ListConversationDatasetsResponse expectedResponse = + ListConversationDatasetsResponse.newBuilder() + .setNextPageToken("") + .addAllConversationDatasets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListConversationDatasetsPagedResponse pagedListResponse = + client.listConversationDatasets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationDatasetsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationDatasetsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listConversationDatasets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationDatasetsTest2() throws Exception { + ConversationDataset responsesElement = ConversationDataset.newBuilder().build(); + ListConversationDatasetsResponse expectedResponse = + ListConversationDatasetsResponse.newBuilder() + .setNextPageToken("") + .addAllConversationDatasets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListConversationDatasetsPagedResponse pagedListResponse = + client.listConversationDatasets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationDatasetsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationDatasetsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listConversationDatasets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteConversationDatasetTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteConversationDatasetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ConversationDatasetName name = + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]"); + + client.deleteConversationDatasetAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteConversationDatasetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationDatasetName name = + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]"); + client.deleteConversationDatasetAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteConversationDatasetTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteConversationDatasetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-658/locations/location-658/conversationDatasets/conversationDataset-658"; + + client.deleteConversationDatasetAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteConversationDatasetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-658/locations/location-658/conversationDatasets/conversationDataset-658"; + client.deleteConversationDatasetAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importConversationDataTest() throws Exception { + ImportConversationDataOperationResponse expectedResponse = + ImportConversationDataOperationResponse.newBuilder() + .setConversationDataset( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .setImportCount(-1721296907) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importConversationDataTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportConversationDataRequest request = + ImportConversationDataRequest.newBuilder() + .setName( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .setInputConfig(InputConfig.newBuilder().build()) + .build(); + + ImportConversationDataOperationResponse actualResponse = + client.importConversationDataAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importConversationDataExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportConversationDataRequest request = + ImportConversationDataRequest.newBuilder() + .setName( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .setInputConfig(InputConfig.newBuilder().build()) + .build(); + client.importConversationDataAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationModelsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationModelsClientHttpJsonTest.java new file mode 100644 index 000000000000..63378a83d424 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationModelsClientHttpJsonTest.java @@ -0,0 +1,622 @@ +/* + * Copyright 2022 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.ConversationModelsClient.ListConversationModelEvaluationsPagedResponse; +import static com.google.cloud.dialogflow.v2.ConversationModelsClient.ListConversationModelsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonConversationModelsStub; +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.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ConversationModelsClientHttpJsonTest { + private static MockHttpService mockService; + private static ConversationModelsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonConversationModelsStub.getMethodDescriptors(), + ConversationModelsSettings.getDefaultEndpoint()); + ConversationModelsSettings settings = + ConversationModelsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ConversationModelsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ConversationModelsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createConversationModelTest() throws Exception { + ConversationModel expectedResponse = + ConversationModel.newBuilder() + .setName( + ConversationModelName.ofProjectLocationConversationModelName( + "[PROJECT]", "[LOCATION]", "[CONVERSATION_MODEL]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .addAllDatasets(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createConversationModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2353"; + ConversationModel conversationModel = ConversationModel.newBuilder().build(); + + ConversationModel actualResponse = + client.createConversationModelAsync(parent, conversationModel).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + ConversationModel conversationModel = ConversationModel.newBuilder().build(); + client.createConversationModelAsync(parent, conversationModel).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getConversationModelTest() throws Exception { + ConversationModel expectedResponse = + ConversationModel.newBuilder() + .setName( + ConversationModelName.ofProjectConversationModelName( + "[PROJECT]", "[CONVERSATION_MODEL]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .addAllDatasets(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2935/conversationModels/conversationModel-2935"; + + ConversationModel actualResponse = client.getConversationModel(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getConversationModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2935/conversationModels/conversationModel-2935"; + client.getConversationModel(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationModelsTest() throws Exception { + ConversationModel responsesElement = ConversationModel.newBuilder().build(); + ListConversationModelsResponse expectedResponse = + ListConversationModelsResponse.newBuilder() + .setNextPageToken("") + .addAllConversationModels(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListConversationModelsPagedResponse pagedListResponse = client.listConversationModels(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationModelsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationModelsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listConversationModels(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteConversationModelTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteConversationModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-2935/conversationModels/conversationModel-2935"; + + client.deleteConversationModelAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteConversationModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2935/conversationModels/conversationModel-2935"; + client.deleteConversationModelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deployConversationModelTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deployConversationModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DeployConversationModelRequest request = + DeployConversationModelRequest.newBuilder() + .setName("projects/project-2935/conversationModels/conversationModel-2935") + .build(); + + client.deployConversationModelAsync(request).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deployConversationModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeployConversationModelRequest request = + DeployConversationModelRequest.newBuilder() + .setName("projects/project-2935/conversationModels/conversationModel-2935") + .build(); + client.deployConversationModelAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void undeployConversationModelTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("undeployConversationModelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + UndeployConversationModelRequest request = + UndeployConversationModelRequest.newBuilder() + .setName("projects/project-2935/conversationModels/conversationModel-2935") + .build(); + + client.undeployConversationModelAsync(request).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void undeployConversationModelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UndeployConversationModelRequest request = + UndeployConversationModelRequest.newBuilder() + .setName("projects/project-2935/conversationModels/conversationModel-2935") + .build(); + client.undeployConversationModelAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getConversationModelEvaluationTest() throws Exception { + ConversationModelEvaluation expectedResponse = + ConversationModelEvaluation.newBuilder() + .setName( + ConversationModelEvaluationName.ofProjectConversationModelEvaluationName( + "[PROJECT]", "[CONVERSATION_MODEL]", "[EVALUATION]") + .toString()) + .setDisplayName("displayName1714148973") + .setEvaluationConfig(EvaluationConfig.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-3158/conversationModels/conversationModel-3158/evaluations/evaluation-3158"; + + ConversationModelEvaluation actualResponse = client.getConversationModelEvaluation(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getConversationModelEvaluationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-3158/conversationModels/conversationModel-3158/evaluations/evaluation-3158"; + client.getConversationModelEvaluation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationModelEvaluationsTest() throws Exception { + ConversationModelEvaluation responsesElement = ConversationModelEvaluation.newBuilder().build(); + ListConversationModelEvaluationsResponse expectedResponse = + ListConversationModelEvaluationsResponse.newBuilder() + .setNextPageToken("") + .addAllConversationModelEvaluations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9736/conversationModels/conversationModel-9736"; + + ListConversationModelEvaluationsPagedResponse pagedListResponse = + client.listConversationModelEvaluations(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals( + expectedResponse.getConversationModelEvaluationsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationModelEvaluationsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9736/conversationModels/conversationModel-9736"; + client.listConversationModelEvaluations(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConversationModelEvaluationTest() throws Exception { + ConversationModelEvaluation expectedResponse = + ConversationModelEvaluation.newBuilder() + .setName( + ConversationModelEvaluationName.ofProjectConversationModelEvaluationName( + "[PROJECT]", "[CONVERSATION_MODEL]", "[EVALUATION]") + .toString()) + .setDisplayName("displayName1714148973") + .setEvaluationConfig(EvaluationConfig.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createConversationModelEvaluationTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ConversationModelName parent = + ConversationModelName.ofProjectLocationConversationModelName( + "[PROJECT]", "[LOCATION]", "[CONVERSATION_MODEL]"); + ConversationModelEvaluation conversationModelEvaluation = + ConversationModelEvaluation.newBuilder().build(); + + ConversationModelEvaluation actualResponse = + client.createConversationModelEvaluationAsync(parent, conversationModelEvaluation).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationModelEvaluationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationModelName parent = + ConversationModelName.ofProjectLocationConversationModelName( + "[PROJECT]", "[LOCATION]", "[CONVERSATION_MODEL]"); + ConversationModelEvaluation conversationModelEvaluation = + ConversationModelEvaluation.newBuilder().build(); + client.createConversationModelEvaluationAsync(parent, conversationModelEvaluation).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createConversationModelEvaluationTest2() throws Exception { + ConversationModelEvaluation expectedResponse = + ConversationModelEvaluation.newBuilder() + .setName( + ConversationModelEvaluationName.ofProjectConversationModelEvaluationName( + "[PROJECT]", "[CONVERSATION_MODEL]", "[EVALUATION]") + .toString()) + .setDisplayName("displayName1714148973") + .setEvaluationConfig(EvaluationConfig.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createConversationModelEvaluationTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = + "projects/project-4546/locations/location-4546/conversationModels/conversationModel-4546"; + ConversationModelEvaluation conversationModelEvaluation = + ConversationModelEvaluation.newBuilder().build(); + + ConversationModelEvaluation actualResponse = + client.createConversationModelEvaluationAsync(parent, conversationModelEvaluation).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationModelEvaluationExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-4546/locations/location-4546/conversationModels/conversationModel-4546"; + ConversationModelEvaluation conversationModelEvaluation = + ConversationModelEvaluation.newBuilder().build(); + client.createConversationModelEvaluationAsync(parent, conversationModelEvaluation).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationProfilesClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationProfilesClientHttpJsonTest.java new file mode 100644 index 000000000000..6b69fd9045d2 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationProfilesClientHttpJsonTest.java @@ -0,0 +1,870 @@ +/* + * Copyright 2022 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.ConversationProfilesClient.ListConversationProfilesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonConversationProfilesStub; +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.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ConversationProfilesClientHttpJsonTest { + private static MockHttpService mockService; + private static ConversationProfilesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonConversationProfilesStub.getMethodDescriptors(), + ConversationProfilesSettings.getDefaultEndpoint()); + ConversationProfilesSettings settings = + ConversationProfilesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ConversationProfilesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ConversationProfilesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listConversationProfilesTest() throws Exception { + ConversationProfile responsesElement = ConversationProfile.newBuilder().build(); + ListConversationProfilesResponse expectedResponse = + ListConversationProfilesResponse.newBuilder() + .setNextPageToken("") + .addAllConversationProfiles(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListConversationProfilesPagedResponse pagedListResponse = + client.listConversationProfiles(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationProfilesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationProfilesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listConversationProfiles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationProfilesTest2() throws Exception { + ConversationProfile responsesElement = ConversationProfile.newBuilder().build(); + ListConversationProfilesResponse expectedResponse = + ListConversationProfilesResponse.newBuilder() + .setNextPageToken("") + .addAllConversationProfiles(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListConversationProfilesPagedResponse pagedListResponse = + client.listConversationProfiles(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationProfilesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationProfilesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listConversationProfiles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationProfilesTest3() throws Exception { + ConversationProfile responsesElement = ConversationProfile.newBuilder().build(); + ListConversationProfilesResponse expectedResponse = + ListConversationProfilesResponse.newBuilder() + .setNextPageToken("") + .addAllConversationProfiles(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListConversationProfilesPagedResponse pagedListResponse = + client.listConversationProfiles(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationProfilesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationProfilesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listConversationProfiles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConversationProfileTest() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + mockService.addResponse(expectedResponse); + + ConversationProfileName name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]"); + + ConversationProfile actualResponse = client.getConversationProfile(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getConversationProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationProfileName name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]"); + client.getConversationProfile(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConversationProfileTest2() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-695/conversationProfiles/conversationProfile-695"; + + ConversationProfile actualResponse = client.getConversationProfile(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getConversationProfileExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-695/conversationProfiles/conversationProfile-695"; + client.getConversationProfile(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConversationProfileTest() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + + ConversationProfile actualResponse = + client.createConversationProfile(parent, conversationProfile); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + client.createConversationProfile(parent, conversationProfile); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConversationProfileTest2() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + + ConversationProfile actualResponse = + client.createConversationProfile(parent, conversationProfile); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationProfileExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + client.createConversationProfile(parent, conversationProfile); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConversationProfileTest3() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + + ConversationProfile actualResponse = + client.createConversationProfile(parent, conversationProfile); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationProfileExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + client.createConversationProfile(parent, conversationProfile); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateConversationProfileTest() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + mockService.addResponse(expectedResponse); + + ConversationProfile conversationProfile = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ConversationProfile actualResponse = + client.updateConversationProfile(conversationProfile, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateConversationProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationProfile conversationProfile = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateConversationProfile(conversationProfile, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteConversationProfileTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ConversationProfileName name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]"); + + client.deleteConversationProfile(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteConversationProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationProfileName name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]"); + client.deleteConversationProfile(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteConversationProfileTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-695/conversationProfiles/conversationProfile-695"; + + client.deleteConversationProfile(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteConversationProfileExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-695/conversationProfiles/conversationProfile-695"; + client.deleteConversationProfile(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setSuggestionFeatureConfigTest() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("setSuggestionFeatureConfigTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String conversationProfile = + "projects/project-4204/conversationProfiles/conversationProfile-4204"; + + ConversationProfile actualResponse = + client.setSuggestionFeatureConfigAsync(conversationProfile).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setSuggestionFeatureConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String conversationProfile = + "projects/project-4204/conversationProfiles/conversationProfile-4204"; + client.setSuggestionFeatureConfigAsync(conversationProfile).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void clearSuggestionFeatureConfigTest() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("clearSuggestionFeatureConfigTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String conversationProfile = + "projects/project-4204/conversationProfiles/conversationProfile-4204"; + + ConversationProfile actualResponse = + client.clearSuggestionFeatureConfigAsync(conversationProfile).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void clearSuggestionFeatureConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String conversationProfile = + "projects/project-4204/conversationProfiles/conversationProfile-4204"; + client.clearSuggestionFeatureConfigAsync(conversationProfile).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationsClientHttpJsonTest.java new file mode 100644 index 000000000000..cced75524aae --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ConversationsClientHttpJsonTest.java @@ -0,0 +1,712 @@ +/* + * Copyright 2022 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.ConversationsClient.ListConversationsPagedResponse; +import static com.google.cloud.dialogflow.v2.ConversationsClient.ListMessagesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonConversationsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ConversationsClientHttpJsonTest { + private static MockHttpService mockService; + private static ConversationsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonConversationsStub.getMethodDescriptors(), + ConversationsSettings.getDefaultEndpoint()); + ConversationsSettings settings = + ConversationsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ConversationsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ConversationsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createConversationTest() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Conversation conversation = Conversation.newBuilder().build(); + + Conversation actualResponse = client.createConversation(parent, conversation); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Conversation conversation = Conversation.newBuilder().build(); + client.createConversation(parent, conversation); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConversationTest2() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + Conversation conversation = Conversation.newBuilder().build(); + + Conversation actualResponse = client.createConversation(parent, conversation); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + Conversation conversation = Conversation.newBuilder().build(); + client.createConversation(parent, conversation); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConversationTest3() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + Conversation conversation = Conversation.newBuilder().build(); + + Conversation actualResponse = client.createConversation(parent, conversation); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + Conversation conversation = Conversation.newBuilder().build(); + client.createConversation(parent, conversation); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationsTest() throws Exception { + Conversation responsesElement = Conversation.newBuilder().build(); + ListConversationsResponse expectedResponse = + ListConversationsResponse.newBuilder() + .setNextPageToken("") + .addAllConversations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListConversationsPagedResponse pagedListResponse = client.listConversations(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listConversations(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationsTest2() throws Exception { + Conversation responsesElement = Conversation.newBuilder().build(); + ListConversationsResponse expectedResponse = + ListConversationsResponse.newBuilder() + .setNextPageToken("") + .addAllConversations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListConversationsPagedResponse pagedListResponse = client.listConversations(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listConversations(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationsTest3() throws Exception { + Conversation responsesElement = Conversation.newBuilder().build(); + ListConversationsResponse expectedResponse = + ListConversationsResponse.newBuilder() + .setNextPageToken("") + .addAllConversations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListConversationsPagedResponse pagedListResponse = client.listConversations(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listConversations(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConversationTest() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ConversationName name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + + Conversation actualResponse = client.getConversation(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getConversationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationName name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + client.getConversation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConversationTest2() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3460/conversations/conversation-3460"; + + Conversation actualResponse = client.getConversation(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getConversationExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3460/conversations/conversation-3460"; + client.getConversation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void completeConversationTest() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ConversationName name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + + Conversation actualResponse = client.completeConversation(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void completeConversationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationName name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + client.completeConversation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void completeConversationTest2() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3460/conversations/conversation-3460"; + + Conversation actualResponse = client.completeConversation(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void completeConversationExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3460/conversations/conversation-3460"; + client.completeConversation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listMessagesTest() throws Exception { + Message responsesElement = Message.newBuilder().build(); + ListMessagesResponse expectedResponse = + ListMessagesResponse.newBuilder() + .setNextPageToken("") + .addAllMessages(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + + ListMessagesPagedResponse pagedListResponse = client.listMessages(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getMessagesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listMessagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + client.listMessages(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listMessagesTest2() throws Exception { + Message responsesElement = Message.newBuilder().build(); + ListMessagesResponse expectedResponse = + ListMessagesResponse.newBuilder() + .setNextPageToken("") + .addAllMessages(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-4379/conversations/conversation-4379"; + + ListMessagesPagedResponse pagedListResponse = client.listMessages(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getMessagesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listMessagesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-4379/conversations/conversation-4379"; + client.listMessages(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/DocumentsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/DocumentsClientHttpJsonTest.java new file mode 100644 index 000000000000..9eccf8d59150 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/DocumentsClientHttpJsonTest.java @@ -0,0 +1,858 @@ +/* + * Copyright 2022 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.DocumentsClient.ListDocumentsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonDocumentsStub; +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.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class DocumentsClientHttpJsonTest { + private static MockHttpService mockService; + private static DocumentsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonDocumentsStub.getMethodDescriptors(), DocumentsSettings.getDefaultEndpoint()); + DocumentsSettings settings = + DocumentsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + DocumentsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DocumentsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listDocumentsTest() throws Exception { + Document responsesElement = Document.newBuilder().build(); + ListDocumentsResponse expectedResponse = + ListDocumentsResponse.newBuilder() + .setNextPageToken("") + .addAllDocuments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + KnowledgeBaseName parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + + ListDocumentsPagedResponse pagedListResponse = client.listDocuments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDocumentsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + KnowledgeBaseName parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + client.listDocuments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDocumentsTest2() throws Exception { + Document responsesElement = Document.newBuilder().build(); + ListDocumentsResponse expectedResponse = + ListDocumentsResponse.newBuilder() + .setNextPageToken("") + .addAllDocuments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-8161/knowledgeBases/knowledgeBase-8161"; + + ListDocumentsPagedResponse pagedListResponse = client.listDocuments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDocumentsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDocumentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-8161/knowledgeBases/knowledgeBase-8161"; + client.listDocuments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + + Document actualResponse = client.getDocument(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + client.getDocument(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDocumentTest2() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-5854/knowledgeBases/knowledgeBase-5854/documents/document-5854"; + + Document actualResponse = client.getDocument(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5854/knowledgeBases/knowledgeBase-5854/documents/document-5854"; + client.getDocument(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + KnowledgeBaseName parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + Document document = Document.newBuilder().build(); + + Document actualResponse = client.createDocumentAsync(parent, document).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + KnowledgeBaseName parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + Document document = Document.newBuilder().build(); + client.createDocumentAsync(parent, document).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createDocumentTest2() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-8161/knowledgeBases/knowledgeBase-8161"; + Document document = Document.newBuilder().build(); + + Document actualResponse = client.createDocumentAsync(parent, document).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-8161/knowledgeBases/knowledgeBase-8161"; + Document document = Document.newBuilder().build(); + client.createDocumentAsync(parent, document).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importDocumentsTest() throws Exception { + ImportDocumentsResponse expectedResponse = + ImportDocumentsResponse.newBuilder().addAllWarnings(new ArrayList()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportDocumentsRequest request = + ImportDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocumentTemplate(ImportDocumentTemplate.newBuilder().build()) + .setImportGcsCustomMetadata(true) + .build(); + + ImportDocumentsResponse actualResponse = client.importDocumentsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportDocumentsRequest request = + ImportDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocumentTemplate(ImportDocumentTemplate.newBuilder().build()) + .setImportGcsCustomMetadata(true) + .build(); + client.importDocumentsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteDocumentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + + client.deleteDocumentAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + client.deleteDocumentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteDocumentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-5854/knowledgeBases/knowledgeBase-5854/documents/document-5854"; + + client.deleteDocumentAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5854/knowledgeBases/knowledgeBase-5854/documents/document-5854"; + client.deleteDocumentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Document document = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Document actualResponse = client.updateDocumentAsync(document, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Document document = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateDocumentAsync(document, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void reloadDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("reloadDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + String contentUri = "contentUri264542771"; + + Document actualResponse = client.reloadDocumentAsync(name, contentUri).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void reloadDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + String contentUri = "contentUri264542771"; + client.reloadDocumentAsync(name, contentUri).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void reloadDocumentTest2() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("reloadDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-5854/knowledgeBases/knowledgeBase-5854/documents/document-5854"; + String contentUri = "contentUri264542771"; + + Document actualResponse = client.reloadDocumentAsync(name, contentUri).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void reloadDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5854/knowledgeBases/knowledgeBase-5854/documents/document-5854"; + String contentUri = "contentUri264542771"; + client.reloadDocumentAsync(name, contentUri).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ExportDocumentRequest request = + ExportDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setExportFullContent(true) + .setSmartMessagingPartialUpdate(true) + .build(); + + Document actualResponse = client.exportDocumentAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void exportDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ExportDocumentRequest request = + ExportDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setExportFullContent(true) + .setSmartMessagingPartialUpdate(true) + .build(); + client.exportDocumentAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/EntityTypesClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/EntityTypesClientHttpJsonTest.java new file mode 100644 index 000000000000..0a2f48918aa9 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/EntityTypesClientHttpJsonTest.java @@ -0,0 +1,1623 @@ +/* + * Copyright 2022 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonEntityTypesStub; +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 java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class EntityTypesClientHttpJsonTest { + private static MockHttpService mockService; + private static EntityTypesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonEntityTypesStub.getMethodDescriptors(), + EntityTypesSettings.getDefaultEndpoint()); + EntityTypesSettings settings = + EntityTypesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + EntityTypesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = EntityTypesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listEntityTypesTest() throws Exception { + EntityType responsesElement = EntityType.newBuilder().build(); + ListEntityTypesResponse expectedResponse = + ListEntityTypesResponse.newBuilder() + .setNextPageToken("") + .addAllEntityTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEntityTypesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + client.listEntityTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEntityTypesTest2() throws Exception { + EntityType responsesElement = EntityType.newBuilder().build(); + ListEntityTypesResponse expectedResponse = + ListEntityTypesResponse.newBuilder() + .setNextPageToken("") + .addAllEntityTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEntityTypesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + client.listEntityTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEntityTypesTest3() throws Exception { + EntityType responsesElement = EntityType.newBuilder().build(); + ListEntityTypesResponse expectedResponse = + ListEntityTypesResponse.newBuilder() + .setNextPageToken("") + .addAllEntityTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String languageCode = "languageCode-2092349083"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEntityTypesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String languageCode = "languageCode-2092349083"; + client.listEntityTypes(parent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEntityTypesTest4() throws Exception { + EntityType responsesElement = EntityType.newBuilder().build(); + ListEntityTypesResponse expectedResponse = + ListEntityTypesResponse.newBuilder() + .setNextPageToken("") + .addAllEntityTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + String languageCode = "languageCode-2092349083"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEntityTypesExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + String languageCode = "languageCode-2092349083"; + client.listEntityTypes(parent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEntityTypeTest() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + + EntityType actualResponse = client.getEntityType(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + client.getEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEntityTypeTest2() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3464/agent/entityTypes/entityType-3464"; + + EntityType actualResponse = client.getEntityType(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3464/agent/entityTypes/entityType-3464"; + client.getEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEntityTypeTest3() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + String languageCode = "languageCode-2092349083"; + + EntityType actualResponse = client.getEntityType(name, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEntityTypeExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + String languageCode = "languageCode-2092349083"; + client.getEntityType(name, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEntityTypeTest4() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3464/agent/entityTypes/entityType-3464"; + String languageCode = "languageCode-2092349083"; + + EntityType actualResponse = client.getEntityType(name, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEntityTypeExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3464/agent/entityTypes/entityType-3464"; + String languageCode = "languageCode-2092349083"; + client.getEntityType(name, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEntityTypeTest() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + + EntityType actualResponse = client.createEntityType(parent, entityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + client.createEntityType(parent, entityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEntityTypeTest2() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + EntityType entityType = EntityType.newBuilder().build(); + + EntityType actualResponse = client.createEntityType(parent, entityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + EntityType entityType = EntityType.newBuilder().build(); + client.createEntityType(parent, entityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEntityTypeTest3() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + + EntityType actualResponse = client.createEntityType(parent, entityType, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEntityTypeExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + client.createEntityType(parent, entityType, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEntityTypeTest4() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + + EntityType actualResponse = client.createEntityType(parent, entityType, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEntityTypeExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + client.createEntityType(parent, entityType, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateEntityTypeTest() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + EntityType entityType = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + + EntityType actualResponse = client.updateEntityType(entityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityType entityType = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + client.updateEntityType(entityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateEntityTypeTest2() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + EntityType entityType = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + String languageCode = "languageCode-2092349083"; + + EntityType actualResponse = client.updateEntityType(entityType, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityType entityType = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + String languageCode = "languageCode-2092349083"; + client.updateEntityType(entityType, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteEntityTypeTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + + client.deleteEntityType(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + client.deleteEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteEntityTypeTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3464/agent/entityTypes/entityType-3464"; + + client.deleteEntityType(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3464/agent/entityTypes/entityType-3464"; + client.deleteEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchUpdateEntityTypesTest() throws Exception { + BatchUpdateEntityTypesResponse expectedResponse = + BatchUpdateEntityTypesResponse.newBuilder() + .addAllEntityTypes(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateEntityTypesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + BatchUpdateEntityTypesRequest request = + BatchUpdateEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + BatchUpdateEntityTypesResponse actualResponse = + client.batchUpdateEntityTypesAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateEntityTypesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BatchUpdateEntityTypesRequest request = + BatchUpdateEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.batchUpdateEntityTypesAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteEntityTypesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntityTypesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + List entityTypeNames = new ArrayList<>(); + + client.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteEntityTypesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + List entityTypeNames = new ArrayList<>(); + client.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteEntityTypesTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntityTypesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2469/agent"; + List entityTypeNames = new ArrayList<>(); + + client.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteEntityTypesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + List entityTypeNames = new ArrayList<>(); + client.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchCreateEntitiesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchCreateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + + client.batchCreateEntitiesAsync(parent, entities).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchCreateEntitiesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + client.batchCreateEntitiesAsync(parent, entities).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchCreateEntitiesTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchCreateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + + client.batchCreateEntitiesAsync(parent, entities).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchCreateEntitiesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + client.batchCreateEntitiesAsync(parent, entities).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchCreateEntitiesTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchCreateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + + client.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchCreateEntitiesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + client.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchCreateEntitiesTest4() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchCreateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + + client.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchCreateEntitiesExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + client.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateEntitiesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + + client.batchUpdateEntitiesAsync(parent, entities).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateEntitiesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + client.batchUpdateEntitiesAsync(parent, entities).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateEntitiesTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + + client.batchUpdateEntitiesAsync(parent, entities).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateEntitiesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + client.batchUpdateEntitiesAsync(parent, entities).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateEntitiesTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + + client.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateEntitiesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + client.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateEntitiesTest4() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + + client.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateEntitiesExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + client.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteEntitiesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + + client.batchDeleteEntitiesAsync(parent, entityValues).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteEntitiesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + client.batchDeleteEntitiesAsync(parent, entityValues).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteEntitiesTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entityValues = new ArrayList<>(); + + client.batchDeleteEntitiesAsync(parent, entityValues).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteEntitiesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entityValues = new ArrayList<>(); + client.batchDeleteEntitiesAsync(parent, entityValues).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteEntitiesTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + + client.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteEntitiesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + client.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteEntitiesTest4() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + + client.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteEntitiesExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + client.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/EnvironmentsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/EnvironmentsClientHttpJsonTest.java new file mode 100644 index 000000000000..766d7b23ed0d --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/EnvironmentsClientHttpJsonTest.java @@ -0,0 +1,491 @@ +/* + * Copyright 2022 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.EnvironmentsClient.GetEnvironmentHistoryPagedResponse; +import static com.google.cloud.dialogflow.v2.EnvironmentsClient.ListEnvironmentsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonEnvironmentsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class EnvironmentsClientHttpJsonTest { + private static MockHttpService mockService; + private static EnvironmentsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonEnvironmentsStub.getMethodDescriptors(), + EnvironmentsSettings.getDefaultEndpoint()); + EnvironmentsSettings settings = + EnvironmentsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + EnvironmentsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = EnvironmentsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listEnvironmentsTest() throws Exception { + Environment responsesElement = Environment.newBuilder().build(); + ListEnvironmentsResponse expectedResponse = + ListEnvironmentsResponse.newBuilder() + .setNextPageToken("") + .addAllEnvironments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + + ListEnvironmentsPagedResponse pagedListResponse = client.listEnvironments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEnvironmentsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEnvironmentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + client.listEnvironments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEnvironmentsTest2() throws Exception { + Environment responsesElement = Environment.newBuilder().build(); + ListEnvironmentsResponse expectedResponse = + ListEnvironmentsResponse.newBuilder() + .setNextPageToken("") + .addAllEnvironments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + + ListEnvironmentsPagedResponse pagedListResponse = client.listEnvironments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEnvironmentsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEnvironmentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + client.listEnvironments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEnvironmentTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setDescription("description-1724546052") + .setAgentVersion(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setTextToSpeechSettings(TextToSpeechSettings.newBuilder().build()) + .setFulfillment(Fulfillment.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + + Environment actualResponse = client.getEnvironment(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + client.getEnvironment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEnvironmentTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setDescription("description-1724546052") + .setAgentVersion(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setTextToSpeechSettings(TextToSpeechSettings.newBuilder().build()) + .setFulfillment(Fulfillment.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setEnvironment(Environment.newBuilder().build()) + .setEnvironmentId("environmentId-950205810") + .build(); + + Environment actualResponse = client.createEnvironment(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setEnvironment(Environment.newBuilder().build()) + .setEnvironmentId("environmentId-950205810") + .build(); + client.createEnvironment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateEnvironmentTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setDescription("description-1724546052") + .setAgentVersion(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setTextToSpeechSettings(TextToSpeechSettings.newBuilder().build()) + .setFulfillment(Fulfillment.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setEnvironment( + Environment.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]") + .toString()) + .setDescription("description-1724546052") + .setAgentVersion( + VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setTextToSpeechSettings(TextToSpeechSettings.newBuilder().build()) + .setFulfillment(Fulfillment.newBuilder().build()) + .build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowLoadToDraftAndDiscardChanges(true) + .build(); + + Environment actualResponse = client.updateEnvironment(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setEnvironment( + Environment.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]") + .toString()) + .setDescription("description-1724546052") + .setAgentVersion( + VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setTextToSpeechSettings(TextToSpeechSettings.newBuilder().build()) + .setFulfillment(Fulfillment.newBuilder().build()) + .build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowLoadToDraftAndDiscardChanges(true) + .build(); + client.updateEnvironment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteEnvironmentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + + client.deleteEnvironment(request); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + client.deleteEnvironment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEnvironmentHistoryTest() throws Exception { + EnvironmentHistory.Entry responsesElement = EnvironmentHistory.Entry.newBuilder().build(); + EnvironmentHistory expectedResponse = + EnvironmentHistory.newBuilder() + .setNextPageToken("") + .addAllEntries(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + GetEnvironmentHistoryRequest request = + GetEnvironmentHistoryRequest.newBuilder() + .setParent( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + GetEnvironmentHistoryPagedResponse pagedListResponse = client.getEnvironmentHistory(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEntriesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEnvironmentHistoryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetEnvironmentHistoryRequest request = + GetEnvironmentHistoryRequest.newBuilder() + .setParent( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.getEnvironmentHistory(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/FulfillmentsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/FulfillmentsClientHttpJsonTest.java new file mode 100644 index 000000000000..0a683a01109f --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/FulfillmentsClientHttpJsonTest.java @@ -0,0 +1,230 @@ +/* + * Copyright 2022 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonFulfillmentsStub; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class FulfillmentsClientHttpJsonTest { + private static MockHttpService mockService; + private static FulfillmentsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonFulfillmentsStub.getMethodDescriptors(), + FulfillmentsSettings.getDefaultEndpoint()); + FulfillmentsSettings settings = + FulfillmentsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + FulfillmentsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = FulfillmentsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void getFulfillmentTest() throws Exception { + Fulfillment expectedResponse = + Fulfillment.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setEnabled(true) + .addAllFeatures(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + FulfillmentName name = FulfillmentName.ofProjectName("[PROJECT]"); + + Fulfillment actualResponse = client.getFulfillment(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getFulfillmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FulfillmentName name = FulfillmentName.ofProjectName("[PROJECT]"); + client.getFulfillment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFulfillmentTest2() throws Exception { + Fulfillment expectedResponse = + Fulfillment.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setEnabled(true) + .addAllFeatures(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2293/agent/fulfillment"; + + Fulfillment actualResponse = client.getFulfillment(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getFulfillmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2293/agent/fulfillment"; + client.getFulfillment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateFulfillmentTest() throws Exception { + Fulfillment expectedResponse = + Fulfillment.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setEnabled(true) + .addAllFeatures(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Fulfillment fulfillment = + Fulfillment.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setEnabled(true) + .addAllFeatures(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Fulfillment actualResponse = client.updateFulfillment(fulfillment, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateFulfillmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Fulfillment fulfillment = + Fulfillment.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setEnabled(true) + .addAllFeatures(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateFulfillment(fulfillment, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/IntentsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/IntentsClientHttpJsonTest.java new file mode 100644 index 000000000000..bbc66aba4de1 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/IntentsClientHttpJsonTest.java @@ -0,0 +1,1386 @@ +/* + * Copyright 2022 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonIntentsStub; +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 java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class IntentsClientHttpJsonTest { + private static MockHttpService mockService; + private static IntentsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonIntentsStub.getMethodDescriptors(), IntentsSettings.getDefaultEndpoint()); + IntentsSettings settings = + IntentsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + IntentsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = IntentsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listIntentsTest() throws Exception { + Intent responsesElement = Intent.newBuilder().build(); + ListIntentsResponse expectedResponse = + ListIntentsResponse.newBuilder() + .setNextPageToken("") + .addAllIntents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listIntentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + client.listIntents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listIntentsTest2() throws Exception { + Intent responsesElement = Intent.newBuilder().build(); + ListIntentsResponse expectedResponse = + ListIntentsResponse.newBuilder() + .setNextPageToken("") + .addAllIntents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listIntentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + client.listIntents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listIntentsTest3() throws Exception { + Intent responsesElement = Intent.newBuilder().build(); + ListIntentsResponse expectedResponse = + ListIntentsResponse.newBuilder() + .setNextPageToken("") + .addAllIntents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String languageCode = "languageCode-2092349083"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listIntentsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String languageCode = "languageCode-2092349083"; + client.listIntents(parent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listIntentsTest4() throws Exception { + Intent responsesElement = Intent.newBuilder().build(); + ListIntentsResponse expectedResponse = + ListIntentsResponse.newBuilder() + .setNextPageToken("") + .addAllIntents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + String languageCode = "languageCode-2092349083"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listIntentsExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + String languageCode = "languageCode-2092349083"; + client.listIntents(parent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIntentTest() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + + Intent actualResponse = client.getIntent(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIntentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + client.getIntent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIntentTest2() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1783/agent/intents/intent-1783"; + + Intent actualResponse = client.getIntent(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIntentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1783/agent/intents/intent-1783"; + client.getIntent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIntentTest3() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + String languageCode = "languageCode-2092349083"; + + Intent actualResponse = client.getIntent(name, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIntentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + String languageCode = "languageCode-2092349083"; + client.getIntent(name, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIntentTest4() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1783/agent/intents/intent-1783"; + String languageCode = "languageCode-2092349083"; + + Intent actualResponse = client.getIntent(name, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIntentExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1783/agent/intents/intent-1783"; + String languageCode = "languageCode-2092349083"; + client.getIntent(name, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createIntentTest() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + + Intent actualResponse = client.createIntent(parent, intent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createIntentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + client.createIntent(parent, intent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createIntentTest2() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + Intent intent = Intent.newBuilder().build(); + + Intent actualResponse = client.createIntent(parent, intent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createIntentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + Intent intent = Intent.newBuilder().build(); + client.createIntent(parent, intent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createIntentTest3() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + + Intent actualResponse = client.createIntent(parent, intent, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createIntentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + client.createIntent(parent, intent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createIntentTest4() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + + Intent actualResponse = client.createIntent(parent, intent, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createIntentExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + client.createIntent(parent, intent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateIntentTest() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Intent intent = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + String languageCode = "languageCode-2092349083"; + + Intent actualResponse = client.updateIntent(intent, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateIntentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Intent intent = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + String languageCode = "languageCode-2092349083"; + client.updateIntent(intent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateIntentTest2() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Intent intent = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + String languageCode = "languageCode-2092349083"; + FieldMask updateMask = FieldMask.newBuilder().build(); + + Intent actualResponse = client.updateIntent(intent, languageCode, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateIntentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Intent intent = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + String languageCode = "languageCode-2092349083"; + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateIntent(intent, languageCode, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteIntentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + + client.deleteIntent(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteIntentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + client.deleteIntent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteIntentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1783/agent/intents/intent-1783"; + + client.deleteIntent(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteIntentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1783/agent/intents/intent-1783"; + client.deleteIntent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchUpdateIntentsTest() throws Exception { + BatchUpdateIntentsResponse expectedResponse = + BatchUpdateIntentsResponse.newBuilder().addAllIntents(new ArrayList()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateIntentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + IntentBatch intentBatchInline = IntentBatch.newBuilder().build(); + + BatchUpdateIntentsResponse actualResponse = + client.batchUpdateIntentsAsync(parent, intentBatchInline).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateIntentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + IntentBatch intentBatchInline = IntentBatch.newBuilder().build(); + client.batchUpdateIntentsAsync(parent, intentBatchInline).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateIntentsTest2() throws Exception { + BatchUpdateIntentsResponse expectedResponse = + BatchUpdateIntentsResponse.newBuilder().addAllIntents(new ArrayList()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateIntentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String intentBatchUri = "intentBatchUri544125582"; + + BatchUpdateIntentsResponse actualResponse = + client.batchUpdateIntentsAsync(parent, intentBatchUri).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateIntentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String intentBatchUri = "intentBatchUri544125582"; + client.batchUpdateIntentsAsync(parent, intentBatchUri).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateIntentsTest3() throws Exception { + BatchUpdateIntentsResponse expectedResponse = + BatchUpdateIntentsResponse.newBuilder().addAllIntents(new ArrayList()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateIntentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2469/agent"; + IntentBatch intentBatchInline = IntentBatch.newBuilder().build(); + + BatchUpdateIntentsResponse actualResponse = + client.batchUpdateIntentsAsync(parent, intentBatchInline).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateIntentsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + IntentBatch intentBatchInline = IntentBatch.newBuilder().build(); + client.batchUpdateIntentsAsync(parent, intentBatchInline).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateIntentsTest4() throws Exception { + BatchUpdateIntentsResponse expectedResponse = + BatchUpdateIntentsResponse.newBuilder().addAllIntents(new ArrayList()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateIntentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2469/agent"; + String intentBatchUri = "intentBatchUri544125582"; + + BatchUpdateIntentsResponse actualResponse = + client.batchUpdateIntentsAsync(parent, intentBatchUri).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateIntentsExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + String intentBatchUri = "intentBatchUri544125582"; + client.batchUpdateIntentsAsync(parent, intentBatchUri).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteIntentsTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteIntentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + List intents = new ArrayList<>(); + + client.batchDeleteIntentsAsync(parent, intents).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteIntentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + List intents = new ArrayList<>(); + client.batchDeleteIntentsAsync(parent, intents).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteIntentsTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteIntentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2469/agent"; + List intents = new ArrayList<>(); + + client.batchDeleteIntentsAsync(parent, intents).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteIntentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + List intents = new ArrayList<>(); + client.batchDeleteIntentsAsync(parent, intents).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/KnowledgeBasesClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/KnowledgeBasesClientHttpJsonTest.java new file mode 100644 index 000000000000..1d9f3dc849c4 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/KnowledgeBasesClientHttpJsonTest.java @@ -0,0 +1,623 @@ +/* + * Copyright 2022 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.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonKnowledgeBasesStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class KnowledgeBasesClientHttpJsonTest { + private static MockHttpService mockService; + private static KnowledgeBasesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonKnowledgeBasesStub.getMethodDescriptors(), + KnowledgeBasesSettings.getDefaultEndpoint()); + KnowledgeBasesSettings settings = + KnowledgeBasesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + KnowledgeBasesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = KnowledgeBasesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listKnowledgeBasesTest() throws Exception { + KnowledgeBase responsesElement = KnowledgeBase.newBuilder().build(); + ListKnowledgeBasesResponse expectedResponse = + ListKnowledgeBasesResponse.newBuilder() + .setNextPageToken("") + .addAllKnowledgeBases(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListKnowledgeBasesPagedResponse pagedListResponse = client.listKnowledgeBases(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getKnowledgeBasesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listKnowledgeBasesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listKnowledgeBases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listKnowledgeBasesTest2() throws Exception { + KnowledgeBase responsesElement = KnowledgeBase.newBuilder().build(); + ListKnowledgeBasesResponse expectedResponse = + ListKnowledgeBasesResponse.newBuilder() + .setNextPageToken("") + .addAllKnowledgeBases(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListKnowledgeBasesPagedResponse pagedListResponse = client.listKnowledgeBases(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getKnowledgeBasesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listKnowledgeBasesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listKnowledgeBases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listKnowledgeBasesTest3() throws Exception { + KnowledgeBase responsesElement = KnowledgeBase.newBuilder().build(); + ListKnowledgeBasesResponse expectedResponse = + ListKnowledgeBasesResponse.newBuilder() + .setNextPageToken("") + .addAllKnowledgeBases(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListKnowledgeBasesPagedResponse pagedListResponse = client.listKnowledgeBases(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getKnowledgeBasesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listKnowledgeBasesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listKnowledgeBases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getKnowledgeBaseTest() throws Exception { + KnowledgeBase expectedResponse = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + KnowledgeBaseName name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + + KnowledgeBase actualResponse = client.getKnowledgeBase(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getKnowledgeBaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + KnowledgeBaseName name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + client.getKnowledgeBase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getKnowledgeBaseTest2() throws Exception { + KnowledgeBase expectedResponse = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-8270/knowledgeBases/knowledgeBase-8270"; + + KnowledgeBase actualResponse = client.getKnowledgeBase(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getKnowledgeBaseExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-8270/knowledgeBases/knowledgeBase-8270"; + client.getKnowledgeBase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createKnowledgeBaseTest() throws Exception { + KnowledgeBase expectedResponse = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + + KnowledgeBase actualResponse = client.createKnowledgeBase(parent, knowledgeBase); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createKnowledgeBaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + client.createKnowledgeBase(parent, knowledgeBase); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createKnowledgeBaseTest2() throws Exception { + KnowledgeBase expectedResponse = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + + KnowledgeBase actualResponse = client.createKnowledgeBase(parent, knowledgeBase); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createKnowledgeBaseExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + client.createKnowledgeBase(parent, knowledgeBase); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createKnowledgeBaseTest3() throws Exception { + KnowledgeBase expectedResponse = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + + KnowledgeBase actualResponse = client.createKnowledgeBase(parent, knowledgeBase); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createKnowledgeBaseExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + client.createKnowledgeBase(parent, knowledgeBase); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteKnowledgeBaseTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + KnowledgeBaseName name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + + client.deleteKnowledgeBase(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteKnowledgeBaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + KnowledgeBaseName name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + client.deleteKnowledgeBase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteKnowledgeBaseTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-8270/knowledgeBases/knowledgeBase-8270"; + + client.deleteKnowledgeBase(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteKnowledgeBaseExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-8270/knowledgeBases/knowledgeBase-8270"; + client.deleteKnowledgeBase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateKnowledgeBaseTest() throws Exception { + KnowledgeBase expectedResponse = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + KnowledgeBase knowledgeBase = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + KnowledgeBase actualResponse = client.updateKnowledgeBase(knowledgeBase, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateKnowledgeBaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + KnowledgeBase knowledgeBase = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateKnowledgeBase(knowledgeBase, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ParticipantsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ParticipantsClientHttpJsonTest.java new file mode 100644 index 000000000000..6b54face40a7 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ParticipantsClientHttpJsonTest.java @@ -0,0 +1,977 @@ +/* + * Copyright 2022 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.ParticipantsClient.ListParticipantsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonParticipantsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ParticipantsClientHttpJsonTest { + private static MockHttpService mockService; + private static ParticipantsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonParticipantsStub.getMethodDescriptors(), + ParticipantsSettings.getDefaultEndpoint()); + ParticipantsSettings settings = + ParticipantsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ParticipantsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ParticipantsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createParticipantTest() throws Exception { + Participant expectedResponse = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setSipRecordingMediaLabel("sipRecordingMediaLabel-1887770873") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + Participant participant = Participant.newBuilder().build(); + + Participant actualResponse = client.createParticipant(parent, participant); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createParticipantExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + Participant participant = Participant.newBuilder().build(); + client.createParticipant(parent, participant); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createParticipantTest2() throws Exception { + Participant expectedResponse = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setSipRecordingMediaLabel("sipRecordingMediaLabel-1887770873") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-4379/conversations/conversation-4379"; + Participant participant = Participant.newBuilder().build(); + + Participant actualResponse = client.createParticipant(parent, participant); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createParticipantExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-4379/conversations/conversation-4379"; + Participant participant = Participant.newBuilder().build(); + client.createParticipant(parent, participant); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getParticipantTest() throws Exception { + Participant expectedResponse = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setSipRecordingMediaLabel("sipRecordingMediaLabel-1887770873") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + ParticipantName name = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + + Participant actualResponse = client.getParticipant(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getParticipantExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ParticipantName name = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + client.getParticipant(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getParticipantTest2() throws Exception { + Participant expectedResponse = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setSipRecordingMediaLabel("sipRecordingMediaLabel-1887770873") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7006/conversations/conversation-7006/participants/participant-7006"; + + Participant actualResponse = client.getParticipant(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getParticipantExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7006/conversations/conversation-7006/participants/participant-7006"; + client.getParticipant(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listParticipantsTest() throws Exception { + Participant responsesElement = Participant.newBuilder().build(); + ListParticipantsResponse expectedResponse = + ListParticipantsResponse.newBuilder() + .setNextPageToken("") + .addAllParticipants(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + + ListParticipantsPagedResponse pagedListResponse = client.listParticipants(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getParticipantsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listParticipantsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + client.listParticipants(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listParticipantsTest2() throws Exception { + Participant responsesElement = Participant.newBuilder().build(); + ListParticipantsResponse expectedResponse = + ListParticipantsResponse.newBuilder() + .setNextPageToken("") + .addAllParticipants(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-4379/conversations/conversation-4379"; + + ListParticipantsPagedResponse pagedListResponse = client.listParticipants(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getParticipantsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listParticipantsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-4379/conversations/conversation-4379"; + client.listParticipants(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateParticipantTest() throws Exception { + Participant expectedResponse = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setSipRecordingMediaLabel("sipRecordingMediaLabel-1887770873") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + Participant participant = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setSipRecordingMediaLabel("sipRecordingMediaLabel-1887770873") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Participant actualResponse = client.updateParticipant(participant, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateParticipantExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Participant participant = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setSipRecordingMediaLabel("sipRecordingMediaLabel-1887770873") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateParticipant(participant, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void analyzeContentTest() throws Exception { + AnalyzeContentResponse expectedResponse = + AnalyzeContentResponse.newBuilder() + .setReplyText("replyText-433699017") + .setReplyAudio(OutputAudio.newBuilder().build()) + .setAutomatedAgentReply(AutomatedAgentReply.newBuilder().build()) + .setMessage(Message.newBuilder().build()) + .addAllHumanAgentSuggestionResults(new ArrayList()) + .addAllEndUserSuggestionResults(new ArrayList()) + .setDtmfParameters(DtmfParameters.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ParticipantName participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + EventInput eventInput = EventInput.newBuilder().build(); + + AnalyzeContentResponse actualResponse = client.analyzeContent(participant, eventInput); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void analyzeContentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ParticipantName participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + EventInput eventInput = EventInput.newBuilder().build(); + client.analyzeContent(participant, eventInput); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void analyzeContentTest2() throws Exception { + AnalyzeContentResponse expectedResponse = + AnalyzeContentResponse.newBuilder() + .setReplyText("replyText-433699017") + .setReplyAudio(OutputAudio.newBuilder().build()) + .setAutomatedAgentReply(AutomatedAgentReply.newBuilder().build()) + .setMessage(Message.newBuilder().build()) + .addAllHumanAgentSuggestionResults(new ArrayList()) + .addAllEndUserSuggestionResults(new ArrayList()) + .setDtmfParameters(DtmfParameters.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ParticipantName participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + TextInput textInput = TextInput.newBuilder().build(); + + AnalyzeContentResponse actualResponse = client.analyzeContent(participant, textInput); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void analyzeContentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ParticipantName participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + TextInput textInput = TextInput.newBuilder().build(); + client.analyzeContent(participant, textInput); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void analyzeContentTest3() throws Exception { + AnalyzeContentResponse expectedResponse = + AnalyzeContentResponse.newBuilder() + .setReplyText("replyText-433699017") + .setReplyAudio(OutputAudio.newBuilder().build()) + .setAutomatedAgentReply(AutomatedAgentReply.newBuilder().build()) + .setMessage(Message.newBuilder().build()) + .addAllHumanAgentSuggestionResults(new ArrayList()) + .addAllEndUserSuggestionResults(new ArrayList()) + .setDtmfParameters(DtmfParameters.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String participant = + "projects/project-8054/conversations/conversation-8054/participants/participant-8054"; + EventInput eventInput = EventInput.newBuilder().build(); + + AnalyzeContentResponse actualResponse = client.analyzeContent(participant, eventInput); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void analyzeContentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String participant = + "projects/project-8054/conversations/conversation-8054/participants/participant-8054"; + EventInput eventInput = EventInput.newBuilder().build(); + client.analyzeContent(participant, eventInput); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void analyzeContentTest4() throws Exception { + AnalyzeContentResponse expectedResponse = + AnalyzeContentResponse.newBuilder() + .setReplyText("replyText-433699017") + .setReplyAudio(OutputAudio.newBuilder().build()) + .setAutomatedAgentReply(AutomatedAgentReply.newBuilder().build()) + .setMessage(Message.newBuilder().build()) + .addAllHumanAgentSuggestionResults(new ArrayList()) + .addAllEndUserSuggestionResults(new ArrayList()) + .setDtmfParameters(DtmfParameters.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String participant = + "projects/project-8054/conversations/conversation-8054/participants/participant-8054"; + TextInput textInput = TextInput.newBuilder().build(); + + AnalyzeContentResponse actualResponse = client.analyzeContent(participant, textInput); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void analyzeContentExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String participant = + "projects/project-8054/conversations/conversation-8054/participants/participant-8054"; + TextInput textInput = TextInput.newBuilder().build(); + client.analyzeContent(participant, textInput); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void suggestArticlesTest() throws Exception { + SuggestArticlesResponse expectedResponse = + SuggestArticlesResponse.newBuilder() + .addAllArticleAnswers(new ArrayList()) + .setLatestMessage("latestMessage-1424305536") + .setContextSize(1116903569) + .build(); + mockService.addResponse(expectedResponse); + + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + + SuggestArticlesResponse actualResponse = client.suggestArticles(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void suggestArticlesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + client.suggestArticles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void suggestArticlesTest2() throws Exception { + SuggestArticlesResponse expectedResponse = + SuggestArticlesResponse.newBuilder() + .addAllArticleAnswers(new ArrayList()) + .setLatestMessage("latestMessage-1424305536") + .setContextSize(1116903569) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-4961/conversations/conversation-4961/participants/participant-4961"; + + SuggestArticlesResponse actualResponse = client.suggestArticles(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void suggestArticlesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-4961/conversations/conversation-4961/participants/participant-4961"; + client.suggestArticles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void suggestFaqAnswersTest() throws Exception { + SuggestFaqAnswersResponse expectedResponse = + SuggestFaqAnswersResponse.newBuilder() + .addAllFaqAnswers(new ArrayList()) + .setLatestMessage("latestMessage-1424305536") + .setContextSize(1116903569) + .build(); + mockService.addResponse(expectedResponse); + + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + + SuggestFaqAnswersResponse actualResponse = client.suggestFaqAnswers(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void suggestFaqAnswersExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + client.suggestFaqAnswers(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void suggestFaqAnswersTest2() throws Exception { + SuggestFaqAnswersResponse expectedResponse = + SuggestFaqAnswersResponse.newBuilder() + .addAllFaqAnswers(new ArrayList()) + .setLatestMessage("latestMessage-1424305536") + .setContextSize(1116903569) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-4961/conversations/conversation-4961/participants/participant-4961"; + + SuggestFaqAnswersResponse actualResponse = client.suggestFaqAnswers(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void suggestFaqAnswersExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-4961/conversations/conversation-4961/participants/participant-4961"; + client.suggestFaqAnswers(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void suggestSmartRepliesTest() throws Exception { + SuggestSmartRepliesResponse expectedResponse = + SuggestSmartRepliesResponse.newBuilder() + .addAllSmartReplyAnswers(new ArrayList()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .build(); + mockService.addResponse(expectedResponse); + + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + + SuggestSmartRepliesResponse actualResponse = client.suggestSmartReplies(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void suggestSmartRepliesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + client.suggestSmartReplies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void suggestSmartRepliesTest2() throws Exception { + SuggestSmartRepliesResponse expectedResponse = + SuggestSmartRepliesResponse.newBuilder() + .addAllSmartReplyAnswers(new ArrayList()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-4961/conversations/conversation-4961/participants/participant-4961"; + + SuggestSmartRepliesResponse actualResponse = client.suggestSmartReplies(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void suggestSmartRepliesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-4961/conversations/conversation-4961/participants/participant-4961"; + client.suggestSmartReplies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClientHttpJsonTest.java new file mode 100644 index 000000000000..f03f0da874f2 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClientHttpJsonTest.java @@ -0,0 +1,591 @@ +/* + * Copyright 2022 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonSessionEntityTypesStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class SessionEntityTypesClientHttpJsonTest { + private static MockHttpService mockService; + private static SessionEntityTypesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSessionEntityTypesStub.getMethodDescriptors(), + SessionEntityTypesSettings.getDefaultEndpoint()); + SessionEntityTypesSettings settings = + SessionEntityTypesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SessionEntityTypesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SessionEntityTypesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listSessionEntityTypesTest() throws Exception { + SessionEntityType responsesElement = SessionEntityType.newBuilder().build(); + ListSessionEntityTypesResponse expectedResponse = + ListSessionEntityTypesResponse.newBuilder() + .setNextPageToken("") + .addAllSessionEntityTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SessionName parent = SessionName.ofProjectSessionName("[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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSessionEntityTypesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + client.listSessionEntityTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSessionEntityTypesTest2() throws Exception { + SessionEntityType responsesElement = SessionEntityType.newBuilder().build(); + ListSessionEntityTypesResponse expectedResponse = + ListSessionEntityTypesResponse.newBuilder() + .setNextPageToken("") + .addAllSessionEntityTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6494/agent/sessions/session-6494"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSessionEntityTypesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6494/agent/sessions/session-6494"; + client.listSessionEntityTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSessionEntityTypeTest() throws Exception { + SessionEntityType expectedResponse = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + SessionEntityTypeName name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + + SessionEntityType actualResponse = client.getSessionEntityType(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSessionEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionEntityTypeName name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + client.getSessionEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSessionEntityTypeTest2() throws Exception { + SessionEntityType expectedResponse = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-957/agent/sessions/session-957/entityTypes/entityType-957"; + + SessionEntityType actualResponse = client.getSessionEntityType(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSessionEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-957/agent/sessions/session-957/entityTypes/entityType-957"; + client.getSessionEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSessionEntityTypeTest() throws Exception { + SessionEntityType expectedResponse = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + + SessionEntityType actualResponse = client.createSessionEntityType(parent, sessionEntityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSessionEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + client.createSessionEntityType(parent, sessionEntityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSessionEntityTypeTest2() throws Exception { + SessionEntityType expectedResponse = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6494/agent/sessions/session-6494"; + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + + SessionEntityType actualResponse = client.createSessionEntityType(parent, sessionEntityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSessionEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6494/agent/sessions/session-6494"; + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + client.createSessionEntityType(parent, sessionEntityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSessionEntityTypeTest() throws Exception { + SessionEntityType expectedResponse = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + SessionEntityType sessionEntityType = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + + SessionEntityType actualResponse = client.updateSessionEntityType(sessionEntityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSessionEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionEntityType sessionEntityType = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + client.updateSessionEntityType(sessionEntityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSessionEntityTypeTest2() throws Exception { + SessionEntityType expectedResponse = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + SessionEntityType sessionEntityType = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + SessionEntityType actualResponse = + client.updateSessionEntityType(sessionEntityType, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSessionEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionEntityType sessionEntityType = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateSessionEntityType(sessionEntityType, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteSessionEntityTypeTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + SessionEntityTypeName name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + + client.deleteSessionEntityType(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteSessionEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionEntityTypeName name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + client.deleteSessionEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteSessionEntityTypeTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-957/agent/sessions/session-957/entityTypes/entityType-957"; + + client.deleteSessionEntityType(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteSessionEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-957/agent/sessions/session-957/entityTypes/entityType-957"; + client.deleteSessionEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionsClientHttpJsonTest.java new file mode 100644 index 000000000000..c6e7fd36cc8d --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionsClientHttpJsonTest.java @@ -0,0 +1,180 @@ +/* + * Copyright 2022 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonSessionsStub; +import com.google.protobuf.ByteString; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class SessionsClientHttpJsonTest { + private static MockHttpService mockService; + private static SessionsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSessionsStub.getMethodDescriptors(), SessionsSettings.getDefaultEndpoint()); + SessionsSettings settings = + SessionsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SessionsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SessionsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void detectIntentTest() throws Exception { + DetectIntentResponse expectedResponse = + DetectIntentResponse.newBuilder() + .setResponseId("responseId-633138884") + .setQueryResult(QueryResult.newBuilder().build()) + .setWebhookStatus(Status.newBuilder().build()) + .setOutputAudio(ByteString.EMPTY) + .setOutputAudioConfig(OutputAudioConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + SessionName session = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + QueryInput queryInput = QueryInput.newBuilder().build(); + + DetectIntentResponse actualResponse = client.detectIntent(session, queryInput); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void detectIntentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionName session = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + QueryInput queryInput = QueryInput.newBuilder().build(); + client.detectIntent(session, queryInput); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void detectIntentTest2() throws Exception { + DetectIntentResponse expectedResponse = + DetectIntentResponse.newBuilder() + .setResponseId("responseId-633138884") + .setQueryResult(QueryResult.newBuilder().build()) + .setWebhookStatus(Status.newBuilder().build()) + .setOutputAudio(ByteString.EMPTY) + .setOutputAudioConfig(OutputAudioConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String session = "projects/project-3462/agent/sessions/session-3462"; + QueryInput queryInput = QueryInput.newBuilder().build(); + + DetectIntentResponse actualResponse = client.detectIntent(session, queryInput); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void detectIntentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String session = "projects/project-3462/agent/sessions/session-3462"; + QueryInput queryInput = QueryInput.newBuilder().build(); + client.detectIntent(session, queryInput); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void streamingDetectIntentUnsupportedMethodTest() throws Exception { + // The streamingDetectIntent() method is not supported in REST transport. + // This empty test is generated for technical reasons. + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/VersionsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/VersionsClientHttpJsonTest.java new file mode 100644 index 000000000000..3a207263a0cc --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/VersionsClientHttpJsonTest.java @@ -0,0 +1,512 @@ +/* + * Copyright 2022 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.VersionsClient.ListVersionsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2.stub.HttpJsonVersionsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class VersionsClientHttpJsonTest { + private static MockHttpService mockService; + private static VersionsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonVersionsStub.getMethodDescriptors(), VersionsSettings.getDefaultEndpoint()); + VersionsSettings settings = + VersionsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + VersionsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = VersionsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listVersionsTest() throws Exception { + Version responsesElement = Version.newBuilder().build(); + ListVersionsResponse expectedResponse = + ListVersionsResponse.newBuilder() + .setNextPageToken("") + .addAllVersions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + + ListVersionsPagedResponse pagedListResponse = client.listVersions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVersionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listVersionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + client.listVersions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listVersionsTest2() throws Exception { + Version responsesElement = Version.newBuilder().build(); + ListVersionsResponse expectedResponse = + ListVersionsResponse.newBuilder() + .setNextPageToken("") + .addAllVersions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + + ListVersionsPagedResponse pagedListResponse = client.listVersions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVersionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listVersionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + client.listVersions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVersionTest() throws Exception { + Version expectedResponse = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]"); + + Version actualResponse = client.getVersion(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getVersionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]"); + client.getVersion(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVersionTest2() throws Exception { + Version expectedResponse = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9087/agent/versions/version-9087"; + + Version actualResponse = client.getVersion(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getVersionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9087/agent/versions/version-9087"; + client.getVersion(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createVersionTest() throws Exception { + Version expectedResponse = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Version version = Version.newBuilder().build(); + + Version actualResponse = client.createVersion(parent, version); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createVersionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Version version = Version.newBuilder().build(); + client.createVersion(parent, version); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createVersionTest2() throws Exception { + Version expectedResponse = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + Version version = Version.newBuilder().build(); + + Version actualResponse = client.createVersion(parent, version); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createVersionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + Version version = Version.newBuilder().build(); + client.createVersion(parent, version); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateVersionTest() throws Exception { + Version expectedResponse = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Version version = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Version actualResponse = client.updateVersion(version, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateVersionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Version version = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateVersion(version, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteVersionTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]"); + + client.deleteVersion(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteVersionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]"); + client.deleteVersion(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteVersionTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9087/agent/versions/version-9087"; + + client.deleteVersion(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteVersionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9087/agent/versions/version-9087"; + client.deleteVersion(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/AgentsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/AgentsClientHttpJsonTest.java new file mode 100644 index 000000000000..65f5f36070e4 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/AgentsClientHttpJsonTest.java @@ -0,0 +1,1002 @@ +/* + * Copyright 2022 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.v2beta1; + +import static com.google.cloud.dialogflow.v2beta1.AgentsClient.SearchAgentsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonAgentsStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class AgentsClientHttpJsonTest { + private static MockHttpService mockService; + private static AgentsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonAgentsStub.getMethodDescriptors(), AgentsSettings.getDefaultEndpoint()); + AgentsSettings settings = + AgentsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + AgentsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = AgentsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void getAgentTest() throws Exception { + Agent expectedResponse = + Agent.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setDefaultLanguageCode("defaultLanguageCode2069633606") + .addAllSupportedLanguageCodes(new ArrayList()) + .setTimeZone("timeZone-2077180903") + .setDescription("description-1724546052") + .setAvatarUri("avatarUri-428646061") + .setEnableLogging(true) + .setClassificationThreshold(1115810642) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + Agent actualResponse = client.getAgent(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.getAgent(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAgentTest2() throws Exception { + Agent expectedResponse = + Agent.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setDefaultLanguageCode("defaultLanguageCode2069633606") + .addAllSupportedLanguageCodes(new ArrayList()) + .setTimeZone("timeZone-2077180903") + .setDescription("description-1724546052") + .setAvatarUri("avatarUri-428646061") + .setEnableLogging(true) + .setClassificationThreshold(1115810642) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + Agent actualResponse = client.getAgent(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getAgentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.getAgent(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAgentTest3() throws Exception { + Agent expectedResponse = + Agent.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setDefaultLanguageCode("defaultLanguageCode2069633606") + .addAllSupportedLanguageCodes(new ArrayList()) + .setTimeZone("timeZone-2077180903") + .setDescription("description-1724546052") + .setAvatarUri("avatarUri-428646061") + .setEnableLogging(true) + .setClassificationThreshold(1115810642) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + Agent actualResponse = client.getAgent(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getAgentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.getAgent(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setAgentTest() throws Exception { + Agent expectedResponse = + Agent.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setDefaultLanguageCode("defaultLanguageCode2069633606") + .addAllSupportedLanguageCodes(new ArrayList()) + .setTimeZone("timeZone-2077180903") + .setDescription("description-1724546052") + .setAvatarUri("avatarUri-428646061") + .setEnableLogging(true) + .setClassificationThreshold(1115810642) + .build(); + mockService.addResponse(expectedResponse); + + Agent agent = + Agent.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setDefaultLanguageCode("defaultLanguageCode2069633606") + .addAllSupportedLanguageCodes(new ArrayList()) + .setTimeZone("timeZone-2077180903") + .setDescription("description-1724546052") + .setAvatarUri("avatarUri-428646061") + .setEnableLogging(true) + .setClassificationThreshold(1115810642) + .build(); + + Agent actualResponse = client.setAgent(agent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Agent agent = + Agent.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setDefaultLanguageCode("defaultLanguageCode2069633606") + .addAllSupportedLanguageCodes(new ArrayList()) + .setTimeZone("timeZone-2077180903") + .setDescription("description-1724546052") + .setAvatarUri("avatarUri-428646061") + .setEnableLogging(true) + .setClassificationThreshold(1115810642) + .build(); + client.setAgent(agent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteAgentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + client.deleteAgent(parent); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.deleteAgent(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteAgentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + client.deleteAgent(parent); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteAgentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.deleteAgent(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteAgentTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + client.deleteAgent(parent); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteAgentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.deleteAgent(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void searchAgentsTest() throws Exception { + Agent responsesElement = Agent.newBuilder().build(); + SearchAgentsResponse expectedResponse = + SearchAgentsResponse.newBuilder() + .setNextPageToken("") + .addAllAgents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void searchAgentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.searchAgents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void searchAgentsTest2() throws Exception { + Agent responsesElement = Agent.newBuilder().build(); + SearchAgentsResponse expectedResponse = + SearchAgentsResponse.newBuilder() + .setNextPageToken("") + .addAllAgents(Arrays.asList(responsesElement)) + .build(); + mockService.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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void searchAgentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.searchAgents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void searchAgentsTest3() throws Exception { + Agent responsesElement = Agent.newBuilder().build(); + SearchAgentsResponse expectedResponse = + SearchAgentsResponse.newBuilder() + .setNextPageToken("") + .addAllAgents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void searchAgentsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.searchAgents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void trainAgentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("trainAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + client.trainAgentAsync(parent).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void trainAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.trainAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void trainAgentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("trainAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + client.trainAgentAsync(parent).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void trainAgentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.trainAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void trainAgentTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("trainAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2353"; + + client.trainAgentAsync(parent).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void trainAgentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.trainAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportAgentTest() throws Exception { + ExportAgentResponse expectedResponse = ExportAgentResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ExportAgentResponse actualResponse = client.exportAgentAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void exportAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.exportAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportAgentTest2() throws Exception { + ExportAgentResponse expectedResponse = ExportAgentResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ExportAgentResponse actualResponse = client.exportAgentAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void exportAgentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.exportAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportAgentTest3() throws Exception { + ExportAgentResponse expectedResponse = ExportAgentResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2353"; + + ExportAgentResponse actualResponse = client.exportAgentAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void exportAgentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.exportAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importAgentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportAgentRequest request = + ImportAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + + client.importAgentAsync(request).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportAgentRequest request = + ImportAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + client.importAgentAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void restoreAgentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("restoreAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RestoreAgentRequest request = + RestoreAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + + client.restoreAgentAsync(request).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void restoreAgentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestoreAgentRequest request = + RestoreAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .build(); + client.restoreAgentAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getValidationResultTest() throws Exception { + ValidationResult expectedResponse = + ValidationResult.newBuilder() + .addAllValidationErrors(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + GetValidationResultRequest request = + GetValidationResultRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .build(); + + ValidationResult actualResponse = client.getValidationResult(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getValidationResultExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetValidationResultRequest request = + GetValidationResultRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .build(); + client.getValidationResult(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/AnswerRecordsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/AnswerRecordsClientHttpJsonTest.java new file mode 100644 index 000000000000..5157aa9c83b2 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/AnswerRecordsClientHttpJsonTest.java @@ -0,0 +1,342 @@ +/* + * Copyright 2022 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.v2beta1; + +import static com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient.ListAnswerRecordsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonAnswerRecordsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class AnswerRecordsClientHttpJsonTest { + private static MockHttpService mockService; + private static AnswerRecordsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonAnswerRecordsStub.getMethodDescriptors(), + AnswerRecordsSettings.getDefaultEndpoint()); + AnswerRecordsSettings settings = + AnswerRecordsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + AnswerRecordsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = AnswerRecordsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void getAnswerRecordTest() throws Exception { + AnswerRecord expectedResponse = + AnswerRecord.newBuilder() + .setName( + AnswerRecordName.ofProjectAnswerRecordName("[PROJECT]", "[ANSWER_RECORD]") + .toString()) + .setAnswerFeedback(AnswerFeedback.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetAnswerRecordRequest request = + GetAnswerRecordRequest.newBuilder() + .setName("projects/project-7424/answerRecords/answerRecord-7424") + .build(); + + AnswerRecord actualResponse = client.getAnswerRecord(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getAnswerRecordExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetAnswerRecordRequest request = + GetAnswerRecordRequest.newBuilder() + .setName("projects/project-7424/answerRecords/answerRecord-7424") + .build(); + client.getAnswerRecord(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAnswerRecordsTest() throws Exception { + AnswerRecord responsesElement = AnswerRecord.newBuilder().build(); + ListAnswerRecordsResponse expectedResponse = + ListAnswerRecordsResponse.newBuilder() + .setNextPageToken("") + .addAllAnswerRecords(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListAnswerRecordsPagedResponse pagedListResponse = client.listAnswerRecords(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getAnswerRecordsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAnswerRecordsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listAnswerRecords(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAnswerRecordsTest2() throws Exception { + AnswerRecord responsesElement = AnswerRecord.newBuilder().build(); + ListAnswerRecordsResponse expectedResponse = + ListAnswerRecordsResponse.newBuilder() + .setNextPageToken("") + .addAllAnswerRecords(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListAnswerRecordsPagedResponse pagedListResponse = client.listAnswerRecords(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getAnswerRecordsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAnswerRecordsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listAnswerRecords(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAnswerRecordsTest3() throws Exception { + AnswerRecord responsesElement = AnswerRecord.newBuilder().build(); + ListAnswerRecordsResponse expectedResponse = + ListAnswerRecordsResponse.newBuilder() + .setNextPageToken("") + .addAllAnswerRecords(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListAnswerRecordsPagedResponse pagedListResponse = client.listAnswerRecords(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getAnswerRecordsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAnswerRecordsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listAnswerRecords(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateAnswerRecordTest() throws Exception { + AnswerRecord expectedResponse = + AnswerRecord.newBuilder() + .setName( + AnswerRecordName.ofProjectAnswerRecordName("[PROJECT]", "[ANSWER_RECORD]") + .toString()) + .setAnswerFeedback(AnswerFeedback.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + AnswerRecord answerRecord = + AnswerRecord.newBuilder() + .setName( + AnswerRecordName.ofProjectAnswerRecordName("[PROJECT]", "[ANSWER_RECORD]") + .toString()) + .setAnswerFeedback(AnswerFeedback.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + AnswerRecord actualResponse = client.updateAnswerRecord(answerRecord, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateAnswerRecordExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AnswerRecord answerRecord = + AnswerRecord.newBuilder() + .setName( + AnswerRecordName.ofProjectAnswerRecordName("[PROJECT]", "[ANSWER_RECORD]") + .toString()) + .setAnswerFeedback(AnswerFeedback.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateAnswerRecord(answerRecord, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ContextsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ContextsClientHttpJsonTest.java new file mode 100644 index 000000000000..b47b5c8af3c1 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ContextsClientHttpJsonTest.java @@ -0,0 +1,665 @@ +/* + * Copyright 2022 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.v2beta1; + +import static com.google.cloud.dialogflow.v2beta1.ContextsClient.ListContextsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonContextsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ContextsClientHttpJsonTest { + private static MockHttpService mockService; + private static ContextsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonContextsStub.getMethodDescriptors(), ContextsSettings.getDefaultEndpoint()); + ContextsSettings settings = + ContextsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ContextsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ContextsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listContextsTest() throws Exception { + Context responsesElement = Context.newBuilder().build(); + ListContextsResponse expectedResponse = + ListContextsResponse.newBuilder() + .setNextPageToken("") + .addAllContexts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SessionName parent = SessionName.ofProjectSessionName("[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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listContextsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + client.listContexts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listContextsTest2() throws Exception { + Context responsesElement = Context.newBuilder().build(); + ListContextsResponse expectedResponse = + ListContextsResponse.newBuilder() + .setNextPageToken("") + .addAllContexts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6494/agent/sessions/session-6494"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listContextsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6494/agent/sessions/session-6494"; + client.listContexts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getContextTest() throws Exception { + Context expectedResponse = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ContextName name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"); + + Context actualResponse = client.getContext(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getContextExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ContextName name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"); + client.getContext(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getContextTest2() throws Exception { + Context expectedResponse = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-8115/agent/sessions/session-8115/contexts/context-8115"; + + Context actualResponse = client.getContext(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getContextExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-8115/agent/sessions/session-8115/contexts/context-8115"; + client.getContext(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createContextTest() throws Exception { + Context expectedResponse = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + Context context = Context.newBuilder().build(); + + Context actualResponse = client.createContext(parent, context); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createContextExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + Context context = Context.newBuilder().build(); + client.createContext(parent, context); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createContextTest2() throws Exception { + Context expectedResponse = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6494/agent/sessions/session-6494"; + Context context = Context.newBuilder().build(); + + Context actualResponse = client.createContext(parent, context); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createContextExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6494/agent/sessions/session-6494"; + Context context = Context.newBuilder().build(); + client.createContext(parent, context); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateContextTest() throws Exception { + Context expectedResponse = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Context context = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + + Context actualResponse = client.updateContext(context); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateContextExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Context context = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + client.updateContext(context); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateContextTest2() throws Exception { + Context expectedResponse = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Context context = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Context actualResponse = client.updateContext(context, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateContextExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Context context = + Context.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .setLifespanCount(1178775510) + .setParameters(Struct.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateContext(context, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteContextTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ContextName name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"); + + client.deleteContext(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteContextExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ContextName name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"); + client.deleteContext(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteContextTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-8115/agent/sessions/session-8115/contexts/context-8115"; + + client.deleteContext(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteContextExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-8115/agent/sessions/session-8115/contexts/context-8115"; + client.deleteContext(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteAllContextsTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + + client.deleteAllContexts(parent); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteAllContextsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + client.deleteAllContexts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteAllContextsTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6494/agent/sessions/session-6494"; + + client.deleteAllContexts(parent); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteAllContextsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6494/agent/sessions/session-6494"; + client.deleteAllContexts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ConversationProfilesClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ConversationProfilesClientHttpJsonTest.java new file mode 100644 index 000000000000..f8f07c0e6406 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ConversationProfilesClientHttpJsonTest.java @@ -0,0 +1,870 @@ +/* + * Copyright 2022 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.v2beta1; + +import static com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient.ListConversationProfilesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonConversationProfilesStub; +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.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ConversationProfilesClientHttpJsonTest { + private static MockHttpService mockService; + private static ConversationProfilesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonConversationProfilesStub.getMethodDescriptors(), + ConversationProfilesSettings.getDefaultEndpoint()); + ConversationProfilesSettings settings = + ConversationProfilesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ConversationProfilesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ConversationProfilesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listConversationProfilesTest() throws Exception { + ConversationProfile responsesElement = ConversationProfile.newBuilder().build(); + ListConversationProfilesResponse expectedResponse = + ListConversationProfilesResponse.newBuilder() + .setNextPageToken("") + .addAllConversationProfiles(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListConversationProfilesPagedResponse pagedListResponse = + client.listConversationProfiles(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationProfilesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationProfilesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listConversationProfiles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationProfilesTest2() throws Exception { + ConversationProfile responsesElement = ConversationProfile.newBuilder().build(); + ListConversationProfilesResponse expectedResponse = + ListConversationProfilesResponse.newBuilder() + .setNextPageToken("") + .addAllConversationProfiles(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListConversationProfilesPagedResponse pagedListResponse = + client.listConversationProfiles(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationProfilesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationProfilesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listConversationProfiles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationProfilesTest3() throws Exception { + ConversationProfile responsesElement = ConversationProfile.newBuilder().build(); + ListConversationProfilesResponse expectedResponse = + ListConversationProfilesResponse.newBuilder() + .setNextPageToken("") + .addAllConversationProfiles(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListConversationProfilesPagedResponse pagedListResponse = + client.listConversationProfiles(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationProfilesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationProfilesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listConversationProfiles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConversationProfileTest() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + mockService.addResponse(expectedResponse); + + ConversationProfileName name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]"); + + ConversationProfile actualResponse = client.getConversationProfile(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getConversationProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationProfileName name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]"); + client.getConversationProfile(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConversationProfileTest2() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-695/conversationProfiles/conversationProfile-695"; + + ConversationProfile actualResponse = client.getConversationProfile(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getConversationProfileExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-695/conversationProfiles/conversationProfile-695"; + client.getConversationProfile(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConversationProfileTest() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + + ConversationProfile actualResponse = + client.createConversationProfile(parent, conversationProfile); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + client.createConversationProfile(parent, conversationProfile); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConversationProfileTest2() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + + ConversationProfile actualResponse = + client.createConversationProfile(parent, conversationProfile); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationProfileExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + client.createConversationProfile(parent, conversationProfile); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConversationProfileTest3() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + + ConversationProfile actualResponse = + client.createConversationProfile(parent, conversationProfile); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationProfileExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + client.createConversationProfile(parent, conversationProfile); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateConversationProfileTest() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + mockService.addResponse(expectedResponse); + + ConversationProfile conversationProfile = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ConversationProfile actualResponse = + client.updateConversationProfile(conversationProfile, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateConversationProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationProfile conversationProfile = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateConversationProfile(conversationProfile, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteConversationProfileTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ConversationProfileName name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]"); + + client.deleteConversationProfile(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteConversationProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationProfileName name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]"); + client.deleteConversationProfile(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteConversationProfileTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-695/conversationProfiles/conversationProfile-695"; + + client.deleteConversationProfile(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteConversationProfileExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-695/conversationProfiles/conversationProfile-695"; + client.deleteConversationProfile(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setSuggestionFeatureConfigTest() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("setSuggestionFeatureConfigTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String conversationProfile = + "projects/project-4204/conversationProfiles/conversationProfile-4204"; + + ConversationProfile actualResponse = + client.setSuggestionFeatureConfigAsync(conversationProfile).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setSuggestionFeatureConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String conversationProfile = + "projects/project-4204/conversationProfiles/conversationProfile-4204"; + client.setSuggestionFeatureConfigAsync(conversationProfile).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void clearSuggestionFeatureConfigTest() throws Exception { + ConversationProfile expectedResponse = + ConversationProfile.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAutomatedAgentConfig(AutomatedAgentConfig.newBuilder().build()) + .setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().build()) + .setHumanAgentHandoffConfig(HumanAgentHandoffConfig.newBuilder().build()) + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setLoggingConfig(LoggingConfig.newBuilder().build()) + .setNewMessageEventNotificationConfig(NotificationConfig.newBuilder().build()) + .setSttConfig(SpeechToTextConfig.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setTimeZone("timeZone-2077180903") + .setSecuritySettings("securitySettings-1062971517") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("clearSuggestionFeatureConfigTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String conversationProfile = + "projects/project-4204/conversationProfiles/conversationProfile-4204"; + + ConversationProfile actualResponse = + client.clearSuggestionFeatureConfigAsync(conversationProfile).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void clearSuggestionFeatureConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String conversationProfile = + "projects/project-4204/conversationProfiles/conversationProfile-4204"; + client.clearSuggestionFeatureConfigAsync(conversationProfile).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ConversationsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ConversationsClientHttpJsonTest.java new file mode 100644 index 000000000000..cb404620267d --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ConversationsClientHttpJsonTest.java @@ -0,0 +1,799 @@ +/* + * Copyright 2022 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.v2beta1; + +import static com.google.cloud.dialogflow.v2beta1.ConversationsClient.ListConversationsPagedResponse; +import static com.google.cloud.dialogflow.v2beta1.ConversationsClient.ListMessagesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonConversationsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ConversationsClientHttpJsonTest { + private static MockHttpService mockService; + private static ConversationsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonConversationsStub.getMethodDescriptors(), + ConversationsSettings.getDefaultEndpoint()); + ConversationsSettings settings = + ConversationsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ConversationsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ConversationsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createConversationTest() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Conversation conversation = Conversation.newBuilder().build(); + + Conversation actualResponse = client.createConversation(parent, conversation); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Conversation conversation = Conversation.newBuilder().build(); + client.createConversation(parent, conversation); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConversationTest2() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + Conversation conversation = Conversation.newBuilder().build(); + + Conversation actualResponse = client.createConversation(parent, conversation); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + Conversation conversation = Conversation.newBuilder().build(); + client.createConversation(parent, conversation); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConversationTest3() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + Conversation conversation = Conversation.newBuilder().build(); + + Conversation actualResponse = client.createConversation(parent, conversation); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createConversationExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + Conversation conversation = Conversation.newBuilder().build(); + client.createConversation(parent, conversation); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationsTest() throws Exception { + Conversation responsesElement = Conversation.newBuilder().build(); + ListConversationsResponse expectedResponse = + ListConversationsResponse.newBuilder() + .setNextPageToken("") + .addAllConversations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListConversationsPagedResponse pagedListResponse = client.listConversations(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listConversations(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationsTest2() throws Exception { + Conversation responsesElement = Conversation.newBuilder().build(); + ListConversationsResponse expectedResponse = + ListConversationsResponse.newBuilder() + .setNextPageToken("") + .addAllConversations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListConversationsPagedResponse pagedListResponse = client.listConversations(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listConversations(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConversationsTest3() throws Exception { + Conversation responsesElement = Conversation.newBuilder().build(); + ListConversationsResponse expectedResponse = + ListConversationsResponse.newBuilder() + .setNextPageToken("") + .addAllConversations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListConversationsPagedResponse pagedListResponse = client.listConversations(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConversationsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listConversationsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listConversations(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConversationTest() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ConversationName name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + + Conversation actualResponse = client.getConversation(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getConversationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationName name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + client.getConversation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConversationTest2() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3460/conversations/conversation-3460"; + + Conversation actualResponse = client.getConversation(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getConversationExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3460/conversations/conversation-3460"; + client.getConversation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void completeConversationTest() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ConversationName name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + + Conversation actualResponse = client.completeConversation(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void completeConversationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationName name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + client.completeConversation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void completeConversationTest2() throws Exception { + Conversation expectedResponse = + Conversation.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setConversationProfile( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .setPhoneNumber(ConversationPhoneNumber.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3460/conversations/conversation-3460"; + + Conversation actualResponse = client.completeConversation(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void completeConversationExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3460/conversations/conversation-3460"; + client.completeConversation(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchCreateMessagesTest() throws Exception { + BatchCreateMessagesResponse expectedResponse = + BatchCreateMessagesResponse.newBuilder().addAllMessages(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + + BatchCreateMessagesResponse actualResponse = client.batchCreateMessages(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchCreateMessagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + client.batchCreateMessages(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchCreateMessagesTest2() throws Exception { + BatchCreateMessagesResponse expectedResponse = + BatchCreateMessagesResponse.newBuilder().addAllMessages(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-4379/conversations/conversation-4379"; + + BatchCreateMessagesResponse actualResponse = client.batchCreateMessages(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchCreateMessagesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-4379/conversations/conversation-4379"; + client.batchCreateMessages(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listMessagesTest() throws Exception { + Message responsesElement = Message.newBuilder().build(); + ListMessagesResponse expectedResponse = + ListMessagesResponse.newBuilder() + .setNextPageToken("") + .addAllMessages(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + + ListMessagesPagedResponse pagedListResponse = client.listMessages(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getMessagesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listMessagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + client.listMessages(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listMessagesTest2() throws Exception { + Message responsesElement = Message.newBuilder().build(); + ListMessagesResponse expectedResponse = + ListMessagesResponse.newBuilder() + .setNextPageToken("") + .addAllMessages(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-4379/conversations/conversation-4379"; + + ListMessagesPagedResponse pagedListResponse = client.listMessages(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getMessagesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listMessagesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-4379/conversations/conversation-4379"; + client.listMessages(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/DocumentsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/DocumentsClientHttpJsonTest.java new file mode 100644 index 000000000000..0192016cb2e3 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/DocumentsClientHttpJsonTest.java @@ -0,0 +1,866 @@ +/* + * Copyright 2022 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.v2beta1; + +import static com.google.cloud.dialogflow.v2beta1.DocumentsClient.ListDocumentsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonDocumentsStub; +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.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class DocumentsClientHttpJsonTest { + private static MockHttpService mockService; + private static DocumentsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonDocumentsStub.getMethodDescriptors(), DocumentsSettings.getDefaultEndpoint()); + DocumentsSettings settings = + DocumentsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + DocumentsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DocumentsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listDocumentsTest() throws Exception { + Document responsesElement = Document.newBuilder().build(); + ListDocumentsResponse expectedResponse = + ListDocumentsResponse.newBuilder() + .setNextPageToken("") + .addAllDocuments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + KnowledgeBaseName parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + + ListDocumentsPagedResponse pagedListResponse = client.listDocuments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDocumentsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + KnowledgeBaseName parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + client.listDocuments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDocumentsTest2() throws Exception { + Document responsesElement = Document.newBuilder().build(); + ListDocumentsResponse expectedResponse = + ListDocumentsResponse.newBuilder() + .setNextPageToken("") + .addAllDocuments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-8161/knowledgeBases/knowledgeBase-8161"; + + ListDocumentsPagedResponse pagedListResponse = client.listDocuments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDocumentsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDocumentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-8161/knowledgeBases/knowledgeBase-8161"; + client.listDocuments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + + Document actualResponse = client.getDocument(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + client.getDocument(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDocumentTest2() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-5854/knowledgeBases/knowledgeBase-5854/documents/document-5854"; + + Document actualResponse = client.getDocument(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5854/knowledgeBases/knowledgeBase-5854/documents/document-5854"; + client.getDocument(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + KnowledgeBaseName parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + Document document = Document.newBuilder().build(); + + Document actualResponse = client.createDocumentAsync(parent, document).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + KnowledgeBaseName parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + Document document = Document.newBuilder().build(); + client.createDocumentAsync(parent, document).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createDocumentTest2() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-8161/knowledgeBases/knowledgeBase-8161"; + Document document = Document.newBuilder().build(); + + Document actualResponse = client.createDocumentAsync(parent, document).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-8161/knowledgeBases/knowledgeBase-8161"; + Document document = Document.newBuilder().build(); + client.createDocumentAsync(parent, document).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importDocumentsTest() throws Exception { + ImportDocumentsResponse expectedResponse = + ImportDocumentsResponse.newBuilder().addAllWarnings(new ArrayList()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ImportDocumentsRequest request = + ImportDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocumentTemplate(ImportDocumentTemplate.newBuilder().build()) + .setImportGcsCustomMetadata(true) + .build(); + + ImportDocumentsResponse actualResponse = client.importDocumentsAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ImportDocumentsRequest request = + ImportDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocumentTemplate(ImportDocumentTemplate.newBuilder().build()) + .setImportGcsCustomMetadata(true) + .build(); + client.importDocumentsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteDocumentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + + client.deleteDocumentAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + client.deleteDocumentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteDocumentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-5854/knowledgeBases/knowledgeBase-5854/documents/document-5854"; + + client.deleteDocumentAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5854/knowledgeBases/knowledgeBase-5854/documents/document-5854"; + client.deleteDocumentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Document document = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + + Document actualResponse = client.updateDocumentAsync(document).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Document document = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + client.updateDocumentAsync(document).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateDocumentTest2() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Document document = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Document actualResponse = client.updateDocumentAsync(document, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Document document = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateDocumentAsync(document, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void reloadDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("reloadDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + GcsSource gcsSource = GcsSource.newBuilder().build(); + + Document actualResponse = client.reloadDocumentAsync(name, gcsSource).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void reloadDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + GcsSource gcsSource = GcsSource.newBuilder().build(); + client.reloadDocumentAsync(name, gcsSource).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void reloadDocumentTest2() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setDisplayName("displayName1714148973") + .setMimeType("mimeType-1392120434") + .addAllKnowledgeTypes(new ArrayList()) + .setEnableAutoReload(true) + .setLatestReloadStatus(Document.ReloadStatus.newBuilder().build()) + .putAllMetadata(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("reloadDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-5854/knowledgeBases/knowledgeBase-5854/documents/document-5854"; + GcsSource gcsSource = GcsSource.newBuilder().build(); + + Document actualResponse = client.reloadDocumentAsync(name, gcsSource).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void reloadDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5854/knowledgeBases/knowledgeBase-5854/documents/document-5854"; + GcsSource gcsSource = GcsSource.newBuilder().build(); + client.reloadDocumentAsync(name, gcsSource).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/EntityTypesClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/EntityTypesClientHttpJsonTest.java new file mode 100644 index 000000000000..90d4867152a2 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/EntityTypesClientHttpJsonTest.java @@ -0,0 +1,1689 @@ +/* + * Copyright 2022 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.v2beta1; + +import static com.google.cloud.dialogflow.v2beta1.EntityTypesClient.ListEntityTypesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonEntityTypesStub; +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 java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class EntityTypesClientHttpJsonTest { + private static MockHttpService mockService; + private static EntityTypesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonEntityTypesStub.getMethodDescriptors(), + EntityTypesSettings.getDefaultEndpoint()); + EntityTypesSettings settings = + EntityTypesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + EntityTypesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = EntityTypesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listEntityTypesTest() throws Exception { + EntityType responsesElement = EntityType.newBuilder().build(); + ListEntityTypesResponse expectedResponse = + ListEntityTypesResponse.newBuilder() + .setNextPageToken("") + .addAllEntityTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEntityTypesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + client.listEntityTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEntityTypesTest2() throws Exception { + EntityType responsesElement = EntityType.newBuilder().build(); + ListEntityTypesResponse expectedResponse = + ListEntityTypesResponse.newBuilder() + .setNextPageToken("") + .addAllEntityTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEntityTypesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + client.listEntityTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEntityTypesTest3() throws Exception { + EntityType responsesElement = EntityType.newBuilder().build(); + ListEntityTypesResponse expectedResponse = + ListEntityTypesResponse.newBuilder() + .setNextPageToken("") + .addAllEntityTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String languageCode = "languageCode-2092349083"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEntityTypesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String languageCode = "languageCode-2092349083"; + client.listEntityTypes(parent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEntityTypesTest4() throws Exception { + EntityType responsesElement = EntityType.newBuilder().build(); + ListEntityTypesResponse expectedResponse = + ListEntityTypesResponse.newBuilder() + .setNextPageToken("") + .addAllEntityTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + String languageCode = "languageCode-2092349083"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEntityTypesExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + String languageCode = "languageCode-2092349083"; + client.listEntityTypes(parent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEntityTypeTest() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + + EntityType actualResponse = client.getEntityType(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + client.getEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEntityTypeTest2() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3464/agent/entityTypes/entityType-3464"; + + EntityType actualResponse = client.getEntityType(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3464/agent/entityTypes/entityType-3464"; + client.getEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEntityTypeTest3() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + String languageCode = "languageCode-2092349083"; + + EntityType actualResponse = client.getEntityType(name, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEntityTypeExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + String languageCode = "languageCode-2092349083"; + client.getEntityType(name, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEntityTypeTest4() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3464/agent/entityTypes/entityType-3464"; + String languageCode = "languageCode-2092349083"; + + EntityType actualResponse = client.getEntityType(name, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEntityTypeExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3464/agent/entityTypes/entityType-3464"; + String languageCode = "languageCode-2092349083"; + client.getEntityType(name, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEntityTypeTest() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + + EntityType actualResponse = client.createEntityType(parent, entityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + client.createEntityType(parent, entityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEntityTypeTest2() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + EntityType entityType = EntityType.newBuilder().build(); + + EntityType actualResponse = client.createEntityType(parent, entityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + EntityType entityType = EntityType.newBuilder().build(); + client.createEntityType(parent, entityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEntityTypeTest3() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + + EntityType actualResponse = client.createEntityType(parent, entityType, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEntityTypeExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + client.createEntityType(parent, entityType, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEntityTypeTest4() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + + EntityType actualResponse = client.createEntityType(parent, entityType, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEntityTypeExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + client.createEntityType(parent, entityType, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateEntityTypeTest() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + EntityType entityType = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + + EntityType actualResponse = client.updateEntityType(entityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityType entityType = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + client.updateEntityType(entityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateEntityTypeTest2() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + EntityType entityType = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + String languageCode = "languageCode-2092349083"; + + EntityType actualResponse = client.updateEntityType(entityType, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityType entityType = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + String languageCode = "languageCode-2092349083"; + client.updateEntityType(entityType, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateEntityTypeTest3() throws Exception { + EntityType expectedResponse = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + mockService.addResponse(expectedResponse); + + EntityType entityType = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + String languageCode = "languageCode-2092349083"; + FieldMask updateMask = FieldMask.newBuilder().build(); + + EntityType actualResponse = client.updateEntityType(entityType, languageCode, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateEntityTypeExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityType entityType = + EntityType.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setDisplayName("displayName1714148973") + .addAllEntities(new ArrayList()) + .setEnableFuzzyExtraction(true) + .build(); + String languageCode = "languageCode-2092349083"; + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateEntityType(entityType, languageCode, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteEntityTypeTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + + client.deleteEntityType(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + client.deleteEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteEntityTypeTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3464/agent/entityTypes/entityType-3464"; + + client.deleteEntityType(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3464/agent/entityTypes/entityType-3464"; + client.deleteEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchUpdateEntityTypesTest() throws Exception { + BatchUpdateEntityTypesResponse expectedResponse = + BatchUpdateEntityTypesResponse.newBuilder() + .addAllEntityTypes(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateEntityTypesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + BatchUpdateEntityTypesRequest request = + BatchUpdateEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + BatchUpdateEntityTypesResponse actualResponse = + client.batchUpdateEntityTypesAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateEntityTypesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BatchUpdateEntityTypesRequest request = + BatchUpdateEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.batchUpdateEntityTypesAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteEntityTypesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntityTypesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + List entityTypeNames = new ArrayList<>(); + + client.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteEntityTypesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + List entityTypeNames = new ArrayList<>(); + client.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteEntityTypesTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntityTypesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2469/agent"; + List entityTypeNames = new ArrayList<>(); + + client.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteEntityTypesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + List entityTypeNames = new ArrayList<>(); + client.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchCreateEntitiesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchCreateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + + client.batchCreateEntitiesAsync(parent, entities).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchCreateEntitiesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + client.batchCreateEntitiesAsync(parent, entities).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchCreateEntitiesTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchCreateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + + client.batchCreateEntitiesAsync(parent, entities).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchCreateEntitiesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + client.batchCreateEntitiesAsync(parent, entities).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchCreateEntitiesTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchCreateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + + client.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchCreateEntitiesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + client.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchCreateEntitiesTest4() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchCreateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + + client.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchCreateEntitiesExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + client.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateEntitiesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + + client.batchUpdateEntitiesAsync(parent, entities).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateEntitiesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + client.batchUpdateEntitiesAsync(parent, entities).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateEntitiesTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + + client.batchUpdateEntitiesAsync(parent, entities).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateEntitiesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + client.batchUpdateEntitiesAsync(parent, entities).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateEntitiesTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + + client.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateEntitiesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + client.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateEntitiesTest4() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + + client.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateEntitiesExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + client.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteEntitiesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + + client.batchDeleteEntitiesAsync(parent, entityValues).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteEntitiesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + client.batchDeleteEntitiesAsync(parent, entityValues).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteEntitiesTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entityValues = new ArrayList<>(); + + client.batchDeleteEntitiesAsync(parent, entityValues).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteEntitiesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entityValues = new ArrayList<>(); + client.batchDeleteEntitiesAsync(parent, entityValues).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteEntitiesTest3() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + + client.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteEntitiesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + client.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteEntitiesTest4() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + + client.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteEntitiesExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2105/agent/entityTypes/entityType-2105"; + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + client.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/EnvironmentsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/EnvironmentsClientHttpJsonTest.java new file mode 100644 index 000000000000..3879e82e50a8 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/EnvironmentsClientHttpJsonTest.java @@ -0,0 +1,491 @@ +/* + * Copyright 2022 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.v2beta1; + +import static com.google.cloud.dialogflow.v2beta1.EnvironmentsClient.GetEnvironmentHistoryPagedResponse; +import static com.google.cloud.dialogflow.v2beta1.EnvironmentsClient.ListEnvironmentsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonEnvironmentsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class EnvironmentsClientHttpJsonTest { + private static MockHttpService mockService; + private static EnvironmentsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonEnvironmentsStub.getMethodDescriptors(), + EnvironmentsSettings.getDefaultEndpoint()); + EnvironmentsSettings settings = + EnvironmentsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + EnvironmentsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = EnvironmentsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listEnvironmentsTest() throws Exception { + Environment responsesElement = Environment.newBuilder().build(); + ListEnvironmentsResponse expectedResponse = + ListEnvironmentsResponse.newBuilder() + .setNextPageToken("") + .addAllEnvironments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + + ListEnvironmentsPagedResponse pagedListResponse = client.listEnvironments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEnvironmentsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEnvironmentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + client.listEnvironments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEnvironmentsTest2() throws Exception { + Environment responsesElement = Environment.newBuilder().build(); + ListEnvironmentsResponse expectedResponse = + ListEnvironmentsResponse.newBuilder() + .setNextPageToken("") + .addAllEnvironments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + + ListEnvironmentsPagedResponse pagedListResponse = client.listEnvironments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEnvironmentsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEnvironmentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + client.listEnvironments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEnvironmentTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setDescription("description-1724546052") + .setAgentVersion(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setTextToSpeechSettings(TextToSpeechSettings.newBuilder().build()) + .setFulfillment(Fulfillment.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + + Environment actualResponse = client.getEnvironment(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + client.getEnvironment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEnvironmentTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setDescription("description-1724546052") + .setAgentVersion(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setTextToSpeechSettings(TextToSpeechSettings.newBuilder().build()) + .setFulfillment(Fulfillment.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setEnvironment(Environment.newBuilder().build()) + .setEnvironmentId("environmentId-950205810") + .build(); + + Environment actualResponse = client.createEnvironment(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setEnvironment(Environment.newBuilder().build()) + .setEnvironmentId("environmentId-950205810") + .build(); + client.createEnvironment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateEnvironmentTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setDescription("description-1724546052") + .setAgentVersion(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setTextToSpeechSettings(TextToSpeechSettings.newBuilder().build()) + .setFulfillment(Fulfillment.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setEnvironment( + Environment.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]") + .toString()) + .setDescription("description-1724546052") + .setAgentVersion( + VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setTextToSpeechSettings(TextToSpeechSettings.newBuilder().build()) + .setFulfillment(Fulfillment.newBuilder().build()) + .build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowLoadToDraftAndDiscardChanges(true) + .build(); + + Environment actualResponse = client.updateEnvironment(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setEnvironment( + Environment.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]") + .toString()) + .setDescription("description-1724546052") + .setAgentVersion( + VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setTextToSpeechSettings(TextToSpeechSettings.newBuilder().build()) + .setFulfillment(Fulfillment.newBuilder().build()) + .build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowLoadToDraftAndDiscardChanges(true) + .build(); + client.updateEnvironment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteEnvironmentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + + client.deleteEnvironment(request); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + client.deleteEnvironment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEnvironmentHistoryTest() throws Exception { + EnvironmentHistory.Entry responsesElement = EnvironmentHistory.Entry.newBuilder().build(); + EnvironmentHistory expectedResponse = + EnvironmentHistory.newBuilder() + .setNextPageToken("") + .addAllEntries(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + GetEnvironmentHistoryRequest request = + GetEnvironmentHistoryRequest.newBuilder() + .setParent( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + GetEnvironmentHistoryPagedResponse pagedListResponse = client.getEnvironmentHistory(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEntriesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEnvironmentHistoryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetEnvironmentHistoryRequest request = + GetEnvironmentHistoryRequest.newBuilder() + .setParent( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.getEnvironmentHistory(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/FulfillmentsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/FulfillmentsClientHttpJsonTest.java new file mode 100644 index 000000000000..62e1222c3c58 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/FulfillmentsClientHttpJsonTest.java @@ -0,0 +1,230 @@ +/* + * Copyright 2022 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.v2beta1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonFulfillmentsStub; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class FulfillmentsClientHttpJsonTest { + private static MockHttpService mockService; + private static FulfillmentsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonFulfillmentsStub.getMethodDescriptors(), + FulfillmentsSettings.getDefaultEndpoint()); + FulfillmentsSettings settings = + FulfillmentsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + FulfillmentsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = FulfillmentsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void getFulfillmentTest() throws Exception { + Fulfillment expectedResponse = + Fulfillment.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setEnabled(true) + .addAllFeatures(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + FulfillmentName name = FulfillmentName.ofProjectName("[PROJECT]"); + + Fulfillment actualResponse = client.getFulfillment(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getFulfillmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FulfillmentName name = FulfillmentName.ofProjectName("[PROJECT]"); + client.getFulfillment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFulfillmentTest2() throws Exception { + Fulfillment expectedResponse = + Fulfillment.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setEnabled(true) + .addAllFeatures(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2293/agent/fulfillment"; + + Fulfillment actualResponse = client.getFulfillment(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getFulfillmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2293/agent/fulfillment"; + client.getFulfillment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateFulfillmentTest() throws Exception { + Fulfillment expectedResponse = + Fulfillment.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setEnabled(true) + .addAllFeatures(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Fulfillment fulfillment = + Fulfillment.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setEnabled(true) + .addAllFeatures(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Fulfillment actualResponse = client.updateFulfillment(fulfillment, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateFulfillmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Fulfillment fulfillment = + Fulfillment.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .setDisplayName("displayName1714148973") + .setEnabled(true) + .addAllFeatures(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateFulfillment(fulfillment, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/IntentsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/IntentsClientHttpJsonTest.java new file mode 100644 index 000000000000..ea5ad5296bbf --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/IntentsClientHttpJsonTest.java @@ -0,0 +1,1616 @@ +/* + * Copyright 2022 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.v2beta1; + +import static com.google.cloud.dialogflow.v2beta1.IntentsClient.ListIntentsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonIntentsStub; +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 java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class IntentsClientHttpJsonTest { + private static MockHttpService mockService; + private static IntentsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonIntentsStub.getMethodDescriptors(), IntentsSettings.getDefaultEndpoint()); + IntentsSettings settings = + IntentsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + IntentsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = IntentsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listIntentsTest() throws Exception { + Intent responsesElement = Intent.newBuilder().build(); + ListIntentsResponse expectedResponse = + ListIntentsResponse.newBuilder() + .setNextPageToken("") + .addAllIntents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listIntentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + client.listIntents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listIntentsTest2() throws Exception { + Intent responsesElement = Intent.newBuilder().build(); + ListIntentsResponse expectedResponse = + ListIntentsResponse.newBuilder() + .setNextPageToken("") + .addAllIntents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listIntentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + client.listIntents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listIntentsTest3() throws Exception { + Intent responsesElement = Intent.newBuilder().build(); + ListIntentsResponse expectedResponse = + ListIntentsResponse.newBuilder() + .setNextPageToken("") + .addAllIntents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String languageCode = "languageCode-2092349083"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listIntentsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String languageCode = "languageCode-2092349083"; + client.listIntents(parent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listIntentsTest4() throws Exception { + Intent responsesElement = Intent.newBuilder().build(); + ListIntentsResponse expectedResponse = + ListIntentsResponse.newBuilder() + .setNextPageToken("") + .addAllIntents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + String languageCode = "languageCode-2092349083"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listIntentsExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + String languageCode = "languageCode-2092349083"; + client.listIntents(parent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIntentTest() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + + Intent actualResponse = client.getIntent(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIntentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + client.getIntent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIntentTest2() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1783/agent/intents/intent-1783"; + + Intent actualResponse = client.getIntent(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIntentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1783/agent/intents/intent-1783"; + client.getIntent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIntentTest3() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + String languageCode = "languageCode-2092349083"; + + Intent actualResponse = client.getIntent(name, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIntentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + String languageCode = "languageCode-2092349083"; + client.getIntent(name, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIntentTest4() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1783/agent/intents/intent-1783"; + String languageCode = "languageCode-2092349083"; + + Intent actualResponse = client.getIntent(name, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIntentExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1783/agent/intents/intent-1783"; + String languageCode = "languageCode-2092349083"; + client.getIntent(name, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createIntentTest() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + + Intent actualResponse = client.createIntent(parent, intent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createIntentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + client.createIntent(parent, intent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createIntentTest2() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + Intent intent = Intent.newBuilder().build(); + + Intent actualResponse = client.createIntent(parent, intent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createIntentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + Intent intent = Intent.newBuilder().build(); + client.createIntent(parent, intent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createIntentTest3() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + + Intent actualResponse = client.createIntent(parent, intent, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createIntentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + client.createIntent(parent, intent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createIntentTest4() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + + Intent actualResponse = client.createIntent(parent, intent, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createIntentExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + client.createIntent(parent, intent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateIntentTest() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Intent intent = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + + Intent actualResponse = client.updateIntent(intent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateIntentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Intent intent = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + client.updateIntent(intent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateIntentTest2() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Intent intent = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Intent actualResponse = client.updateIntent(intent, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateIntentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Intent intent = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateIntent(intent, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateIntentTest3() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Intent intent = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + String languageCode = "languageCode-2092349083"; + + Intent actualResponse = client.updateIntent(intent, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateIntentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Intent intent = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + String languageCode = "languageCode-2092349083"; + client.updateIntent(intent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateIntentTest4() throws Exception { + Intent expectedResponse = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Intent intent = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + String languageCode = "languageCode-2092349083"; + FieldMask updateMask = FieldMask.newBuilder().build(); + + Intent actualResponse = client.updateIntent(intent, languageCode, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateIntentExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Intent intent = + Intent.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setDisplayName("displayName1714148973") + .setPriority(-1165461084) + .setIsFallback(true) + .setMlEnabled(true) + .setMlDisabled(true) + .setLiveAgentHandoff(true) + .setEndInteraction(true) + .addAllInputContextNames(new ArrayList()) + .addAllEvents(new ArrayList()) + .addAllTrainingPhrases(new ArrayList()) + .setAction("action-1422950858") + .addAllOutputContexts(new ArrayList()) + .setResetContexts(true) + .addAllParameters(new ArrayList()) + .addAllMessages(new ArrayList()) + .addAllDefaultResponsePlatforms(new ArrayList()) + .setRootFollowupIntentName("rootFollowupIntentName1370087157") + .setParentFollowupIntentName("parentFollowupIntentName1233650877") + .addAllFollowupIntentInfo(new ArrayList()) + .build(); + String languageCode = "languageCode-2092349083"; + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateIntent(intent, languageCode, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteIntentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + + client.deleteIntent(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteIntentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + client.deleteIntent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteIntentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1783/agent/intents/intent-1783"; + + client.deleteIntent(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteIntentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1783/agent/intents/intent-1783"; + client.deleteIntent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchUpdateIntentsTest() throws Exception { + BatchUpdateIntentsResponse expectedResponse = + BatchUpdateIntentsResponse.newBuilder().addAllIntents(new ArrayList()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateIntentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + IntentBatch intentBatchInline = IntentBatch.newBuilder().build(); + + BatchUpdateIntentsResponse actualResponse = + client.batchUpdateIntentsAsync(parent, intentBatchInline).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateIntentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + IntentBatch intentBatchInline = IntentBatch.newBuilder().build(); + client.batchUpdateIntentsAsync(parent, intentBatchInline).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateIntentsTest2() throws Exception { + BatchUpdateIntentsResponse expectedResponse = + BatchUpdateIntentsResponse.newBuilder().addAllIntents(new ArrayList()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateIntentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String intentBatchUri = "intentBatchUri544125582"; + + BatchUpdateIntentsResponse actualResponse = + client.batchUpdateIntentsAsync(parent, intentBatchUri).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateIntentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String intentBatchUri = "intentBatchUri544125582"; + client.batchUpdateIntentsAsync(parent, intentBatchUri).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateIntentsTest3() throws Exception { + BatchUpdateIntentsResponse expectedResponse = + BatchUpdateIntentsResponse.newBuilder().addAllIntents(new ArrayList()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateIntentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2469/agent"; + IntentBatch intentBatchInline = IntentBatch.newBuilder().build(); + + BatchUpdateIntentsResponse actualResponse = + client.batchUpdateIntentsAsync(parent, intentBatchInline).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateIntentsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + IntentBatch intentBatchInline = IntentBatch.newBuilder().build(); + client.batchUpdateIntentsAsync(parent, intentBatchInline).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchUpdateIntentsTest4() throws Exception { + BatchUpdateIntentsResponse expectedResponse = + BatchUpdateIntentsResponse.newBuilder().addAllIntents(new ArrayList()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateIntentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2469/agent"; + String intentBatchUri = "intentBatchUri544125582"; + + BatchUpdateIntentsResponse actualResponse = + client.batchUpdateIntentsAsync(parent, intentBatchUri).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchUpdateIntentsExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + String intentBatchUri = "intentBatchUri544125582"; + client.batchUpdateIntentsAsync(parent, intentBatchUri).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteIntentsTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteIntentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + List intents = new ArrayList<>(); + + client.batchDeleteIntentsAsync(parent, intents).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteIntentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + List intents = new ArrayList<>(); + client.batchDeleteIntentsAsync(parent, intents).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchDeleteIntentsTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteIntentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2469/agent"; + List intents = new ArrayList<>(); + + client.batchDeleteIntentsAsync(parent, intents).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchDeleteIntentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + List intents = new ArrayList<>(); + client.batchDeleteIntentsAsync(parent, intents).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/KnowledgeBasesClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/KnowledgeBasesClientHttpJsonTest.java new file mode 100644 index 000000000000..9fd52c42e068 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/KnowledgeBasesClientHttpJsonTest.java @@ -0,0 +1,685 @@ +/* + * Copyright 2022 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.v2beta1; + +import static com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonKnowledgeBasesStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class KnowledgeBasesClientHttpJsonTest { + private static MockHttpService mockService; + private static KnowledgeBasesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonKnowledgeBasesStub.getMethodDescriptors(), + KnowledgeBasesSettings.getDefaultEndpoint()); + KnowledgeBasesSettings settings = + KnowledgeBasesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + KnowledgeBasesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = KnowledgeBasesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listKnowledgeBasesTest() throws Exception { + KnowledgeBase responsesElement = KnowledgeBase.newBuilder().build(); + ListKnowledgeBasesResponse expectedResponse = + ListKnowledgeBasesResponse.newBuilder() + .setNextPageToken("") + .addAllKnowledgeBases(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListKnowledgeBasesPagedResponse pagedListResponse = client.listKnowledgeBases(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getKnowledgeBasesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listKnowledgeBasesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listKnowledgeBases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listKnowledgeBasesTest2() throws Exception { + KnowledgeBase responsesElement = KnowledgeBase.newBuilder().build(); + ListKnowledgeBasesResponse expectedResponse = + ListKnowledgeBasesResponse.newBuilder() + .setNextPageToken("") + .addAllKnowledgeBases(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListKnowledgeBasesPagedResponse pagedListResponse = client.listKnowledgeBases(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getKnowledgeBasesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listKnowledgeBasesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listKnowledgeBases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listKnowledgeBasesTest3() throws Exception { + KnowledgeBase responsesElement = KnowledgeBase.newBuilder().build(); + ListKnowledgeBasesResponse expectedResponse = + ListKnowledgeBasesResponse.newBuilder() + .setNextPageToken("") + .addAllKnowledgeBases(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListKnowledgeBasesPagedResponse pagedListResponse = client.listKnowledgeBases(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getKnowledgeBasesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listKnowledgeBasesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listKnowledgeBases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getKnowledgeBaseTest() throws Exception { + KnowledgeBase expectedResponse = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + KnowledgeBaseName name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + + KnowledgeBase actualResponse = client.getKnowledgeBase(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getKnowledgeBaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + KnowledgeBaseName name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + client.getKnowledgeBase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getKnowledgeBaseTest2() throws Exception { + KnowledgeBase expectedResponse = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-8270/knowledgeBases/knowledgeBase-8270"; + + KnowledgeBase actualResponse = client.getKnowledgeBase(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getKnowledgeBaseExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-8270/knowledgeBases/knowledgeBase-8270"; + client.getKnowledgeBase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createKnowledgeBaseTest() throws Exception { + KnowledgeBase expectedResponse = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + + KnowledgeBase actualResponse = client.createKnowledgeBase(parent, knowledgeBase); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createKnowledgeBaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + client.createKnowledgeBase(parent, knowledgeBase); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createKnowledgeBaseTest2() throws Exception { + KnowledgeBase expectedResponse = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + + KnowledgeBase actualResponse = client.createKnowledgeBase(parent, knowledgeBase); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createKnowledgeBaseExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + client.createKnowledgeBase(parent, knowledgeBase); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createKnowledgeBaseTest3() throws Exception { + KnowledgeBase expectedResponse = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + + KnowledgeBase actualResponse = client.createKnowledgeBase(parent, knowledgeBase); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createKnowledgeBaseExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + client.createKnowledgeBase(parent, knowledgeBase); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteKnowledgeBaseTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + KnowledgeBaseName name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + + client.deleteKnowledgeBase(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteKnowledgeBaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + KnowledgeBaseName name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + client.deleteKnowledgeBase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteKnowledgeBaseTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-8270/knowledgeBases/knowledgeBase-8270"; + + client.deleteKnowledgeBase(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteKnowledgeBaseExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-8270/knowledgeBases/knowledgeBase-8270"; + client.deleteKnowledgeBase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateKnowledgeBaseTest() throws Exception { + KnowledgeBase expectedResponse = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + KnowledgeBase knowledgeBase = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + + KnowledgeBase actualResponse = client.updateKnowledgeBase(knowledgeBase); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateKnowledgeBaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + KnowledgeBase knowledgeBase = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + client.updateKnowledgeBase(knowledgeBase); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateKnowledgeBaseTest2() throws Exception { + KnowledgeBase expectedResponse = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + mockService.addResponse(expectedResponse); + + KnowledgeBase knowledgeBase = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + KnowledgeBase actualResponse = client.updateKnowledgeBase(knowledgeBase, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateKnowledgeBaseExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + KnowledgeBase knowledgeBase = + KnowledgeBase.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDisplayName("displayName1714148973") + .setLanguageCode("languageCode-2092349083") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateKnowledgeBase(knowledgeBase, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ParticipantsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ParticipantsClientHttpJsonTest.java new file mode 100644 index 000000000000..9c1d66c2b5c1 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/ParticipantsClientHttpJsonTest.java @@ -0,0 +1,1106 @@ +/* + * Copyright 2022 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.v2beta1; + +import static com.google.cloud.dialogflow.v2beta1.ParticipantsClient.ListParticipantsPagedResponse; +import static com.google.cloud.dialogflow.v2beta1.ParticipantsClient.ListSuggestionsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonParticipantsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ParticipantsClientHttpJsonTest { + private static MockHttpService mockService; + private static ParticipantsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonParticipantsStub.getMethodDescriptors(), + ParticipantsSettings.getDefaultEndpoint()); + ParticipantsSettings settings = + ParticipantsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ParticipantsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ParticipantsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createParticipantTest() throws Exception { + Participant expectedResponse = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setObfuscatedExternalUserId("obfuscatedExternalUserId1778228693") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + Participant participant = Participant.newBuilder().build(); + + Participant actualResponse = client.createParticipant(parent, participant); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createParticipantExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + Participant participant = Participant.newBuilder().build(); + client.createParticipant(parent, participant); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createParticipantTest2() throws Exception { + Participant expectedResponse = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setObfuscatedExternalUserId("obfuscatedExternalUserId1778228693") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-4379/conversations/conversation-4379"; + Participant participant = Participant.newBuilder().build(); + + Participant actualResponse = client.createParticipant(parent, participant); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createParticipantExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-4379/conversations/conversation-4379"; + Participant participant = Participant.newBuilder().build(); + client.createParticipant(parent, participant); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getParticipantTest() throws Exception { + Participant expectedResponse = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setObfuscatedExternalUserId("obfuscatedExternalUserId1778228693") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + ParticipantName name = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + + Participant actualResponse = client.getParticipant(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getParticipantExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ParticipantName name = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + client.getParticipant(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getParticipantTest2() throws Exception { + Participant expectedResponse = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setObfuscatedExternalUserId("obfuscatedExternalUserId1778228693") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7006/conversations/conversation-7006/participants/participant-7006"; + + Participant actualResponse = client.getParticipant(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getParticipantExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7006/conversations/conversation-7006/participants/participant-7006"; + client.getParticipant(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listParticipantsTest() throws Exception { + Participant responsesElement = Participant.newBuilder().build(); + ListParticipantsResponse expectedResponse = + ListParticipantsResponse.newBuilder() + .setNextPageToken("") + .addAllParticipants(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + + ListParticipantsPagedResponse pagedListResponse = client.listParticipants(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getParticipantsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listParticipantsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + client.listParticipants(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listParticipantsTest2() throws Exception { + Participant responsesElement = Participant.newBuilder().build(); + ListParticipantsResponse expectedResponse = + ListParticipantsResponse.newBuilder() + .setNextPageToken("") + .addAllParticipants(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-4379/conversations/conversation-4379"; + + ListParticipantsPagedResponse pagedListResponse = client.listParticipants(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getParticipantsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listParticipantsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-4379/conversations/conversation-4379"; + client.listParticipants(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateParticipantTest() throws Exception { + Participant expectedResponse = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setObfuscatedExternalUserId("obfuscatedExternalUserId1778228693") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + Participant participant = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setObfuscatedExternalUserId("obfuscatedExternalUserId1778228693") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Participant actualResponse = client.updateParticipant(participant, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateParticipantExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Participant participant = + Participant.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setObfuscatedExternalUserId("obfuscatedExternalUserId1778228693") + .putAllDocumentsMetadataFilters(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateParticipant(participant, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void analyzeContentTest() throws Exception { + AnalyzeContentResponse expectedResponse = + AnalyzeContentResponse.newBuilder() + .setReplyText("replyText-433699017") + .setReplyAudio(OutputAudio.newBuilder().build()) + .setAutomatedAgentReply(AutomatedAgentReply.newBuilder().build()) + .setMessage(Message.newBuilder().build()) + .addAllHumanAgentSuggestionResults(new ArrayList()) + .addAllEndUserSuggestionResults(new ArrayList()) + .setDtmfParameters(DtmfParameters.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ParticipantName participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + EventInput eventInput = EventInput.newBuilder().build(); + + AnalyzeContentResponse actualResponse = client.analyzeContent(participant, eventInput); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void analyzeContentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ParticipantName participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + EventInput eventInput = EventInput.newBuilder().build(); + client.analyzeContent(participant, eventInput); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void analyzeContentTest2() throws Exception { + AnalyzeContentResponse expectedResponse = + AnalyzeContentResponse.newBuilder() + .setReplyText("replyText-433699017") + .setReplyAudio(OutputAudio.newBuilder().build()) + .setAutomatedAgentReply(AutomatedAgentReply.newBuilder().build()) + .setMessage(Message.newBuilder().build()) + .addAllHumanAgentSuggestionResults(new ArrayList()) + .addAllEndUserSuggestionResults(new ArrayList()) + .setDtmfParameters(DtmfParameters.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ParticipantName participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + TextInput textInput = TextInput.newBuilder().build(); + + AnalyzeContentResponse actualResponse = client.analyzeContent(participant, textInput); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void analyzeContentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ParticipantName participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + TextInput textInput = TextInput.newBuilder().build(); + client.analyzeContent(participant, textInput); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void analyzeContentTest3() throws Exception { + AnalyzeContentResponse expectedResponse = + AnalyzeContentResponse.newBuilder() + .setReplyText("replyText-433699017") + .setReplyAudio(OutputAudio.newBuilder().build()) + .setAutomatedAgentReply(AutomatedAgentReply.newBuilder().build()) + .setMessage(Message.newBuilder().build()) + .addAllHumanAgentSuggestionResults(new ArrayList()) + .addAllEndUserSuggestionResults(new ArrayList()) + .setDtmfParameters(DtmfParameters.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String participant = + "projects/project-8054/conversations/conversation-8054/participants/participant-8054"; + EventInput eventInput = EventInput.newBuilder().build(); + + AnalyzeContentResponse actualResponse = client.analyzeContent(participant, eventInput); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void analyzeContentExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String participant = + "projects/project-8054/conversations/conversation-8054/participants/participant-8054"; + EventInput eventInput = EventInput.newBuilder().build(); + client.analyzeContent(participant, eventInput); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void analyzeContentTest4() throws Exception { + AnalyzeContentResponse expectedResponse = + AnalyzeContentResponse.newBuilder() + .setReplyText("replyText-433699017") + .setReplyAudio(OutputAudio.newBuilder().build()) + .setAutomatedAgentReply(AutomatedAgentReply.newBuilder().build()) + .setMessage(Message.newBuilder().build()) + .addAllHumanAgentSuggestionResults(new ArrayList()) + .addAllEndUserSuggestionResults(new ArrayList()) + .setDtmfParameters(DtmfParameters.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String participant = + "projects/project-8054/conversations/conversation-8054/participants/participant-8054"; + TextInput textInput = TextInput.newBuilder().build(); + + AnalyzeContentResponse actualResponse = client.analyzeContent(participant, textInput); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void analyzeContentExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String participant = + "projects/project-8054/conversations/conversation-8054/participants/participant-8054"; + TextInput textInput = TextInput.newBuilder().build(); + client.analyzeContent(participant, textInput); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void streamingAnalyzeContentUnsupportedMethodTest() throws Exception { + // The streamingAnalyzeContent() method is not supported in REST transport. + // This empty test is generated for technical reasons. + } + + @Test + public void suggestArticlesTest() throws Exception { + SuggestArticlesResponse expectedResponse = + SuggestArticlesResponse.newBuilder() + .addAllArticleAnswers(new ArrayList()) + .setLatestMessage("latestMessage-1424305536") + .setContextSize(1116903569) + .build(); + mockService.addResponse(expectedResponse); + + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + + SuggestArticlesResponse actualResponse = client.suggestArticles(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void suggestArticlesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + client.suggestArticles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void suggestArticlesTest2() throws Exception { + SuggestArticlesResponse expectedResponse = + SuggestArticlesResponse.newBuilder() + .addAllArticleAnswers(new ArrayList()) + .setLatestMessage("latestMessage-1424305536") + .setContextSize(1116903569) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-4961/conversations/conversation-4961/participants/participant-4961"; + + SuggestArticlesResponse actualResponse = client.suggestArticles(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void suggestArticlesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-4961/conversations/conversation-4961/participants/participant-4961"; + client.suggestArticles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void suggestFaqAnswersTest() throws Exception { + SuggestFaqAnswersResponse expectedResponse = + SuggestFaqAnswersResponse.newBuilder() + .addAllFaqAnswers(new ArrayList()) + .setLatestMessage("latestMessage-1424305536") + .setContextSize(1116903569) + .build(); + mockService.addResponse(expectedResponse); + + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + + SuggestFaqAnswersResponse actualResponse = client.suggestFaqAnswers(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void suggestFaqAnswersExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + client.suggestFaqAnswers(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void suggestFaqAnswersTest2() throws Exception { + SuggestFaqAnswersResponse expectedResponse = + SuggestFaqAnswersResponse.newBuilder() + .addAllFaqAnswers(new ArrayList()) + .setLatestMessage("latestMessage-1424305536") + .setContextSize(1116903569) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-4961/conversations/conversation-4961/participants/participant-4961"; + + SuggestFaqAnswersResponse actualResponse = client.suggestFaqAnswers(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void suggestFaqAnswersExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-4961/conversations/conversation-4961/participants/participant-4961"; + client.suggestFaqAnswers(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void suggestSmartRepliesTest() throws Exception { + SuggestSmartRepliesResponse expectedResponse = + SuggestSmartRepliesResponse.newBuilder() + .addAllSmartReplyAnswers(new ArrayList()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .build(); + mockService.addResponse(expectedResponse); + + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + + SuggestSmartRepliesResponse actualResponse = client.suggestSmartReplies(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void suggestSmartRepliesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + client.suggestSmartReplies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void suggestSmartRepliesTest2() throws Exception { + SuggestSmartRepliesResponse expectedResponse = + SuggestSmartRepliesResponse.newBuilder() + .addAllSmartReplyAnswers(new ArrayList()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-4961/conversations/conversation-4961/participants/participant-4961"; + + SuggestSmartRepliesResponse actualResponse = client.suggestSmartReplies(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void suggestSmartRepliesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-4961/conversations/conversation-4961/participants/participant-4961"; + client.suggestSmartReplies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSuggestionsTest() throws Exception { + Suggestion responsesElement = Suggestion.newBuilder().build(); + ListSuggestionsResponse expectedResponse = + ListSuggestionsResponse.newBuilder() + .setNextPageToken("") + .addAllSuggestions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListSuggestionsRequest request = + ListSuggestionsRequest.newBuilder() + .setParent( + "projects/project-4961/conversations/conversation-4961/participants/participant-4961") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + + ListSuggestionsPagedResponse pagedListResponse = client.listSuggestions(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSuggestionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSuggestionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListSuggestionsRequest request = + ListSuggestionsRequest.newBuilder() + .setParent( + "projects/project-4961/conversations/conversation-4961/participants/participant-4961") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + client.listSuggestions(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void compileSuggestionTest() throws Exception { + CompileSuggestionResponse expectedResponse = + CompileSuggestionResponse.newBuilder() + .setSuggestion(Suggestion.newBuilder().build()) + .setLatestMessage("latestMessage-1424305536") + .setContextSize(1116903569) + .build(); + mockService.addResponse(expectedResponse); + + CompileSuggestionRequest request = + CompileSuggestionRequest.newBuilder() + .setParent( + "projects/project-4961/conversations/conversation-4961/participants/participant-4961") + .setLatestMessage("latestMessage-1424305536") + .setContextSize(1116903569) + .build(); + + CompileSuggestionResponse actualResponse = client.compileSuggestion(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void compileSuggestionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CompileSuggestionRequest request = + CompileSuggestionRequest.newBuilder() + .setParent( + "projects/project-4961/conversations/conversation-4961/participants/participant-4961") + .setLatestMessage("latestMessage-1424305536") + .setContextSize(1116903569) + .build(); + client.compileSuggestion(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesClientHttpJsonTest.java new file mode 100644 index 000000000000..359ae489f97a --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesClientHttpJsonTest.java @@ -0,0 +1,591 @@ +/* + * Copyright 2022 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.v2beta1; + +import static com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient.ListSessionEntityTypesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonSessionEntityTypesStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class SessionEntityTypesClientHttpJsonTest { + private static MockHttpService mockService; + private static SessionEntityTypesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSessionEntityTypesStub.getMethodDescriptors(), + SessionEntityTypesSettings.getDefaultEndpoint()); + SessionEntityTypesSettings settings = + SessionEntityTypesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SessionEntityTypesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SessionEntityTypesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listSessionEntityTypesTest() throws Exception { + SessionEntityType responsesElement = SessionEntityType.newBuilder().build(); + ListSessionEntityTypesResponse expectedResponse = + ListSessionEntityTypesResponse.newBuilder() + .setNextPageToken("") + .addAllSessionEntityTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SessionName parent = SessionName.ofProjectSessionName("[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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSessionEntityTypesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + client.listSessionEntityTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSessionEntityTypesTest2() throws Exception { + SessionEntityType responsesElement = SessionEntityType.newBuilder().build(); + ListSessionEntityTypesResponse expectedResponse = + ListSessionEntityTypesResponse.newBuilder() + .setNextPageToken("") + .addAllSessionEntityTypes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6494/agent/sessions/session-6494"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSessionEntityTypesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6494/agent/sessions/session-6494"; + client.listSessionEntityTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSessionEntityTypeTest() throws Exception { + SessionEntityType expectedResponse = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + SessionEntityTypeName name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + + SessionEntityType actualResponse = client.getSessionEntityType(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSessionEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionEntityTypeName name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + client.getSessionEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSessionEntityTypeTest2() throws Exception { + SessionEntityType expectedResponse = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-957/agent/sessions/session-957/entityTypes/entityType-957"; + + SessionEntityType actualResponse = client.getSessionEntityType(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSessionEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-957/agent/sessions/session-957/entityTypes/entityType-957"; + client.getSessionEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSessionEntityTypeTest() throws Exception { + SessionEntityType expectedResponse = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + + SessionEntityType actualResponse = client.createSessionEntityType(parent, sessionEntityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSessionEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + client.createSessionEntityType(parent, sessionEntityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSessionEntityTypeTest2() throws Exception { + SessionEntityType expectedResponse = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6494/agent/sessions/session-6494"; + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + + SessionEntityType actualResponse = client.createSessionEntityType(parent, sessionEntityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSessionEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6494/agent/sessions/session-6494"; + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + client.createSessionEntityType(parent, sessionEntityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSessionEntityTypeTest() throws Exception { + SessionEntityType expectedResponse = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + SessionEntityType sessionEntityType = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + + SessionEntityType actualResponse = client.updateSessionEntityType(sessionEntityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSessionEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionEntityType sessionEntityType = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + client.updateSessionEntityType(sessionEntityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSessionEntityTypeTest2() throws Exception { + SessionEntityType expectedResponse = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + SessionEntityType sessionEntityType = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + SessionEntityType actualResponse = + client.updateSessionEntityType(sessionEntityType, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSessionEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionEntityType sessionEntityType = + SessionEntityType.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .addAllEntities(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateSessionEntityType(sessionEntityType, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteSessionEntityTypeTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + SessionEntityTypeName name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + + client.deleteSessionEntityType(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteSessionEntityTypeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionEntityTypeName name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + client.deleteSessionEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteSessionEntityTypeTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-957/agent/sessions/session-957/entityTypes/entityType-957"; + + client.deleteSessionEntityType(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteSessionEntityTypeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-957/agent/sessions/session-957/entityTypes/entityType-957"; + client.deleteSessionEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/SessionsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/SessionsClientHttpJsonTest.java new file mode 100644 index 000000000000..87b986d085cb --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/SessionsClientHttpJsonTest.java @@ -0,0 +1,183 @@ +/* + * Copyright 2022 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.v2beta1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonSessionsStub; +import com.google.protobuf.ByteString; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class SessionsClientHttpJsonTest { + private static MockHttpService mockService; + private static SessionsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSessionsStub.getMethodDescriptors(), SessionsSettings.getDefaultEndpoint()); + SessionsSettings settings = + SessionsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SessionsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SessionsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void detectIntentTest() throws Exception { + DetectIntentResponse expectedResponse = + DetectIntentResponse.newBuilder() + .setResponseId("responseId-633138884") + .setQueryResult(QueryResult.newBuilder().build()) + .addAllAlternativeQueryResults(new ArrayList()) + .setWebhookStatus(Status.newBuilder().build()) + .setOutputAudio(ByteString.EMPTY) + .setOutputAudioConfig(OutputAudioConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + SessionName session = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + QueryInput queryInput = QueryInput.newBuilder().build(); + + DetectIntentResponse actualResponse = client.detectIntent(session, queryInput); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void detectIntentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SessionName session = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + QueryInput queryInput = QueryInput.newBuilder().build(); + client.detectIntent(session, queryInput); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void detectIntentTest2() throws Exception { + DetectIntentResponse expectedResponse = + DetectIntentResponse.newBuilder() + .setResponseId("responseId-633138884") + .setQueryResult(QueryResult.newBuilder().build()) + .addAllAlternativeQueryResults(new ArrayList()) + .setWebhookStatus(Status.newBuilder().build()) + .setOutputAudio(ByteString.EMPTY) + .setOutputAudioConfig(OutputAudioConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String session = "projects/project-3462/agent/sessions/session-3462"; + QueryInput queryInput = QueryInput.newBuilder().build(); + + DetectIntentResponse actualResponse = client.detectIntent(session, queryInput); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void detectIntentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String session = "projects/project-3462/agent/sessions/session-3462"; + QueryInput queryInput = QueryInput.newBuilder().build(); + client.detectIntent(session, queryInput); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void streamingDetectIntentUnsupportedMethodTest() throws Exception { + // The streamingDetectIntent() method is not supported in REST transport. + // This empty test is generated for technical reasons. + } +} diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/VersionsClientHttpJsonTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/VersionsClientHttpJsonTest.java new file mode 100644 index 000000000000..d3fc94772af5 --- /dev/null +++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/VersionsClientHttpJsonTest.java @@ -0,0 +1,512 @@ +/* + * Copyright 2022 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.v2beta1; + +import static com.google.cloud.dialogflow.v2beta1.VersionsClient.ListVersionsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.dialogflow.v2beta1.stub.HttpJsonVersionsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class VersionsClientHttpJsonTest { + private static MockHttpService mockService; + private static VersionsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonVersionsStub.getMethodDescriptors(), VersionsSettings.getDefaultEndpoint()); + VersionsSettings settings = + VersionsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + VersionsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = VersionsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listVersionsTest() throws Exception { + Version responsesElement = Version.newBuilder().build(); + ListVersionsResponse expectedResponse = + ListVersionsResponse.newBuilder() + .setNextPageToken("") + .addAllVersions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + + ListVersionsPagedResponse pagedListResponse = client.listVersions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVersionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listVersionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + client.listVersions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listVersionsTest2() throws Exception { + Version responsesElement = Version.newBuilder().build(); + ListVersionsResponse expectedResponse = + ListVersionsResponse.newBuilder() + .setNextPageToken("") + .addAllVersions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + + ListVersionsPagedResponse pagedListResponse = client.listVersions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVersionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listVersionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + client.listVersions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVersionTest() throws Exception { + Version expectedResponse = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]"); + + Version actualResponse = client.getVersion(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getVersionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]"); + client.getVersion(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVersionTest2() throws Exception { + Version expectedResponse = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9087/agent/versions/version-9087"; + + Version actualResponse = client.getVersion(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getVersionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9087/agent/versions/version-9087"; + client.getVersion(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createVersionTest() throws Exception { + Version expectedResponse = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Version version = Version.newBuilder().build(); + + Version actualResponse = client.createVersion(parent, version); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createVersionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Version version = Version.newBuilder().build(); + client.createVersion(parent, version); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createVersionTest2() throws Exception { + Version expectedResponse = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2469/agent"; + Version version = Version.newBuilder().build(); + + Version actualResponse = client.createVersion(parent, version); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createVersionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2469/agent"; + Version version = Version.newBuilder().build(); + client.createVersion(parent, version); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateVersionTest() throws Exception { + Version expectedResponse = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Version version = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Version actualResponse = client.updateVersion(version, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateVersionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Version version = + Version.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .setDescription("description-1724546052") + .setVersionNumber(135927952) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateVersion(version, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteVersionTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]"); + + client.deleteVersion(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteVersionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]"); + client.deleteVersion(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteVersionTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9087/agent/versions/version-9087"; + + client.deleteVersion(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteVersionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9087/agent/versions/version-9087"; + client.deleteVersion(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..3319224f0a5f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.AgentsSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AgentsSettings agentsSettings = + AgentsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + AgentsClient agentsClient = AgentsClient.create(agentsSettings); + } +} +// [END dialogflow_v2_generated_agentsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..1db7e3e5b85c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.AgentsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AgentsSettings agentsSettings = + AgentsSettings.newBuilder() + .setTransportChannelProvider( + AgentsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + AgentsClient agentsClient = AgentsClient.create(agentsSettings); + } +} +// [END dialogflow_v2_generated_agentsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..afb22f0ef3be --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,37 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.AgentsSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AgentsSettings agentsSettings = AgentsSettings.newBuilder().setEndpoint(myEndpoint).build(); + AgentsClient agentsClient = AgentsClient.create(agentsSettings); + } +} +// [END dialogflow_v2_generated_agentsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/AsyncDeleteAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/AsyncDeleteAgent.java new file mode 100644 index 000000000000..f821b7d24c16 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/AsyncDeleteAgent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_deleteagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.DeleteAgentRequest; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.protobuf.Empty; + +public class AsyncDeleteAgent { + + public static void main(String[] args) throws Exception { + asyncDeleteAgent(); + } + + public static void asyncDeleteAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + DeleteAgentRequest request = + DeleteAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + ApiFuture future = agentsClient.deleteAgentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_deleteagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgent.java new file mode 100644 index 000000000000..7d8f9807cbb1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgent.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_deleteagent_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.DeleteAgentRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncDeleteAgent { + + public static void main(String[] args) throws Exception { + syncDeleteAgent(); + } + + public static void syncDeleteAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + DeleteAgentRequest request = + DeleteAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + agentsClient.deleteAgent(request); + } + } +} +// [END dialogflow_v2_generated_agentsclient_deleteagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgentLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgentLocationname.java new file mode 100644 index 000000000000..9afb26b5f5ed --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgentLocationname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_deleteagent_locationname_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncDeleteAgentLocationname { + + public static void main(String[] args) throws Exception { + syncDeleteAgentLocationname(); + } + + public static void syncDeleteAgentLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + agentsClient.deleteAgent(parent); + } + } +} +// [END dialogflow_v2_generated_agentsclient_deleteagent_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgentProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgentProjectname.java new file mode 100644 index 000000000000..2de30a1522da --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgentProjectname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_deleteagent_projectname_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncDeleteAgentProjectname { + + public static void main(String[] args) throws Exception { + syncDeleteAgentProjectname(); + } + + public static void syncDeleteAgentProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + agentsClient.deleteAgent(parent); + } + } +} +// [END dialogflow_v2_generated_agentsclient_deleteagent_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgentString.java new file mode 100644 index 000000000000..c83fdb6f9945 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/deleteagent/SyncDeleteAgentString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_deleteagent_string_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncDeleteAgentString { + + public static void main(String[] args) throws Exception { + syncDeleteAgentString(); + } + + public static void syncDeleteAgentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + agentsClient.deleteAgent(parent); + } + } +} +// [END dialogflow_v2_generated_agentsclient_deleteagent_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/AsyncExportAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/AsyncExportAgent.java new file mode 100644 index 000000000000..47d016c54fa5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/AsyncExportAgent.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_exportagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ExportAgentRequest; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.longrunning.Operation; + +public class AsyncExportAgent { + + public static void main(String[] args) throws Exception { + asyncExportAgent(); + } + + public static void asyncExportAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ExportAgentRequest request = + ExportAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setAgentUri("agentUri1469149223") + .build(); + ApiFuture future = agentsClient.exportAgentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_exportagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/AsyncExportAgentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/AsyncExportAgentLRO.java new file mode 100644 index 000000000000..4df9a39fad8d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/AsyncExportAgentLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_exportagent_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ExportAgentRequest; +import com.google.cloud.dialogflow.v2.ExportAgentResponse; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.protobuf.Struct; + +public class AsyncExportAgentLRO { + + public static void main(String[] args) throws Exception { + asyncExportAgentLRO(); + } + + public static void asyncExportAgentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ExportAgentRequest request = + ExportAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setAgentUri("agentUri1469149223") + .build(); + OperationFuture future = + agentsClient.exportAgentOperationCallable().futureCall(request); + // Do something. + ExportAgentResponse response = future.get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_exportagent_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgent.java new file mode 100644 index 000000000000..f6641044f692 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_exportagent_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ExportAgentRequest; +import com.google.cloud.dialogflow.v2.ExportAgentResponse; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncExportAgent { + + public static void main(String[] args) throws Exception { + syncExportAgent(); + } + + public static void syncExportAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ExportAgentRequest request = + ExportAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setAgentUri("agentUri1469149223") + .build(); + ExportAgentResponse response = agentsClient.exportAgentAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_exportagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgentLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgentLocationname.java new file mode 100644 index 000000000000..d520dacfc76a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgentLocationname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_exportagent_locationname_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ExportAgentResponse; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncExportAgentLocationname { + + public static void main(String[] args) throws Exception { + syncExportAgentLocationname(); + } + + public static void syncExportAgentLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ExportAgentResponse response = agentsClient.exportAgentAsync(parent).get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_exportagent_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgentProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgentProjectname.java new file mode 100644 index 000000000000..e30048292ef7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgentProjectname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_exportagent_projectname_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ExportAgentResponse; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncExportAgentProjectname { + + public static void main(String[] args) throws Exception { + syncExportAgentProjectname(); + } + + public static void syncExportAgentProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + ExportAgentResponse response = agentsClient.exportAgentAsync(parent).get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_exportagent_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgentString.java new file mode 100644 index 000000000000..5c728bb0da3a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/exportagent/SyncExportAgentString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_exportagent_string_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ExportAgentResponse; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncExportAgentString { + + public static void main(String[] args) throws Exception { + syncExportAgentString(); + } + + public static void syncExportAgentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + ExportAgentResponse response = agentsClient.exportAgentAsync(parent).get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_exportagent_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/AsyncGetAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/AsyncGetAgent.java new file mode 100644 index 000000000000..8954419a0b36 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/AsyncGetAgent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_getagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.GetAgentRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class AsyncGetAgent { + + public static void main(String[] args) throws Exception { + asyncGetAgent(); + } + + public static void asyncGetAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + GetAgentRequest request = + GetAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + ApiFuture future = agentsClient.getAgentCallable().futureCall(request); + // Do something. + Agent response = future.get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_getagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgent.java new file mode 100644 index 000000000000..a57bc1de7f3a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgent.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_getagent_sync] +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.GetAgentRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncGetAgent { + + public static void main(String[] args) throws Exception { + syncGetAgent(); + } + + public static void syncGetAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + GetAgentRequest request = + GetAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + Agent response = agentsClient.getAgent(request); + } + } +} +// [END dialogflow_v2_generated_agentsclient_getagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgentLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgentLocationname.java new file mode 100644 index 000000000000..87350ea7b7ca --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgentLocationname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_getagent_locationname_sync] +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncGetAgentLocationname { + + public static void main(String[] args) throws Exception { + syncGetAgentLocationname(); + } + + public static void syncGetAgentLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Agent response = agentsClient.getAgent(parent); + } + } +} +// [END dialogflow_v2_generated_agentsclient_getagent_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgentProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgentProjectname.java new file mode 100644 index 000000000000..38a090787318 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgentProjectname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_getagent_projectname_sync] +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncGetAgentProjectname { + + public static void main(String[] args) throws Exception { + syncGetAgentProjectname(); + } + + public static void syncGetAgentProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + Agent response = agentsClient.getAgent(parent); + } + } +} +// [END dialogflow_v2_generated_agentsclient_getagent_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgentString.java new file mode 100644 index 000000000000..8db8221c4524 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getagent/SyncGetAgentString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_getagent_string_sync] +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncGetAgentString { + + public static void main(String[] args) throws Exception { + syncGetAgentString(); + } + + public static void syncGetAgentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + Agent response = agentsClient.getAgent(parent); + } + } +} +// [END dialogflow_v2_generated_agentsclient_getagent_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getvalidationresult/AsyncGetValidationResult.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getvalidationresult/AsyncGetValidationResult.java new file mode 100644 index 000000000000..4b441d7a7987 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getvalidationresult/AsyncGetValidationResult.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_getvalidationresult_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.GetValidationResultRequest; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.cloud.dialogflow.v2.ValidationResult; + +public class AsyncGetValidationResult { + + public static void main(String[] args) throws Exception { + asyncGetValidationResult(); + } + + public static void asyncGetValidationResult() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + GetValidationResultRequest request = + GetValidationResultRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .build(); + ApiFuture future = + agentsClient.getValidationResultCallable().futureCall(request); + // Do something. + ValidationResult response = future.get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_getvalidationresult_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getvalidationresult/SyncGetValidationResult.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getvalidationresult/SyncGetValidationResult.java new file mode 100644 index 000000000000..0656d3e9b755 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/getvalidationresult/SyncGetValidationResult.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_getvalidationresult_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.GetValidationResultRequest; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.cloud.dialogflow.v2.ValidationResult; + +public class SyncGetValidationResult { + + public static void main(String[] args) throws Exception { + syncGetValidationResult(); + } + + public static void syncGetValidationResult() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + GetValidationResultRequest request = + GetValidationResultRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .build(); + ValidationResult response = agentsClient.getValidationResult(request); + } + } +} +// [END dialogflow_v2_generated_agentsclient_getvalidationresult_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/importagent/AsyncImportAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/importagent/AsyncImportAgent.java new file mode 100644 index 000000000000..58430f584e76 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/importagent/AsyncImportAgent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_importagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ImportAgentRequest; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.longrunning.Operation; + +public class AsyncImportAgent { + + public static void main(String[] args) throws Exception { + asyncImportAgent(); + } + + public static void asyncImportAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ImportAgentRequest request = + ImportAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + ApiFuture future = agentsClient.importAgentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_importagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/importagent/AsyncImportAgentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/importagent/AsyncImportAgentLRO.java new file mode 100644 index 000000000000..e7802145f9f7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/importagent/AsyncImportAgentLRO.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_importagent_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ImportAgentRequest; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; + +public class AsyncImportAgentLRO { + + public static void main(String[] args) throws Exception { + asyncImportAgentLRO(); + } + + public static void asyncImportAgentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ImportAgentRequest request = + ImportAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + OperationFuture future = + agentsClient.importAgentOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_importagent_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/importagent/SyncImportAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/importagent/SyncImportAgent.java new file mode 100644 index 000000000000..9768f5164f40 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/importagent/SyncImportAgent.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_importagent_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ImportAgentRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncImportAgent { + + public static void main(String[] args) throws Exception { + syncImportAgent(); + } + + public static void syncImportAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ImportAgentRequest request = + ImportAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + agentsClient.importAgentAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_importagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/restoreagent/AsyncRestoreAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/restoreagent/AsyncRestoreAgent.java new file mode 100644 index 000000000000..5c79de317df5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/restoreagent/AsyncRestoreAgent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_restoreagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.cloud.dialogflow.v2.RestoreAgentRequest; +import com.google.longrunning.Operation; + +public class AsyncRestoreAgent { + + public static void main(String[] args) throws Exception { + asyncRestoreAgent(); + } + + public static void asyncRestoreAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + RestoreAgentRequest request = + RestoreAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .build(); + ApiFuture future = agentsClient.restoreAgentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_restoreagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/restoreagent/AsyncRestoreAgentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/restoreagent/AsyncRestoreAgentLRO.java new file mode 100644 index 000000000000..7f3526acd3ed --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/restoreagent/AsyncRestoreAgentLRO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_restoreagent_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.cloud.dialogflow.v2.RestoreAgentRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; + +public class AsyncRestoreAgentLRO { + + public static void main(String[] args) throws Exception { + asyncRestoreAgentLRO(); + } + + public static void asyncRestoreAgentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + RestoreAgentRequest request = + RestoreAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .build(); + OperationFuture future = + agentsClient.restoreAgentOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_restoreagent_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/restoreagent/SyncRestoreAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/restoreagent/SyncRestoreAgent.java new file mode 100644 index 000000000000..2d7527fc6f16 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/restoreagent/SyncRestoreAgent.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_restoreagent_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.cloud.dialogflow.v2.RestoreAgentRequest; + +public class SyncRestoreAgent { + + public static void main(String[] args) throws Exception { + syncRestoreAgent(); + } + + public static void syncRestoreAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + RestoreAgentRequest request = + RestoreAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .build(); + agentsClient.restoreAgentAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_restoreagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/AsyncSearchAgents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/AsyncSearchAgents.java new file mode 100644 index 000000000000..77001c2f7ea0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/AsyncSearchAgents.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_searchagents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.cloud.dialogflow.v2.SearchAgentsRequest; + +public class AsyncSearchAgents { + + public static void main(String[] args) throws Exception { + asyncSearchAgents(); + } + + public static void asyncSearchAgents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + SearchAgentsRequest request = + SearchAgentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = agentsClient.searchAgentsPagedCallable().futureCall(request); + // Do something. + for (Agent element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_agentsclient_searchagents_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/AsyncSearchAgentsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/AsyncSearchAgentsPaged.java new file mode 100644 index 000000000000..83d2b46f4994 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/AsyncSearchAgentsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_searchagents_paged_async] +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.cloud.dialogflow.v2.SearchAgentsRequest; +import com.google.cloud.dialogflow.v2.SearchAgentsResponse; +import com.google.common.base.Strings; + +public class AsyncSearchAgentsPaged { + + public static void main(String[] args) throws Exception { + asyncSearchAgentsPaged(); + } + + public static void asyncSearchAgentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + SearchAgentsRequest request = + SearchAgentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .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; + } + } + } + } +} +// [END dialogflow_v2_generated_agentsclient_searchagents_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgents.java new file mode 100644 index 000000000000..a4c1eed21e57 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgents.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_searchagents_sync] +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.cloud.dialogflow.v2.SearchAgentsRequest; + +public class SyncSearchAgents { + + public static void main(String[] args) throws Exception { + syncSearchAgents(); + } + + public static void syncSearchAgents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + SearchAgentsRequest request = + SearchAgentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Agent element : agentsClient.searchAgents(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_agentsclient_searchagents_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgentsLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgentsLocationname.java new file mode 100644 index 000000000000..bd77cda48fef --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgentsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_searchagents_locationname_sync] +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncSearchAgentsLocationname { + + public static void main(String[] args) throws Exception { + syncSearchAgentsLocationname(); + } + + public static void syncSearchAgentsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Agent element : agentsClient.searchAgents(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_agentsclient_searchagents_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgentsProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgentsProjectname.java new file mode 100644 index 000000000000..b75b034b6132 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgentsProjectname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_searchagents_projectname_sync] +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncSearchAgentsProjectname { + + public static void main(String[] args) throws Exception { + syncSearchAgentsProjectname(); + } + + public static void syncSearchAgentsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (Agent element : agentsClient.searchAgents(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_agentsclient_searchagents_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgentsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgentsString.java new file mode 100644 index 000000000000..b291fc778645 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/searchagents/SyncSearchAgentsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_searchagents_string_sync] +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncSearchAgentsString { + + public static void main(String[] args) throws Exception { + syncSearchAgentsString(); + } + + public static void syncSearchAgentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (Agent element : agentsClient.searchAgents(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_agentsclient_searchagents_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/setagent/AsyncSetAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/setagent/AsyncSetAgent.java new file mode 100644 index 000000000000..0e8a707584d0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/setagent/AsyncSetAgent.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_setagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.SetAgentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncSetAgent { + + public static void main(String[] args) throws Exception { + asyncSetAgent(); + } + + public static void asyncSetAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + SetAgentRequest request = + SetAgentRequest.newBuilder() + .setAgent(Agent.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = agentsClient.setAgentCallable().futureCall(request); + // Do something. + Agent response = future.get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_setagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/setagent/SyncSetAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/setagent/SyncSetAgent.java new file mode 100644 index 000000000000..305f2b1583a6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/setagent/SyncSetAgent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_setagent_sync] +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.SetAgentRequest; +import com.google.protobuf.FieldMask; + +public class SyncSetAgent { + + public static void main(String[] args) throws Exception { + syncSetAgent(); + } + + public static void syncSetAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + SetAgentRequest request = + SetAgentRequest.newBuilder() + .setAgent(Agent.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Agent response = agentsClient.setAgent(request); + } + } +} +// [END dialogflow_v2_generated_agentsclient_setagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/setagent/SyncSetAgentAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/setagent/SyncSetAgentAgent.java new file mode 100644 index 000000000000..bc8b53bb8c04 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/setagent/SyncSetAgentAgent.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_setagent_agent_sync] +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.AgentsClient; + +public class SyncSetAgentAgent { + + public static void main(String[] args) throws Exception { + syncSetAgentAgent(); + } + + public static void syncSetAgentAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + Agent agent = Agent.newBuilder().build(); + Agent response = agentsClient.setAgent(agent); + } + } +} +// [END dialogflow_v2_generated_agentsclient_setagent_agent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/AsyncTrainAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/AsyncTrainAgent.java new file mode 100644 index 000000000000..8c00498b2bab --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/AsyncTrainAgent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_trainagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.cloud.dialogflow.v2.TrainAgentRequest; +import com.google.longrunning.Operation; + +public class AsyncTrainAgent { + + public static void main(String[] args) throws Exception { + asyncTrainAgent(); + } + + public static void asyncTrainAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + TrainAgentRequest request = + TrainAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + ApiFuture future = agentsClient.trainAgentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_trainagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/AsyncTrainAgentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/AsyncTrainAgentLRO.java new file mode 100644 index 000000000000..0222acb03d8b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/AsyncTrainAgentLRO.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_trainagent_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.cloud.dialogflow.v2.TrainAgentRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; + +public class AsyncTrainAgentLRO { + + public static void main(String[] args) throws Exception { + asyncTrainAgentLRO(); + } + + public static void asyncTrainAgentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + TrainAgentRequest request = + TrainAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + OperationFuture future = + agentsClient.trainAgentOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_trainagent_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgent.java new file mode 100644 index 000000000000..aba9a9837f9f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgent.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_trainagent_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.cloud.dialogflow.v2.TrainAgentRequest; + +public class SyncTrainAgent { + + public static void main(String[] args) throws Exception { + syncTrainAgent(); + } + + public static void syncTrainAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + TrainAgentRequest request = + TrainAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + agentsClient.trainAgentAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_trainagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgentLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgentLocationname.java new file mode 100644 index 000000000000..947ea787bdad --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgentLocationname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_trainagent_locationname_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncTrainAgentLocationname { + + public static void main(String[] args) throws Exception { + syncTrainAgentLocationname(); + } + + public static void syncTrainAgentLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + agentsClient.trainAgentAsync(parent).get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_trainagent_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgentProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgentProjectname.java new file mode 100644 index 000000000000..70049d5e5c92 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgentProjectname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_trainagent_projectname_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncTrainAgentProjectname { + + public static void main(String[] args) throws Exception { + syncTrainAgentProjectname(); + } + + public static void syncTrainAgentProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + agentsClient.trainAgentAsync(parent).get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_trainagent_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgentString.java new file mode 100644 index 000000000000..eb6c35140609 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentsclient/trainagent/SyncTrainAgentString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsclient_trainagent_string_sync] +import com.google.cloud.dialogflow.v2.AgentsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncTrainAgentString { + + public static void main(String[] args) throws Exception { + syncTrainAgentString(); + } + + public static void syncTrainAgentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + agentsClient.trainAgentAsync(parent).get(); + } + } +} +// [END dialogflow_v2_generated_agentsclient_trainagent_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentssettings/getagent/SyncGetAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentssettings/getagent/SyncGetAgent.java new file mode 100644 index 000000000000..16b16b264547 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/agentssettings/getagent/SyncGetAgent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentssettings_getagent_sync] +import com.google.cloud.dialogflow.v2.AgentsSettings; +import java.time.Duration; + +public class SyncGetAgent { + + public static void main(String[] args) throws Exception { + syncGetAgent(); + } + + public static void syncGetAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AgentsSettings.Builder agentsSettingsBuilder = AgentsSettings.newBuilder(); + agentsSettingsBuilder + .getAgentSettings() + .setRetrySettings( + agentsSettingsBuilder + .getAgentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + AgentsSettings agentsSettings = agentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_agentssettings_getagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..d9f970fd0c03 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2.AnswerRecordsSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AnswerRecordsSettings answerRecordsSettings = + AnswerRecordsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings); + } +} +// [END dialogflow_v2_generated_answerrecordsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..e0edee528d56 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2.AnswerRecordsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AnswerRecordsSettings answerRecordsSettings = + AnswerRecordsSettings.newBuilder() + .setTransportChannelProvider( + AnswerRecordsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings); + } +} +// [END dialogflow_v2_generated_answerrecordsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..a86ae170325a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2.AnswerRecordsSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AnswerRecordsSettings answerRecordsSettings = + AnswerRecordsSettings.newBuilder().setEndpoint(myEndpoint).build(); + AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings); + } +} +// [END dialogflow_v2_generated_answerrecordsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/AsyncListAnswerRecords.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/AsyncListAnswerRecords.java new file mode 100644 index 000000000000..712a1b1e7630 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/AsyncListAnswerRecords.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordsclient_listanswerrecords_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AnswerRecord; +import com.google.cloud.dialogflow.v2.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2.ListAnswerRecordsRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class AsyncListAnswerRecords { + + public static void main(String[] args) throws Exception { + asyncListAnswerRecords(); + } + + public static void asyncListAnswerRecords() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + ListAnswerRecordsRequest request = + ListAnswerRecordsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + answerRecordsClient.listAnswerRecordsPagedCallable().futureCall(request); + // Do something. + for (AnswerRecord element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_answerrecordsclient_listanswerrecords_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/AsyncListAnswerRecordsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/AsyncListAnswerRecordsPaged.java new file mode 100644 index 000000000000..cbcfc125ef62 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/AsyncListAnswerRecordsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordsclient_listanswerrecords_paged_async] +import com.google.cloud.dialogflow.v2.AnswerRecord; +import com.google.cloud.dialogflow.v2.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2.ListAnswerRecordsRequest; +import com.google.cloud.dialogflow.v2.ListAnswerRecordsResponse; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListAnswerRecordsPaged { + + public static void main(String[] args) throws Exception { + asyncListAnswerRecordsPaged(); + } + + public static void asyncListAnswerRecordsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + ListAnswerRecordsRequest request = + ListAnswerRecordsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListAnswerRecordsResponse response = + answerRecordsClient.listAnswerRecordsCallable().call(request); + for (AnswerRecord element : response.getAnswerRecordsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2_generated_answerrecordsclient_listanswerrecords_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecords.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecords.java new file mode 100644 index 000000000000..e56b1ab2f996 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecords.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordsclient_listanswerrecords_sync] +import com.google.cloud.dialogflow.v2.AnswerRecord; +import com.google.cloud.dialogflow.v2.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2.ListAnswerRecordsRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncListAnswerRecords { + + public static void main(String[] args) throws Exception { + syncListAnswerRecords(); + } + + public static void syncListAnswerRecords() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + ListAnswerRecordsRequest request = + ListAnswerRecordsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (AnswerRecord element : answerRecordsClient.listAnswerRecords(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_answerrecordsclient_listanswerrecords_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsLocationname.java new file mode 100644 index 000000000000..756ff2447934 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordsclient_listanswerrecords_locationname_sync] +import com.google.cloud.dialogflow.v2.AnswerRecord; +import com.google.cloud.dialogflow.v2.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncListAnswerRecordsLocationname { + + public static void main(String[] args) throws Exception { + syncListAnswerRecordsLocationname(); + } + + public static void syncListAnswerRecordsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (AnswerRecord element : answerRecordsClient.listAnswerRecords(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_answerrecordsclient_listanswerrecords_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsProjectname.java new file mode 100644 index 000000000000..fd5073544cd2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsProjectname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordsclient_listanswerrecords_projectname_sync] +import com.google.cloud.dialogflow.v2.AnswerRecord; +import com.google.cloud.dialogflow.v2.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncListAnswerRecordsProjectname { + + public static void main(String[] args) throws Exception { + syncListAnswerRecordsProjectname(); + } + + public static void syncListAnswerRecordsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (AnswerRecord element : answerRecordsClient.listAnswerRecords(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_answerrecordsclient_listanswerrecords_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsString.java new file mode 100644 index 000000000000..1fdcac696009 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordsclient_listanswerrecords_string_sync] +import com.google.cloud.dialogflow.v2.AnswerRecord; +import com.google.cloud.dialogflow.v2.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncListAnswerRecordsString { + + public static void main(String[] args) throws Exception { + syncListAnswerRecordsString(); + } + + public static void syncListAnswerRecordsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (AnswerRecord element : answerRecordsClient.listAnswerRecords(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_answerrecordsclient_listanswerrecords_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/updateanswerrecord/AsyncUpdateAnswerRecord.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/updateanswerrecord/AsyncUpdateAnswerRecord.java new file mode 100644 index 000000000000..0de9c442541a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/updateanswerrecord/AsyncUpdateAnswerRecord.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordsclient_updateanswerrecord_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AnswerRecord; +import com.google.cloud.dialogflow.v2.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2.UpdateAnswerRecordRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateAnswerRecord { + + public static void main(String[] args) throws Exception { + asyncUpdateAnswerRecord(); + } + + public static void asyncUpdateAnswerRecord() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + UpdateAnswerRecordRequest request = + UpdateAnswerRecordRequest.newBuilder() + .setAnswerRecord(AnswerRecord.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + answerRecordsClient.updateAnswerRecordCallable().futureCall(request); + // Do something. + AnswerRecord response = future.get(); + } + } +} +// [END dialogflow_v2_generated_answerrecordsclient_updateanswerrecord_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecord.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecord.java new file mode 100644 index 000000000000..6d02e3cf135f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecord.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordsclient_updateanswerrecord_sync] +import com.google.cloud.dialogflow.v2.AnswerRecord; +import com.google.cloud.dialogflow.v2.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2.UpdateAnswerRecordRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateAnswerRecord { + + public static void main(String[] args) throws Exception { + syncUpdateAnswerRecord(); + } + + public static void syncUpdateAnswerRecord() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + UpdateAnswerRecordRequest request = + UpdateAnswerRecordRequest.newBuilder() + .setAnswerRecord(AnswerRecord.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + AnswerRecord response = answerRecordsClient.updateAnswerRecord(request); + } + } +} +// [END dialogflow_v2_generated_answerrecordsclient_updateanswerrecord_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecordAnswerrecordFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecordAnswerrecordFieldmask.java new file mode 100644 index 000000000000..320c5702fc8b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecordAnswerrecordFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordsclient_updateanswerrecord_answerrecordfieldmask_sync] +import com.google.cloud.dialogflow.v2.AnswerRecord; +import com.google.cloud.dialogflow.v2.AnswerRecordsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateAnswerRecordAnswerrecordFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateAnswerRecordAnswerrecordFieldmask(); + } + + public static void syncUpdateAnswerRecordAnswerrecordFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + AnswerRecord answerRecord = AnswerRecord.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + AnswerRecord response = answerRecordsClient.updateAnswerRecord(answerRecord, updateMask); + } + } +} +// [END dialogflow_v2_generated_answerrecordsclient_updateanswerrecord_answerrecordfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordssettings/updateanswerrecord/SyncUpdateAnswerRecord.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordssettings/updateanswerrecord/SyncUpdateAnswerRecord.java new file mode 100644 index 000000000000..784a0160408e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/answerrecordssettings/updateanswerrecord/SyncUpdateAnswerRecord.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordssettings_updateanswerrecord_sync] +import com.google.cloud.dialogflow.v2.AnswerRecordsSettings; +import java.time.Duration; + +public class SyncUpdateAnswerRecord { + + public static void main(String[] args) throws Exception { + syncUpdateAnswerRecord(); + } + + public static void syncUpdateAnswerRecord() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AnswerRecordsSettings.Builder answerRecordsSettingsBuilder = AnswerRecordsSettings.newBuilder(); + answerRecordsSettingsBuilder + .updateAnswerRecordSettings() + .setRetrySettings( + answerRecordsSettingsBuilder + .updateAnswerRecordSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + AnswerRecordsSettings answerRecordsSettings = answerRecordsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_answerrecordssettings_updateanswerrecord_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..0cba62fa6880 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.ContextsSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ContextsSettings contextsSettings = + ContextsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ContextsClient contextsClient = ContextsClient.create(contextsSettings); + } +} +// [END dialogflow_v2_generated_contextsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..05c889b3715d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.ContextsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ContextsSettings contextsSettings = + ContextsSettings.newBuilder() + .setTransportChannelProvider( + ContextsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ContextsClient contextsClient = ContextsClient.create(contextsSettings); + } +} +// [END dialogflow_v2_generated_contextsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..d510c03938b0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.ContextsSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ContextsSettings contextsSettings = + ContextsSettings.newBuilder().setEndpoint(myEndpoint).build(); + ContextsClient contextsClient = ContextsClient.create(contextsSettings); + } +} +// [END dialogflow_v2_generated_contextsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/AsyncCreateContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/AsyncCreateContext.java new file mode 100644 index 000000000000..5e28a6d07f94 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/AsyncCreateContext.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_createcontext_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.CreateContextRequest; +import com.google.cloud.dialogflow.v2.SessionName; + +public class AsyncCreateContext { + + public static void main(String[] args) throws Exception { + asyncCreateContext(); + } + + public static void asyncCreateContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + CreateContextRequest request = + CreateContextRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setContext(Context.newBuilder().build()) + .build(); + ApiFuture future = contextsClient.createContextCallable().futureCall(request); + // Do something. + Context response = future.get(); + } + } +} +// [END dialogflow_v2_generated_contextsclient_createcontext_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/SyncCreateContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/SyncCreateContext.java new file mode 100644 index 000000000000..2853602c1a9a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/SyncCreateContext.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_createcontext_sync] +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.CreateContextRequest; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncCreateContext { + + public static void main(String[] args) throws Exception { + syncCreateContext(); + } + + public static void syncCreateContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + CreateContextRequest request = + CreateContextRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setContext(Context.newBuilder().build()) + .build(); + Context response = contextsClient.createContext(request); + } + } +} +// [END dialogflow_v2_generated_contextsclient_createcontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/SyncCreateContextSessionnameContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/SyncCreateContextSessionnameContext.java new file mode 100644 index 000000000000..75b8d6c036ad --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/SyncCreateContextSessionnameContext.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_createcontext_sessionnamecontext_sync] +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncCreateContextSessionnameContext { + + public static void main(String[] args) throws Exception { + syncCreateContextSessionnameContext(); + } + + public static void syncCreateContextSessionnameContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + Context context = Context.newBuilder().build(); + Context response = contextsClient.createContext(parent, context); + } + } +} +// [END dialogflow_v2_generated_contextsclient_createcontext_sessionnamecontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/SyncCreateContextStringContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/SyncCreateContextStringContext.java new file mode 100644 index 000000000000..01b5f9eb8787 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/createcontext/SyncCreateContextStringContext.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_createcontext_stringcontext_sync] +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncCreateContextStringContext { + + public static void main(String[] args) throws Exception { + syncCreateContextStringContext(); + } + + public static void syncCreateContextStringContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + String parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString(); + Context context = Context.newBuilder().build(); + Context response = contextsClient.createContext(parent, context); + } + } +} +// [END dialogflow_v2_generated_contextsclient_createcontext_stringcontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/AsyncDeleteAllContexts.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/AsyncDeleteAllContexts.java new file mode 100644 index 000000000000..35320643bdad --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/AsyncDeleteAllContexts.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_deleteallcontexts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.DeleteAllContextsRequest; +import com.google.cloud.dialogflow.v2.SessionName; +import com.google.protobuf.Empty; + +public class AsyncDeleteAllContexts { + + public static void main(String[] args) throws Exception { + asyncDeleteAllContexts(); + } + + public static void asyncDeleteAllContexts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + DeleteAllContextsRequest request = + DeleteAllContextsRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .build(); + ApiFuture future = contextsClient.deleteAllContextsCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_contextsclient_deleteallcontexts_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/SyncDeleteAllContexts.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/SyncDeleteAllContexts.java new file mode 100644 index 000000000000..ed11b8fd1755 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/SyncDeleteAllContexts.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_deleteallcontexts_sync] +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.DeleteAllContextsRequest; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncDeleteAllContexts { + + public static void main(String[] args) throws Exception { + syncDeleteAllContexts(); + } + + public static void syncDeleteAllContexts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + DeleteAllContextsRequest request = + DeleteAllContextsRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .build(); + contextsClient.deleteAllContexts(request); + } + } +} +// [END dialogflow_v2_generated_contextsclient_deleteallcontexts_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/SyncDeleteAllContextsSessionname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/SyncDeleteAllContextsSessionname.java new file mode 100644 index 000000000000..233b383b964a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/SyncDeleteAllContextsSessionname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_deleteallcontexts_sessionname_sync] +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncDeleteAllContextsSessionname { + + public static void main(String[] args) throws Exception { + syncDeleteAllContextsSessionname(); + } + + public static void syncDeleteAllContextsSessionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + contextsClient.deleteAllContexts(parent); + } + } +} +// [END dialogflow_v2_generated_contextsclient_deleteallcontexts_sessionname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/SyncDeleteAllContextsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/SyncDeleteAllContextsString.java new file mode 100644 index 000000000000..bbf8aa0fc5a2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deleteallcontexts/SyncDeleteAllContextsString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_deleteallcontexts_string_sync] +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncDeleteAllContextsString { + + public static void main(String[] args) throws Exception { + syncDeleteAllContextsString(); + } + + public static void syncDeleteAllContextsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + String parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString(); + contextsClient.deleteAllContexts(parent); + } + } +} +// [END dialogflow_v2_generated_contextsclient_deleteallcontexts_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/AsyncDeleteContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/AsyncDeleteContext.java new file mode 100644 index 000000000000..a437ce3c0fb2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/AsyncDeleteContext.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_deletecontext_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ContextName; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.DeleteContextRequest; +import com.google.protobuf.Empty; + +public class AsyncDeleteContext { + + public static void main(String[] args) throws Exception { + asyncDeleteContext(); + } + + public static void asyncDeleteContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + DeleteContextRequest request = + DeleteContextRequest.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .build(); + ApiFuture future = contextsClient.deleteContextCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_contextsclient_deletecontext_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/SyncDeleteContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/SyncDeleteContext.java new file mode 100644 index 000000000000..9125ab68be21 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/SyncDeleteContext.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_deletecontext_sync] +import com.google.cloud.dialogflow.v2.ContextName; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.DeleteContextRequest; + +public class SyncDeleteContext { + + public static void main(String[] args) throws Exception { + syncDeleteContext(); + } + + public static void syncDeleteContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + DeleteContextRequest request = + DeleteContextRequest.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .build(); + contextsClient.deleteContext(request); + } + } +} +// [END dialogflow_v2_generated_contextsclient_deletecontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/SyncDeleteContextContextname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/SyncDeleteContextContextname.java new file mode 100644 index 000000000000..f6ca869ac76e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/SyncDeleteContextContextname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_deletecontext_contextname_sync] +import com.google.cloud.dialogflow.v2.ContextName; +import com.google.cloud.dialogflow.v2.ContextsClient; + +public class SyncDeleteContextContextname { + + public static void main(String[] args) throws Exception { + syncDeleteContextContextname(); + } + + public static void syncDeleteContextContextname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + ContextName name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"); + contextsClient.deleteContext(name); + } + } +} +// [END dialogflow_v2_generated_contextsclient_deletecontext_contextname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/SyncDeleteContextString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/SyncDeleteContextString.java new file mode 100644 index 000000000000..534adb600e66 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/deletecontext/SyncDeleteContextString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_deletecontext_string_sync] +import com.google.cloud.dialogflow.v2.ContextName; +import com.google.cloud.dialogflow.v2.ContextsClient; + +public class SyncDeleteContextString { + + public static void main(String[] args) throws Exception { + syncDeleteContextString(); + } + + public static void syncDeleteContextString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + String name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]").toString(); + contextsClient.deleteContext(name); + } + } +} +// [END dialogflow_v2_generated_contextsclient_deletecontext_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/AsyncGetContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/AsyncGetContext.java new file mode 100644 index 000000000000..e4b00c7716c8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/AsyncGetContext.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_getcontext_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextName; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.GetContextRequest; + +public class AsyncGetContext { + + public static void main(String[] args) throws Exception { + asyncGetContext(); + } + + public static void asyncGetContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + GetContextRequest request = + GetContextRequest.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .build(); + ApiFuture future = contextsClient.getContextCallable().futureCall(request); + // Do something. + Context response = future.get(); + } + } +} +// [END dialogflow_v2_generated_contextsclient_getcontext_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/SyncGetContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/SyncGetContext.java new file mode 100644 index 000000000000..e92514ba5d51 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/SyncGetContext.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_getcontext_sync] +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextName; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.GetContextRequest; + +public class SyncGetContext { + + public static void main(String[] args) throws Exception { + syncGetContext(); + } + + public static void syncGetContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + GetContextRequest request = + GetContextRequest.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .build(); + Context response = contextsClient.getContext(request); + } + } +} +// [END dialogflow_v2_generated_contextsclient_getcontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/SyncGetContextContextname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/SyncGetContextContextname.java new file mode 100644 index 000000000000..882a34632567 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/SyncGetContextContextname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_getcontext_contextname_sync] +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextName; +import com.google.cloud.dialogflow.v2.ContextsClient; + +public class SyncGetContextContextname { + + public static void main(String[] args) throws Exception { + syncGetContextContextname(); + } + + public static void syncGetContextContextname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + ContextName name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"); + Context response = contextsClient.getContext(name); + } + } +} +// [END dialogflow_v2_generated_contextsclient_getcontext_contextname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/SyncGetContextString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/SyncGetContextString.java new file mode 100644 index 000000000000..f0442e3d2894 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/getcontext/SyncGetContextString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_getcontext_string_sync] +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextName; +import com.google.cloud.dialogflow.v2.ContextsClient; + +public class SyncGetContextString { + + public static void main(String[] args) throws Exception { + syncGetContextString(); + } + + public static void syncGetContextString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + String name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]").toString(); + Context response = contextsClient.getContext(name); + } + } +} +// [END dialogflow_v2_generated_contextsclient_getcontext_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/AsyncListContexts.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/AsyncListContexts.java new file mode 100644 index 000000000000..4699a8a97254 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/AsyncListContexts.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_listcontexts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.ListContextsRequest; +import com.google.cloud.dialogflow.v2.SessionName; + +public class AsyncListContexts { + + public static void main(String[] args) throws Exception { + asyncListContexts(); + } + + public static void asyncListContexts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + ListContextsRequest request = + ListContextsRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = contextsClient.listContextsPagedCallable().futureCall(request); + // Do something. + for (Context element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_contextsclient_listcontexts_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/AsyncListContextsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/AsyncListContextsPaged.java new file mode 100644 index 000000000000..97ba57ceb662 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/AsyncListContextsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_listcontexts_paged_async] +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.ListContextsRequest; +import com.google.cloud.dialogflow.v2.ListContextsResponse; +import com.google.cloud.dialogflow.v2.SessionName; +import com.google.common.base.Strings; + +public class AsyncListContextsPaged { + + public static void main(String[] args) throws Exception { + asyncListContextsPaged(); + } + + public static void asyncListContextsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + ListContextsRequest request = + ListContextsRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .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; + } + } + } + } +} +// [END dialogflow_v2_generated_contextsclient_listcontexts_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/SyncListContexts.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/SyncListContexts.java new file mode 100644 index 000000000000..33fa129feaed --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/SyncListContexts.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_listcontexts_sync] +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.ListContextsRequest; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncListContexts { + + public static void main(String[] args) throws Exception { + syncListContexts(); + } + + public static void syncListContexts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + ListContextsRequest request = + ListContextsRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Context element : contextsClient.listContexts(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_contextsclient_listcontexts_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/SyncListContextsSessionname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/SyncListContextsSessionname.java new file mode 100644 index 000000000000..79cd7774ea4d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/SyncListContextsSessionname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_listcontexts_sessionname_sync] +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncListContextsSessionname { + + public static void main(String[] args) throws Exception { + syncListContextsSessionname(); + } + + public static void syncListContextsSessionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + for (Context element : contextsClient.listContexts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_contextsclient_listcontexts_sessionname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/SyncListContextsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/SyncListContextsString.java new file mode 100644 index 000000000000..c6fea207fd30 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/listcontexts/SyncListContextsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_listcontexts_string_sync] +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncListContextsString { + + public static void main(String[] args) throws Exception { + syncListContextsString(); + } + + public static void syncListContextsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + String parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString(); + for (Context element : contextsClient.listContexts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_contextsclient_listcontexts_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/updatecontext/AsyncUpdateContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/updatecontext/AsyncUpdateContext.java new file mode 100644 index 000000000000..2a8767fb8df9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/updatecontext/AsyncUpdateContext.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_updatecontext_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.UpdateContextRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateContext { + + public static void main(String[] args) throws Exception { + asyncUpdateContext(); + } + + public static void asyncUpdateContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + UpdateContextRequest request = + UpdateContextRequest.newBuilder() + .setContext(Context.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = contextsClient.updateContextCallable().futureCall(request); + // Do something. + Context response = future.get(); + } + } +} +// [END dialogflow_v2_generated_contextsclient_updatecontext_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/updatecontext/SyncUpdateContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/updatecontext/SyncUpdateContext.java new file mode 100644 index 000000000000..7d2d649775b7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/updatecontext/SyncUpdateContext.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_updatecontext_sync] +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.cloud.dialogflow.v2.UpdateContextRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateContext { + + public static void main(String[] args) throws Exception { + syncUpdateContext(); + } + + public static void syncUpdateContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + UpdateContextRequest request = + UpdateContextRequest.newBuilder() + .setContext(Context.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Context response = contextsClient.updateContext(request); + } + } +} +// [END dialogflow_v2_generated_contextsclient_updatecontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/updatecontext/SyncUpdateContextContextFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/updatecontext/SyncUpdateContextContextFieldmask.java new file mode 100644 index 000000000000..dd8bb7a0ca19 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextsclient/updatecontext/SyncUpdateContextContextFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsclient_updatecontext_contextfieldmask_sync] +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.ContextsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateContextContextFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateContextContextFieldmask(); + } + + public static void syncUpdateContextContextFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + Context context = Context.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Context response = contextsClient.updateContext(context, updateMask); + } + } +} +// [END dialogflow_v2_generated_contextsclient_updatecontext_contextfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextssettings/getcontext/SyncGetContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextssettings/getcontext/SyncGetContext.java new file mode 100644 index 000000000000..8325f041c2f6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/contextssettings/getcontext/SyncGetContext.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextssettings_getcontext_sync] +import com.google.cloud.dialogflow.v2.ContextsSettings; +import java.time.Duration; + +public class SyncGetContext { + + public static void main(String[] args) throws Exception { + syncGetContext(); + } + + public static void syncGetContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ContextsSettings.Builder contextsSettingsBuilder = ContextsSettings.newBuilder(); + contextsSettingsBuilder + .getContextSettings() + .setRetrySettings( + contextsSettingsBuilder + .getContextSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ContextsSettings contextsSettings = contextsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_contextssettings_getcontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..ef625bf92e17 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.ConversationDatasetsSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationDatasetsSettings conversationDatasetsSettings = + ConversationDatasetsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create(conversationDatasetsSettings); + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..35e20890f7c3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.ConversationDatasetsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationDatasetsSettings conversationDatasetsSettings = + ConversationDatasetsSettings.newBuilder() + .setTransportChannelProvider( + ConversationDatasetsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create(conversationDatasetsSettings); + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..393333d190a6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.ConversationDatasetsSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationDatasetsSettings conversationDatasetsSettings = + ConversationDatasetsSettings.newBuilder().setEndpoint(myEndpoint).build(); + ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create(conversationDatasetsSettings); + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/AsyncCreateConversationDataset.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/AsyncCreateConversationDataset.java new file mode 100644 index 000000000000..719695d0ee4a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/AsyncCreateConversationDataset.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_createconversationdataset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationDataset; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.CreateConversationDatasetRequest; +import com.google.longrunning.Operation; + +public class AsyncCreateConversationDataset { + + public static void main(String[] args) throws Exception { + asyncCreateConversationDataset(); + } + + public static void asyncCreateConversationDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + CreateConversationDatasetRequest request = + CreateConversationDatasetRequest.newBuilder() + .setParent("parent-995424086") + .setConversationDataset(ConversationDataset.newBuilder().build()) + .build(); + ApiFuture future = + conversationDatasetsClient.createConversationDatasetCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_createconversationdataset_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/AsyncCreateConversationDatasetLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/AsyncCreateConversationDatasetLRO.java new file mode 100644 index 000000000000..f4c9b7816f3a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/AsyncCreateConversationDatasetLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_createconversationdataset_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.ConversationDataset; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.CreateConversationDatasetOperationMetadata; +import com.google.cloud.dialogflow.v2.CreateConversationDatasetRequest; + +public class AsyncCreateConversationDatasetLRO { + + public static void main(String[] args) throws Exception { + asyncCreateConversationDatasetLRO(); + } + + public static void asyncCreateConversationDatasetLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + CreateConversationDatasetRequest request = + CreateConversationDatasetRequest.newBuilder() + .setParent("parent-995424086") + .setConversationDataset(ConversationDataset.newBuilder().build()) + .build(); + OperationFuture future = + conversationDatasetsClient + .createConversationDatasetOperationCallable() + .futureCall(request); + // Do something. + ConversationDataset response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_createconversationdataset_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/SyncCreateConversationDataset.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/SyncCreateConversationDataset.java new file mode 100644 index 000000000000..344439533ff1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/SyncCreateConversationDataset.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_createconversationdataset_sync] +import com.google.cloud.dialogflow.v2.ConversationDataset; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.CreateConversationDatasetRequest; + +public class SyncCreateConversationDataset { + + public static void main(String[] args) throws Exception { + syncCreateConversationDataset(); + } + + public static void syncCreateConversationDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + CreateConversationDatasetRequest request = + CreateConversationDatasetRequest.newBuilder() + .setParent("parent-995424086") + .setConversationDataset(ConversationDataset.newBuilder().build()) + .build(); + ConversationDataset response = + conversationDatasetsClient.createConversationDatasetAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_createconversationdataset_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/SyncCreateConversationDatasetStringConversationdataset.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/SyncCreateConversationDatasetStringConversationdataset.java new file mode 100644 index 000000000000..dab84436098b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/createconversationdataset/SyncCreateConversationDatasetStringConversationdataset.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationdatasetsclient_createconversationdataset_stringconversationdataset_sync] +import com.google.cloud.dialogflow.v2.ConversationDataset; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; + +public class SyncCreateConversationDatasetStringConversationdataset { + + public static void main(String[] args) throws Exception { + syncCreateConversationDatasetStringConversationdataset(); + } + + public static void syncCreateConversationDatasetStringConversationdataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + String parent = "parent-995424086"; + ConversationDataset conversationDataset = ConversationDataset.newBuilder().build(); + ConversationDataset response = + conversationDatasetsClient + .createConversationDatasetAsync(parent, conversationDataset) + .get(); + } + } +} +// [END +// dialogflow_v2_generated_conversationdatasetsclient_createconversationdataset_stringconversationdataset_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/AsyncDeleteConversationDataset.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/AsyncDeleteConversationDataset.java new file mode 100644 index 000000000000..7c3f74c5ee33 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/AsyncDeleteConversationDataset.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_deleteconversationdataset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationDatasetName; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.DeleteConversationDatasetRequest; +import com.google.longrunning.Operation; + +public class AsyncDeleteConversationDataset { + + public static void main(String[] args) throws Exception { + asyncDeleteConversationDataset(); + } + + public static void asyncDeleteConversationDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + DeleteConversationDatasetRequest request = + DeleteConversationDatasetRequest.newBuilder() + .setName( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .build(); + ApiFuture future = + conversationDatasetsClient.deleteConversationDatasetCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_deleteconversationdataset_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/AsyncDeleteConversationDatasetLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/AsyncDeleteConversationDatasetLRO.java new file mode 100644 index 000000000000..037e71902d77 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/AsyncDeleteConversationDatasetLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_deleteconversationdataset_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.ConversationDatasetName; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.DeleteConversationDatasetOperationMetadata; +import com.google.cloud.dialogflow.v2.DeleteConversationDatasetRequest; +import com.google.protobuf.Empty; + +public class AsyncDeleteConversationDatasetLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteConversationDatasetLRO(); + } + + public static void asyncDeleteConversationDatasetLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + DeleteConversationDatasetRequest request = + DeleteConversationDatasetRequest.newBuilder() + .setName( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .build(); + OperationFuture future = + conversationDatasetsClient + .deleteConversationDatasetOperationCallable() + .futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_deleteconversationdataset_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/SyncDeleteConversationDataset.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/SyncDeleteConversationDataset.java new file mode 100644 index 000000000000..ce926c3a2d73 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/SyncDeleteConversationDataset.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_deleteconversationdataset_sync] +import com.google.cloud.dialogflow.v2.ConversationDatasetName; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.DeleteConversationDatasetRequest; + +public class SyncDeleteConversationDataset { + + public static void main(String[] args) throws Exception { + syncDeleteConversationDataset(); + } + + public static void syncDeleteConversationDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + DeleteConversationDatasetRequest request = + DeleteConversationDatasetRequest.newBuilder() + .setName( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .build(); + conversationDatasetsClient.deleteConversationDatasetAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_deleteconversationdataset_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/SyncDeleteConversationDatasetConversationdatasetname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/SyncDeleteConversationDatasetConversationdatasetname.java new file mode 100644 index 000000000000..28c09960590c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/SyncDeleteConversationDatasetConversationdatasetname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationdatasetsclient_deleteconversationdataset_conversationdatasetname_sync] +import com.google.cloud.dialogflow.v2.ConversationDatasetName; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; + +public class SyncDeleteConversationDatasetConversationdatasetname { + + public static void main(String[] args) throws Exception { + syncDeleteConversationDatasetConversationdatasetname(); + } + + public static void syncDeleteConversationDatasetConversationdatasetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + ConversationDatasetName name = + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]"); + conversationDatasetsClient.deleteConversationDatasetAsync(name).get(); + } + } +} +// [END +// dialogflow_v2_generated_conversationdatasetsclient_deleteconversationdataset_conversationdatasetname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/SyncDeleteConversationDatasetString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/SyncDeleteConversationDatasetString.java new file mode 100644 index 000000000000..d5a455e1db8b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/deleteconversationdataset/SyncDeleteConversationDatasetString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_deleteconversationdataset_string_sync] +import com.google.cloud.dialogflow.v2.ConversationDatasetName; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; + +public class SyncDeleteConversationDatasetString { + + public static void main(String[] args) throws Exception { + syncDeleteConversationDatasetString(); + } + + public static void syncDeleteConversationDatasetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + String name = + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString(); + conversationDatasetsClient.deleteConversationDatasetAsync(name).get(); + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_deleteconversationdataset_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/AsyncGetConversationDataset.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/AsyncGetConversationDataset.java new file mode 100644 index 000000000000..b9b649b8c818 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/AsyncGetConversationDataset.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_getconversationdataset_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationDataset; +import com.google.cloud.dialogflow.v2.ConversationDatasetName; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.GetConversationDatasetRequest; + +public class AsyncGetConversationDataset { + + public static void main(String[] args) throws Exception { + asyncGetConversationDataset(); + } + + public static void asyncGetConversationDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + GetConversationDatasetRequest request = + GetConversationDatasetRequest.newBuilder() + .setName( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .build(); + ApiFuture future = + conversationDatasetsClient.getConversationDatasetCallable().futureCall(request); + // Do something. + ConversationDataset response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_getconversationdataset_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/SyncGetConversationDataset.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/SyncGetConversationDataset.java new file mode 100644 index 000000000000..e332ba3e751c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/SyncGetConversationDataset.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_getconversationdataset_sync] +import com.google.cloud.dialogflow.v2.ConversationDataset; +import com.google.cloud.dialogflow.v2.ConversationDatasetName; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.GetConversationDatasetRequest; + +public class SyncGetConversationDataset { + + public static void main(String[] args) throws Exception { + syncGetConversationDataset(); + } + + public static void syncGetConversationDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + GetConversationDatasetRequest request = + GetConversationDatasetRequest.newBuilder() + .setName( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .build(); + ConversationDataset response = conversationDatasetsClient.getConversationDataset(request); + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_getconversationdataset_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/SyncGetConversationDatasetConversationdatasetname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/SyncGetConversationDatasetConversationdatasetname.java new file mode 100644 index 000000000000..21e2fe199206 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/SyncGetConversationDatasetConversationdatasetname.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationdatasetsclient_getconversationdataset_conversationdatasetname_sync] +import com.google.cloud.dialogflow.v2.ConversationDataset; +import com.google.cloud.dialogflow.v2.ConversationDatasetName; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; + +public class SyncGetConversationDatasetConversationdatasetname { + + public static void main(String[] args) throws Exception { + syncGetConversationDatasetConversationdatasetname(); + } + + public static void syncGetConversationDatasetConversationdatasetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + ConversationDatasetName name = + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]"); + ConversationDataset response = conversationDatasetsClient.getConversationDataset(name); + } + } +} +// [END +// dialogflow_v2_generated_conversationdatasetsclient_getconversationdataset_conversationdatasetname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/SyncGetConversationDatasetString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/SyncGetConversationDatasetString.java new file mode 100644 index 000000000000..224bbb487949 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/getconversationdataset/SyncGetConversationDatasetString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_getconversationdataset_string_sync] +import com.google.cloud.dialogflow.v2.ConversationDataset; +import com.google.cloud.dialogflow.v2.ConversationDatasetName; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; + +public class SyncGetConversationDatasetString { + + public static void main(String[] args) throws Exception { + syncGetConversationDatasetString(); + } + + public static void syncGetConversationDatasetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + String name = + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString(); + ConversationDataset response = conversationDatasetsClient.getConversationDataset(name); + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_getconversationdataset_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/importconversationdata/AsyncImportConversationData.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/importconversationdata/AsyncImportConversationData.java new file mode 100644 index 000000000000..3cf17383ef75 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/importconversationdata/AsyncImportConversationData.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_importconversationdata_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationDatasetName; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.ImportConversationDataRequest; +import com.google.cloud.dialogflow.v2.InputConfig; +import com.google.longrunning.Operation; + +public class AsyncImportConversationData { + + public static void main(String[] args) throws Exception { + asyncImportConversationData(); + } + + public static void asyncImportConversationData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + ImportConversationDataRequest request = + ImportConversationDataRequest.newBuilder() + .setName( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .setInputConfig(InputConfig.newBuilder().build()) + .build(); + ApiFuture future = + conversationDatasetsClient.importConversationDataCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_importconversationdata_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/importconversationdata/AsyncImportConversationDataLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/importconversationdata/AsyncImportConversationDataLRO.java new file mode 100644 index 000000000000..fb18cffbf466 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/importconversationdata/AsyncImportConversationDataLRO.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_importconversationdata_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.ConversationDatasetName; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.ImportConversationDataOperationMetadata; +import com.google.cloud.dialogflow.v2.ImportConversationDataOperationResponse; +import com.google.cloud.dialogflow.v2.ImportConversationDataRequest; +import com.google.cloud.dialogflow.v2.InputConfig; + +public class AsyncImportConversationDataLRO { + + public static void main(String[] args) throws Exception { + asyncImportConversationDataLRO(); + } + + public static void asyncImportConversationDataLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + ImportConversationDataRequest request = + ImportConversationDataRequest.newBuilder() + .setName( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .setInputConfig(InputConfig.newBuilder().build()) + .build(); + OperationFuture< + ImportConversationDataOperationResponse, ImportConversationDataOperationMetadata> + future = + conversationDatasetsClient + .importConversationDataOperationCallable() + .futureCall(request); + // Do something. + ImportConversationDataOperationResponse response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_importconversationdata_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/importconversationdata/SyncImportConversationData.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/importconversationdata/SyncImportConversationData.java new file mode 100644 index 000000000000..05614536b98a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/importconversationdata/SyncImportConversationData.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_importconversationdata_sync] +import com.google.cloud.dialogflow.v2.ConversationDatasetName; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.ImportConversationDataOperationResponse; +import com.google.cloud.dialogflow.v2.ImportConversationDataRequest; +import com.google.cloud.dialogflow.v2.InputConfig; + +public class SyncImportConversationData { + + public static void main(String[] args) throws Exception { + syncImportConversationData(); + } + + public static void syncImportConversationData() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + ImportConversationDataRequest request = + ImportConversationDataRequest.newBuilder() + .setName( + ConversationDatasetName.of("[PROJECT]", "[LOCATION]", "[CONVERSATION_DATASET]") + .toString()) + .setInputConfig(InputConfig.newBuilder().build()) + .build(); + ImportConversationDataOperationResponse response = + conversationDatasetsClient.importConversationDataAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_importconversationdata_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/AsyncListConversationDatasets.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/AsyncListConversationDatasets.java new file mode 100644 index 000000000000..b3672026e6bf --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/AsyncListConversationDatasets.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_listconversationdatasets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationDataset; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.ListConversationDatasetsRequest; +import com.google.cloud.dialogflow.v2.LocationName; + +public class AsyncListConversationDatasets { + + public static void main(String[] args) throws Exception { + asyncListConversationDatasets(); + } + + public static void asyncListConversationDatasets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + ListConversationDatasetsRequest request = + ListConversationDatasetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + conversationDatasetsClient.listConversationDatasetsPagedCallable().futureCall(request); + // Do something. + for (ConversationDataset element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_listconversationdatasets_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/AsyncListConversationDatasetsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/AsyncListConversationDatasetsPaged.java new file mode 100644 index 000000000000..b20dbad8961b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/AsyncListConversationDatasetsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_listconversationdatasets_paged_async] +import com.google.cloud.dialogflow.v2.ConversationDataset; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.ListConversationDatasetsRequest; +import com.google.cloud.dialogflow.v2.ListConversationDatasetsResponse; +import com.google.cloud.dialogflow.v2.LocationName; +import com.google.common.base.Strings; + +public class AsyncListConversationDatasetsPaged { + + public static void main(String[] args) throws Exception { + asyncListConversationDatasetsPaged(); + } + + public static void asyncListConversationDatasetsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + ListConversationDatasetsRequest request = + ListConversationDatasetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListConversationDatasetsResponse response = + conversationDatasetsClient.listConversationDatasetsCallable().call(request); + for (ConversationDataset element : response.getConversationDatasetsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_listconversationdatasets_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/SyncListConversationDatasets.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/SyncListConversationDatasets.java new file mode 100644 index 000000000000..b010715a7f70 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/SyncListConversationDatasets.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_listconversationdatasets_sync] +import com.google.cloud.dialogflow.v2.ConversationDataset; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.ListConversationDatasetsRequest; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncListConversationDatasets { + + public static void main(String[] args) throws Exception { + syncListConversationDatasets(); + } + + public static void syncListConversationDatasets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + ListConversationDatasetsRequest request = + ListConversationDatasetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ConversationDataset element : + conversationDatasetsClient.listConversationDatasets(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_listconversationdatasets_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/SyncListConversationDatasetsLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/SyncListConversationDatasetsLocationname.java new file mode 100644 index 000000000000..44070c1f5cc4 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/SyncListConversationDatasetsLocationname.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationdatasetsclient_listconversationdatasets_locationname_sync] +import com.google.cloud.dialogflow.v2.ConversationDataset; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncListConversationDatasetsLocationname { + + public static void main(String[] args) throws Exception { + syncListConversationDatasetsLocationname(); + } + + public static void syncListConversationDatasetsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (ConversationDataset element : + conversationDatasetsClient.listConversationDatasets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// dialogflow_v2_generated_conversationdatasetsclient_listconversationdatasets_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/SyncListConversationDatasetsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/SyncListConversationDatasetsString.java new file mode 100644 index 000000000000..70d1d4b71aed --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetsclient/listconversationdatasets/SyncListConversationDatasetsString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsclient_listconversationdatasets_string_sync] +import com.google.cloud.dialogflow.v2.ConversationDataset; +import com.google.cloud.dialogflow.v2.ConversationDatasetsClient; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncListConversationDatasetsString { + + public static void main(String[] args) throws Exception { + syncListConversationDatasetsString(); + } + + public static void syncListConversationDatasetsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationDatasetsClient conversationDatasetsClient = + ConversationDatasetsClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (ConversationDataset element : + conversationDatasetsClient.listConversationDatasets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationdatasetsclient_listconversationdatasets_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetssettings/getconversationdataset/SyncGetConversationDataset.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetssettings/getconversationdataset/SyncGetConversationDataset.java new file mode 100644 index 000000000000..1a160f1ed0ac --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationdatasetssettings/getconversationdataset/SyncGetConversationDataset.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetssettings_getconversationdataset_sync] +import com.google.cloud.dialogflow.v2.ConversationDatasetsSettings; +import java.time.Duration; + +public class SyncGetConversationDataset { + + public static void main(String[] args) throws Exception { + syncGetConversationDataset(); + } + + public static void syncGetConversationDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationDatasetsSettings.Builder conversationDatasetsSettingsBuilder = + ConversationDatasetsSettings.newBuilder(); + conversationDatasetsSettingsBuilder + .getConversationDatasetSettings() + .setRetrySettings( + conversationDatasetsSettingsBuilder + .getConversationDatasetSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConversationDatasetsSettings conversationDatasetsSettings = + conversationDatasetsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_conversationdatasetssettings_getconversationdataset_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..0032d931dbaf --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.ConversationModelsSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationModelsSettings conversationModelsSettings = + ConversationModelsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ConversationModelsClient conversationModelsClient = + ConversationModelsClient.create(conversationModelsSettings); + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..475557234a82 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.ConversationModelsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationModelsSettings conversationModelsSettings = + ConversationModelsSettings.newBuilder() + .setTransportChannelProvider( + ConversationModelsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ConversationModelsClient conversationModelsClient = + ConversationModelsClient.create(conversationModelsSettings); + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..e95debb53d8c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.ConversationModelsSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationModelsSettings conversationModelsSettings = + ConversationModelsSettings.newBuilder().setEndpoint(myEndpoint).build(); + ConversationModelsClient conversationModelsClient = + ConversationModelsClient.create(conversationModelsSettings); + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/AsyncCreateConversationModel.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/AsyncCreateConversationModel.java new file mode 100644 index 000000000000..613384a42525 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/AsyncCreateConversationModel.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_createconversationmodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationModel; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.CreateConversationModelRequest; +import com.google.longrunning.Operation; + +public class AsyncCreateConversationModel { + + public static void main(String[] args) throws Exception { + asyncCreateConversationModel(); + } + + public static void asyncCreateConversationModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + CreateConversationModelRequest request = + CreateConversationModelRequest.newBuilder() + .setParent("parent-995424086") + .setConversationModel(ConversationModel.newBuilder().build()) + .build(); + ApiFuture future = + conversationModelsClient.createConversationModelCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_createconversationmodel_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/AsyncCreateConversationModelLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/AsyncCreateConversationModelLRO.java new file mode 100644 index 000000000000..220679a257f2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/AsyncCreateConversationModelLRO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_createconversationmodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.ConversationModel; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.CreateConversationModelOperationMetadata; +import com.google.cloud.dialogflow.v2.CreateConversationModelRequest; + +public class AsyncCreateConversationModelLRO { + + public static void main(String[] args) throws Exception { + asyncCreateConversationModelLRO(); + } + + public static void asyncCreateConversationModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + CreateConversationModelRequest request = + CreateConversationModelRequest.newBuilder() + .setParent("parent-995424086") + .setConversationModel(ConversationModel.newBuilder().build()) + .build(); + OperationFuture future = + conversationModelsClient.createConversationModelOperationCallable().futureCall(request); + // Do something. + ConversationModel response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_createconversationmodel_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/SyncCreateConversationModel.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/SyncCreateConversationModel.java new file mode 100644 index 000000000000..3c3e0be05061 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/SyncCreateConversationModel.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_createconversationmodel_sync] +import com.google.cloud.dialogflow.v2.ConversationModel; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.CreateConversationModelRequest; + +public class SyncCreateConversationModel { + + public static void main(String[] args) throws Exception { + syncCreateConversationModel(); + } + + public static void syncCreateConversationModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + CreateConversationModelRequest request = + CreateConversationModelRequest.newBuilder() + .setParent("parent-995424086") + .setConversationModel(ConversationModel.newBuilder().build()) + .build(); + ConversationModel response = + conversationModelsClient.createConversationModelAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_createconversationmodel_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/SyncCreateConversationModelStringConversationmodel.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/SyncCreateConversationModelStringConversationmodel.java new file mode 100644 index 000000000000..58f286238836 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodel/SyncCreateConversationModelStringConversationmodel.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationmodelsclient_createconversationmodel_stringconversationmodel_sync] +import com.google.cloud.dialogflow.v2.ConversationModel; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; + +public class SyncCreateConversationModelStringConversationmodel { + + public static void main(String[] args) throws Exception { + syncCreateConversationModelStringConversationmodel(); + } + + public static void syncCreateConversationModelStringConversationmodel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + String parent = "parent-995424086"; + ConversationModel conversationModel = ConversationModel.newBuilder().build(); + ConversationModel response = + conversationModelsClient.createConversationModelAsync(parent, conversationModel).get(); + } + } +} +// [END +// dialogflow_v2_generated_conversationmodelsclient_createconversationmodel_stringconversationmodel_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/AsyncCreateConversationModelEvaluation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/AsyncCreateConversationModelEvaluation.java new file mode 100644 index 000000000000..fd50a2bc67c3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/AsyncCreateConversationModelEvaluation.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_createconversationmodelevaluation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationModelEvaluation; +import com.google.cloud.dialogflow.v2.ConversationModelName; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.CreateConversationModelEvaluationRequest; +import com.google.longrunning.Operation; + +public class AsyncCreateConversationModelEvaluation { + + public static void main(String[] args) throws Exception { + asyncCreateConversationModelEvaluation(); + } + + public static void asyncCreateConversationModelEvaluation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + CreateConversationModelEvaluationRequest request = + CreateConversationModelEvaluationRequest.newBuilder() + .setParent( + ConversationModelName.ofProjectLocationConversationModelName( + "[PROJECT]", "[LOCATION]", "[CONVERSATION_MODEL]") + .toString()) + .setConversationModelEvaluation(ConversationModelEvaluation.newBuilder().build()) + .build(); + ApiFuture future = + conversationModelsClient.createConversationModelEvaluationCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_createconversationmodelevaluation_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/AsyncCreateConversationModelEvaluationLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/AsyncCreateConversationModelEvaluationLRO.java new file mode 100644 index 000000000000..280fa65802cb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/AsyncCreateConversationModelEvaluationLRO.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationmodelsclient_createconversationmodelevaluation_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.ConversationModelEvaluation; +import com.google.cloud.dialogflow.v2.ConversationModelName; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.CreateConversationModelEvaluationOperationMetadata; +import com.google.cloud.dialogflow.v2.CreateConversationModelEvaluationRequest; + +public class AsyncCreateConversationModelEvaluationLRO { + + public static void main(String[] args) throws Exception { + asyncCreateConversationModelEvaluationLRO(); + } + + public static void asyncCreateConversationModelEvaluationLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + CreateConversationModelEvaluationRequest request = + CreateConversationModelEvaluationRequest.newBuilder() + .setParent( + ConversationModelName.ofProjectLocationConversationModelName( + "[PROJECT]", "[LOCATION]", "[CONVERSATION_MODEL]") + .toString()) + .setConversationModelEvaluation(ConversationModelEvaluation.newBuilder().build()) + .build(); + OperationFuture< + ConversationModelEvaluation, CreateConversationModelEvaluationOperationMetadata> + future = + conversationModelsClient + .createConversationModelEvaluationOperationCallable() + .futureCall(request); + // Do something. + ConversationModelEvaluation response = future.get(); + } + } +} +// [END +// dialogflow_v2_generated_conversationmodelsclient_createconversationmodelevaluation_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/SyncCreateConversationModelEvaluation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/SyncCreateConversationModelEvaluation.java new file mode 100644 index 000000000000..9c8971c1ec4b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/SyncCreateConversationModelEvaluation.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_createconversationmodelevaluation_sync] +import com.google.cloud.dialogflow.v2.ConversationModelEvaluation; +import com.google.cloud.dialogflow.v2.ConversationModelName; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.CreateConversationModelEvaluationRequest; + +public class SyncCreateConversationModelEvaluation { + + public static void main(String[] args) throws Exception { + syncCreateConversationModelEvaluation(); + } + + public static void syncCreateConversationModelEvaluation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + CreateConversationModelEvaluationRequest request = + CreateConversationModelEvaluationRequest.newBuilder() + .setParent( + ConversationModelName.ofProjectLocationConversationModelName( + "[PROJECT]", "[LOCATION]", "[CONVERSATION_MODEL]") + .toString()) + .setConversationModelEvaluation(ConversationModelEvaluation.newBuilder().build()) + .build(); + ConversationModelEvaluation response = + conversationModelsClient.createConversationModelEvaluationAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_createconversationmodelevaluation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/SyncCreateConversationModelEvaluationConversationmodelnameConversationmodelevaluation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/SyncCreateConversationModelEvaluationConversationmodelnameConversationmodelevaluation.java new file mode 100644 index 000000000000..5a2b7f70503a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/SyncCreateConversationModelEvaluationConversationmodelnameConversationmodelevaluation.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationmodelsclient_createconversationmodelevaluation_conversationmodelnameconversationmodelevaluation_sync] +import com.google.cloud.dialogflow.v2.ConversationModelEvaluation; +import com.google.cloud.dialogflow.v2.ConversationModelName; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; + +public class SyncCreateConversationModelEvaluationConversationmodelnameConversationmodelevaluation { + + public static void main(String[] args) throws Exception { + syncCreateConversationModelEvaluationConversationmodelnameConversationmodelevaluation(); + } + + public static void + syncCreateConversationModelEvaluationConversationmodelnameConversationmodelevaluation() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + ConversationModelName parent = + ConversationModelName.ofProjectLocationConversationModelName( + "[PROJECT]", "[LOCATION]", "[CONVERSATION_MODEL]"); + ConversationModelEvaluation conversationModelEvaluation = + ConversationModelEvaluation.newBuilder().build(); + ConversationModelEvaluation response = + conversationModelsClient + .createConversationModelEvaluationAsync(parent, conversationModelEvaluation) + .get(); + } + } +} +// [END +// dialogflow_v2_generated_conversationmodelsclient_createconversationmodelevaluation_conversationmodelnameconversationmodelevaluation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/SyncCreateConversationModelEvaluationStringConversationmodelevaluation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/SyncCreateConversationModelEvaluationStringConversationmodelevaluation.java new file mode 100644 index 000000000000..eacac86bb7e6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/createconversationmodelevaluation/SyncCreateConversationModelEvaluationStringConversationmodelevaluation.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationmodelsclient_createconversationmodelevaluation_stringconversationmodelevaluation_sync] +import com.google.cloud.dialogflow.v2.ConversationModelEvaluation; +import com.google.cloud.dialogflow.v2.ConversationModelName; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; + +public class SyncCreateConversationModelEvaluationStringConversationmodelevaluation { + + public static void main(String[] args) throws Exception { + syncCreateConversationModelEvaluationStringConversationmodelevaluation(); + } + + public static void syncCreateConversationModelEvaluationStringConversationmodelevaluation() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + String parent = + ConversationModelName.ofProjectLocationConversationModelName( + "[PROJECT]", "[LOCATION]", "[CONVERSATION_MODEL]") + .toString(); + ConversationModelEvaluation conversationModelEvaluation = + ConversationModelEvaluation.newBuilder().build(); + ConversationModelEvaluation response = + conversationModelsClient + .createConversationModelEvaluationAsync(parent, conversationModelEvaluation) + .get(); + } + } +} +// [END +// dialogflow_v2_generated_conversationmodelsclient_createconversationmodelevaluation_stringconversationmodelevaluation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/AsyncDeleteConversationModel.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/AsyncDeleteConversationModel.java new file mode 100644 index 000000000000..0cc8af557e75 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/AsyncDeleteConversationModel.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_deleteconversationmodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.DeleteConversationModelRequest; +import com.google.longrunning.Operation; + +public class AsyncDeleteConversationModel { + + public static void main(String[] args) throws Exception { + asyncDeleteConversationModel(); + } + + public static void asyncDeleteConversationModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + DeleteConversationModelRequest request = + DeleteConversationModelRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + conversationModelsClient.deleteConversationModelCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_deleteconversationmodel_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/AsyncDeleteConversationModelLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/AsyncDeleteConversationModelLRO.java new file mode 100644 index 000000000000..b01c70cd5e03 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/AsyncDeleteConversationModelLRO.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_deleteconversationmodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.DeleteConversationModelOperationMetadata; +import com.google.cloud.dialogflow.v2.DeleteConversationModelRequest; +import com.google.protobuf.Empty; + +public class AsyncDeleteConversationModelLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteConversationModelLRO(); + } + + public static void asyncDeleteConversationModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + DeleteConversationModelRequest request = + DeleteConversationModelRequest.newBuilder().setName("name3373707").build(); + OperationFuture future = + conversationModelsClient.deleteConversationModelOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_deleteconversationmodel_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/SyncDeleteConversationModel.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/SyncDeleteConversationModel.java new file mode 100644 index 000000000000..f0b4a6637c77 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/SyncDeleteConversationModel.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_deleteconversationmodel_sync] +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.DeleteConversationModelRequest; + +public class SyncDeleteConversationModel { + + public static void main(String[] args) throws Exception { + syncDeleteConversationModel(); + } + + public static void syncDeleteConversationModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + DeleteConversationModelRequest request = + DeleteConversationModelRequest.newBuilder().setName("name3373707").build(); + conversationModelsClient.deleteConversationModelAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_deleteconversationmodel_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/SyncDeleteConversationModelString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/SyncDeleteConversationModelString.java new file mode 100644 index 000000000000..10575a668d27 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deleteconversationmodel/SyncDeleteConversationModelString.java @@ -0,0 +1,37 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_deleteconversationmodel_string_sync] +import com.google.cloud.dialogflow.v2.ConversationModelsClient; + +public class SyncDeleteConversationModelString { + + public static void main(String[] args) throws Exception { + syncDeleteConversationModelString(); + } + + public static void syncDeleteConversationModelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + String name = "name3373707"; + conversationModelsClient.deleteConversationModelAsync(name).get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_deleteconversationmodel_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deployconversationmodel/AsyncDeployConversationModel.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deployconversationmodel/AsyncDeployConversationModel.java new file mode 100644 index 000000000000..b530226ff5b8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deployconversationmodel/AsyncDeployConversationModel.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_deployconversationmodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.DeployConversationModelRequest; +import com.google.longrunning.Operation; + +public class AsyncDeployConversationModel { + + public static void main(String[] args) throws Exception { + asyncDeployConversationModel(); + } + + public static void asyncDeployConversationModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + DeployConversationModelRequest request = + DeployConversationModelRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + conversationModelsClient.deployConversationModelCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_deployconversationmodel_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deployconversationmodel/AsyncDeployConversationModelLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deployconversationmodel/AsyncDeployConversationModelLRO.java new file mode 100644 index 000000000000..0920ffc074d8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deployconversationmodel/AsyncDeployConversationModelLRO.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_deployconversationmodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.DeployConversationModelOperationMetadata; +import com.google.cloud.dialogflow.v2.DeployConversationModelRequest; +import com.google.protobuf.Empty; + +public class AsyncDeployConversationModelLRO { + + public static void main(String[] args) throws Exception { + asyncDeployConversationModelLRO(); + } + + public static void asyncDeployConversationModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + DeployConversationModelRequest request = + DeployConversationModelRequest.newBuilder().setName("name3373707").build(); + OperationFuture future = + conversationModelsClient.deployConversationModelOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_deployconversationmodel_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deployconversationmodel/SyncDeployConversationModel.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deployconversationmodel/SyncDeployConversationModel.java new file mode 100644 index 000000000000..5f4154e157b7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/deployconversationmodel/SyncDeployConversationModel.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_deployconversationmodel_sync] +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.DeployConversationModelRequest; + +public class SyncDeployConversationModel { + + public static void main(String[] args) throws Exception { + syncDeployConversationModel(); + } + + public static void syncDeployConversationModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + DeployConversationModelRequest request = + DeployConversationModelRequest.newBuilder().setName("name3373707").build(); + conversationModelsClient.deployConversationModelAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_deployconversationmodel_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodel/AsyncGetConversationModel.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodel/AsyncGetConversationModel.java new file mode 100644 index 000000000000..82dd494d78d6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodel/AsyncGetConversationModel.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_getconversationmodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationModel; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.GetConversationModelRequest; + +public class AsyncGetConversationModel { + + public static void main(String[] args) throws Exception { + asyncGetConversationModel(); + } + + public static void asyncGetConversationModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + GetConversationModelRequest request = + GetConversationModelRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + conversationModelsClient.getConversationModelCallable().futureCall(request); + // Do something. + ConversationModel response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_getconversationmodel_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodel/SyncGetConversationModel.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodel/SyncGetConversationModel.java new file mode 100644 index 000000000000..e816573e2bd0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodel/SyncGetConversationModel.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_getconversationmodel_sync] +import com.google.cloud.dialogflow.v2.ConversationModel; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.GetConversationModelRequest; + +public class SyncGetConversationModel { + + public static void main(String[] args) throws Exception { + syncGetConversationModel(); + } + + public static void syncGetConversationModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + GetConversationModelRequest request = + GetConversationModelRequest.newBuilder().setName("name3373707").build(); + ConversationModel response = conversationModelsClient.getConversationModel(request); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_getconversationmodel_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodel/SyncGetConversationModelString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodel/SyncGetConversationModelString.java new file mode 100644 index 000000000000..d2b1e7fc5190 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodel/SyncGetConversationModelString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_getconversationmodel_string_sync] +import com.google.cloud.dialogflow.v2.ConversationModel; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; + +public class SyncGetConversationModelString { + + public static void main(String[] args) throws Exception { + syncGetConversationModelString(); + } + + public static void syncGetConversationModelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + String name = "name3373707"; + ConversationModel response = conversationModelsClient.getConversationModel(name); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_getconversationmodel_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodelevaluation/AsyncGetConversationModelEvaluation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodelevaluation/AsyncGetConversationModelEvaluation.java new file mode 100644 index 000000000000..2eff4e41a7ca --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodelevaluation/AsyncGetConversationModelEvaluation.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_getconversationmodelevaluation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationModelEvaluation; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.GetConversationModelEvaluationRequest; + +public class AsyncGetConversationModelEvaluation { + + public static void main(String[] args) throws Exception { + asyncGetConversationModelEvaluation(); + } + + public static void asyncGetConversationModelEvaluation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + GetConversationModelEvaluationRequest request = + GetConversationModelEvaluationRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + conversationModelsClient.getConversationModelEvaluationCallable().futureCall(request); + // Do something. + ConversationModelEvaluation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_getconversationmodelevaluation_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodelevaluation/SyncGetConversationModelEvaluation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodelevaluation/SyncGetConversationModelEvaluation.java new file mode 100644 index 000000000000..3eb4d4770992 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodelevaluation/SyncGetConversationModelEvaluation.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_getconversationmodelevaluation_sync] +import com.google.cloud.dialogflow.v2.ConversationModelEvaluation; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.GetConversationModelEvaluationRequest; + +public class SyncGetConversationModelEvaluation { + + public static void main(String[] args) throws Exception { + syncGetConversationModelEvaluation(); + } + + public static void syncGetConversationModelEvaluation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + GetConversationModelEvaluationRequest request = + GetConversationModelEvaluationRequest.newBuilder().setName("name3373707").build(); + ConversationModelEvaluation response = + conversationModelsClient.getConversationModelEvaluation(request); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_getconversationmodelevaluation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodelevaluation/SyncGetConversationModelEvaluationString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodelevaluation/SyncGetConversationModelEvaluationString.java new file mode 100644 index 000000000000..89b8a8374203 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/getconversationmodelevaluation/SyncGetConversationModelEvaluationString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationmodelsclient_getconversationmodelevaluation_string_sync] +import com.google.cloud.dialogflow.v2.ConversationModelEvaluation; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; + +public class SyncGetConversationModelEvaluationString { + + public static void main(String[] args) throws Exception { + syncGetConversationModelEvaluationString(); + } + + public static void syncGetConversationModelEvaluationString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + String name = "name3373707"; + ConversationModelEvaluation response = + conversationModelsClient.getConversationModelEvaluation(name); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_getconversationmodelevaluation_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/AsyncListConversationModelEvaluations.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/AsyncListConversationModelEvaluations.java new file mode 100644 index 000000000000..931a431bae92 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/AsyncListConversationModelEvaluations.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_listconversationmodelevaluations_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationModelEvaluation; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.ListConversationModelEvaluationsRequest; + +public class AsyncListConversationModelEvaluations { + + public static void main(String[] args) throws Exception { + asyncListConversationModelEvaluations(); + } + + public static void asyncListConversationModelEvaluations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + ListConversationModelEvaluationsRequest request = + ListConversationModelEvaluationsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + conversationModelsClient + .listConversationModelEvaluationsPagedCallable() + .futureCall(request); + // Do something. + for (ConversationModelEvaluation element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_listconversationmodelevaluations_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/AsyncListConversationModelEvaluationsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/AsyncListConversationModelEvaluationsPaged.java new file mode 100644 index 000000000000..ab594502f403 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/AsyncListConversationModelEvaluationsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationmodelsclient_listconversationmodelevaluations_paged_async] +import com.google.cloud.dialogflow.v2.ConversationModelEvaluation; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.ListConversationModelEvaluationsRequest; +import com.google.cloud.dialogflow.v2.ListConversationModelEvaluationsResponse; +import com.google.common.base.Strings; + +public class AsyncListConversationModelEvaluationsPaged { + + public static void main(String[] args) throws Exception { + asyncListConversationModelEvaluationsPaged(); + } + + public static void asyncListConversationModelEvaluationsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + ListConversationModelEvaluationsRequest request = + ListConversationModelEvaluationsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListConversationModelEvaluationsResponse response = + conversationModelsClient.listConversationModelEvaluationsCallable().call(request); + for (ConversationModelEvaluation element : response.getConversationModelEvaluationsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END +// dialogflow_v2_generated_conversationmodelsclient_listconversationmodelevaluations_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/SyncListConversationModelEvaluations.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/SyncListConversationModelEvaluations.java new file mode 100644 index 000000000000..1114468cf385 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/SyncListConversationModelEvaluations.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_listconversationmodelevaluations_sync] +import com.google.cloud.dialogflow.v2.ConversationModelEvaluation; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.ListConversationModelEvaluationsRequest; + +public class SyncListConversationModelEvaluations { + + public static void main(String[] args) throws Exception { + syncListConversationModelEvaluations(); + } + + public static void syncListConversationModelEvaluations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + ListConversationModelEvaluationsRequest request = + ListConversationModelEvaluationsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ConversationModelEvaluation element : + conversationModelsClient.listConversationModelEvaluations(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_listconversationmodelevaluations_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/SyncListConversationModelEvaluationsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/SyncListConversationModelEvaluationsString.java new file mode 100644 index 000000000000..bea81f95baaa --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodelevaluations/SyncListConversationModelEvaluationsString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationmodelsclient_listconversationmodelevaluations_string_sync] +import com.google.cloud.dialogflow.v2.ConversationModelEvaluation; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; + +public class SyncListConversationModelEvaluationsString { + + public static void main(String[] args) throws Exception { + syncListConversationModelEvaluationsString(); + } + + public static void syncListConversationModelEvaluationsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + String parent = "parent-995424086"; + for (ConversationModelEvaluation element : + conversationModelsClient.listConversationModelEvaluations(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// dialogflow_v2_generated_conversationmodelsclient_listconversationmodelevaluations_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/AsyncListConversationModels.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/AsyncListConversationModels.java new file mode 100644 index 000000000000..bf3139bf1335 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/AsyncListConversationModels.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_listconversationmodels_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationModel; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.ListConversationModelsRequest; + +public class AsyncListConversationModels { + + public static void main(String[] args) throws Exception { + asyncListConversationModels(); + } + + public static void asyncListConversationModels() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + ListConversationModelsRequest request = + ListConversationModelsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + conversationModelsClient.listConversationModelsPagedCallable().futureCall(request); + // Do something. + for (ConversationModel element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_listconversationmodels_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/AsyncListConversationModelsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/AsyncListConversationModelsPaged.java new file mode 100644 index 000000000000..89baec7d3e3f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/AsyncListConversationModelsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_listconversationmodels_paged_async] +import com.google.cloud.dialogflow.v2.ConversationModel; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.ListConversationModelsRequest; +import com.google.cloud.dialogflow.v2.ListConversationModelsResponse; +import com.google.common.base.Strings; + +public class AsyncListConversationModelsPaged { + + public static void main(String[] args) throws Exception { + asyncListConversationModelsPaged(); + } + + public static void asyncListConversationModelsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + ListConversationModelsRequest request = + ListConversationModelsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListConversationModelsResponse response = + conversationModelsClient.listConversationModelsCallable().call(request); + for (ConversationModel element : response.getConversationModelsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_listconversationmodels_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/SyncListConversationModels.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/SyncListConversationModels.java new file mode 100644 index 000000000000..e33711b328fd --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/SyncListConversationModels.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_listconversationmodels_sync] +import com.google.cloud.dialogflow.v2.ConversationModel; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.ListConversationModelsRequest; + +public class SyncListConversationModels { + + public static void main(String[] args) throws Exception { + syncListConversationModels(); + } + + public static void syncListConversationModels() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + ListConversationModelsRequest request = + ListConversationModelsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ConversationModel element : + conversationModelsClient.listConversationModels(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_listconversationmodels_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/SyncListConversationModelsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/SyncListConversationModelsString.java new file mode 100644 index 000000000000..cbd6959efadf --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/listconversationmodels/SyncListConversationModelsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_listconversationmodels_string_sync] +import com.google.cloud.dialogflow.v2.ConversationModel; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; + +public class SyncListConversationModelsString { + + public static void main(String[] args) throws Exception { + syncListConversationModelsString(); + } + + public static void syncListConversationModelsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + String parent = "parent-995424086"; + for (ConversationModel element : + conversationModelsClient.listConversationModels(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_listconversationmodels_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/undeployconversationmodel/AsyncUndeployConversationModel.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/undeployconversationmodel/AsyncUndeployConversationModel.java new file mode 100644 index 000000000000..18a915b70b04 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/undeployconversationmodel/AsyncUndeployConversationModel.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_undeployconversationmodel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.UndeployConversationModelRequest; +import com.google.longrunning.Operation; + +public class AsyncUndeployConversationModel { + + public static void main(String[] args) throws Exception { + asyncUndeployConversationModel(); + } + + public static void asyncUndeployConversationModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + UndeployConversationModelRequest request = + UndeployConversationModelRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + conversationModelsClient.undeployConversationModelCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_undeployconversationmodel_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/undeployconversationmodel/AsyncUndeployConversationModelLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/undeployconversationmodel/AsyncUndeployConversationModelLRO.java new file mode 100644 index 000000000000..59ebd797b36b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/undeployconversationmodel/AsyncUndeployConversationModelLRO.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_undeployconversationmodel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.UndeployConversationModelOperationMetadata; +import com.google.cloud.dialogflow.v2.UndeployConversationModelRequest; +import com.google.protobuf.Empty; + +public class AsyncUndeployConversationModelLRO { + + public static void main(String[] args) throws Exception { + asyncUndeployConversationModelLRO(); + } + + public static void asyncUndeployConversationModelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + UndeployConversationModelRequest request = + UndeployConversationModelRequest.newBuilder().setName("name3373707").build(); + OperationFuture future = + conversationModelsClient.undeployConversationModelOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_undeployconversationmodel_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/undeployconversationmodel/SyncUndeployConversationModel.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/undeployconversationmodel/SyncUndeployConversationModel.java new file mode 100644 index 000000000000..7532ff6d1b13 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelsclient/undeployconversationmodel/SyncUndeployConversationModel.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsclient_undeployconversationmodel_sync] +import com.google.cloud.dialogflow.v2.ConversationModelsClient; +import com.google.cloud.dialogflow.v2.UndeployConversationModelRequest; + +public class SyncUndeployConversationModel { + + public static void main(String[] args) throws Exception { + syncUndeployConversationModel(); + } + + public static void syncUndeployConversationModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationModelsClient conversationModelsClient = ConversationModelsClient.create()) { + UndeployConversationModelRequest request = + UndeployConversationModelRequest.newBuilder().setName("name3373707").build(); + conversationModelsClient.undeployConversationModelAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_conversationmodelsclient_undeployconversationmodel_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelssettings/getconversationmodel/SyncGetConversationModel.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelssettings/getconversationmodel/SyncGetConversationModel.java new file mode 100644 index 000000000000..41b70b329e43 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationmodelssettings/getconversationmodel/SyncGetConversationModel.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelssettings_getconversationmodel_sync] +import com.google.cloud.dialogflow.v2.ConversationModelsSettings; +import java.time.Duration; + +public class SyncGetConversationModel { + + public static void main(String[] args) throws Exception { + syncGetConversationModel(); + } + + public static void syncGetConversationModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationModelsSettings.Builder conversationModelsSettingsBuilder = + ConversationModelsSettings.newBuilder(); + conversationModelsSettingsBuilder + .getConversationModelSettings() + .setRetrySettings( + conversationModelsSettingsBuilder + .getConversationModelSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConversationModelsSettings conversationModelsSettings = + conversationModelsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_conversationmodelssettings_getconversationmodel_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfig.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfig.java new file mode 100644 index 000000000000..858d48ae3e85 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_clearsuggestionfeatureconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ClearSuggestionFeatureConfigRequest; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.longrunning.Operation; + +public class AsyncClearSuggestionFeatureConfig { + + public static void main(String[] args) throws Exception { + asyncClearSuggestionFeatureConfig(); + } + + public static void asyncClearSuggestionFeatureConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ClearSuggestionFeatureConfigRequest request = + ClearSuggestionFeatureConfigRequest.newBuilder() + .setConversationProfile("conversationProfile1691597734") + .build(); + ApiFuture future = + conversationProfilesClient.clearSuggestionFeatureConfigCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_clearsuggestionfeatureconfig_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfigLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfigLRO.java new file mode 100644 index 000000000000..27b8a9306cf0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfigLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_clearsuggestionfeatureconfig_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.ClearSuggestionFeatureConfigOperationMetadata; +import com.google.cloud.dialogflow.v2.ClearSuggestionFeatureConfigRequest; +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; + +public class AsyncClearSuggestionFeatureConfigLRO { + + public static void main(String[] args) throws Exception { + asyncClearSuggestionFeatureConfigLRO(); + } + + public static void asyncClearSuggestionFeatureConfigLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ClearSuggestionFeatureConfigRequest request = + ClearSuggestionFeatureConfigRequest.newBuilder() + .setConversationProfile("conversationProfile1691597734") + .build(); + OperationFuture future = + conversationProfilesClient + .clearSuggestionFeatureConfigOperationCallable() + .futureCall(request); + // Do something. + ConversationProfile response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_clearsuggestionfeatureconfig_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfig.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfig.java new file mode 100644 index 000000000000..bf50290be033 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_clearsuggestionfeatureconfig_sync] +import com.google.cloud.dialogflow.v2.ClearSuggestionFeatureConfigRequest; +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; + +public class SyncClearSuggestionFeatureConfig { + + public static void main(String[] args) throws Exception { + syncClearSuggestionFeatureConfig(); + } + + public static void syncClearSuggestionFeatureConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ClearSuggestionFeatureConfigRequest request = + ClearSuggestionFeatureConfigRequest.newBuilder() + .setConversationProfile("conversationProfile1691597734") + .build(); + ConversationProfile response = + conversationProfilesClient.clearSuggestionFeatureConfigAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_clearsuggestionfeatureconfig_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfigString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfigString.java new file mode 100644 index 000000000000..28db13461fa1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfigString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationprofilesclient_clearsuggestionfeatureconfig_string_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; + +public class SyncClearSuggestionFeatureConfigString { + + public static void main(String[] args) throws Exception { + syncClearSuggestionFeatureConfigString(); + } + + public static void syncClearSuggestionFeatureConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + String conversationProfile = "conversationProfile1691597734"; + ConversationProfile response = + conversationProfilesClient.clearSuggestionFeatureConfigAsync(conversationProfile).get(); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_clearsuggestionfeatureconfig_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..e08f536c8a7a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.ConversationProfilesSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationProfilesSettings conversationProfilesSettings = + ConversationProfilesSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create(conversationProfilesSettings); + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..f77d3e5d8358 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.ConversationProfilesSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationProfilesSettings conversationProfilesSettings = + ConversationProfilesSettings.newBuilder() + .setTransportChannelProvider( + ConversationProfilesSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create(conversationProfilesSettings); + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..ac1bf372c91d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.ConversationProfilesSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationProfilesSettings conversationProfilesSettings = + ConversationProfilesSettings.newBuilder().setEndpoint(myEndpoint).build(); + ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create(conversationProfilesSettings); + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/AsyncCreateConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/AsyncCreateConversationProfile.java new file mode 100644 index 000000000000..5cad9dc81083 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/AsyncCreateConversationProfile.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_createconversationprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.CreateConversationProfileRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class AsyncCreateConversationProfile { + + public static void main(String[] args) throws Exception { + asyncCreateConversationProfile(); + } + + public static void asyncCreateConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + CreateConversationProfileRequest request = + CreateConversationProfileRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setConversationProfile(ConversationProfile.newBuilder().build()) + .build(); + ApiFuture future = + conversationProfilesClient.createConversationProfileCallable().futureCall(request); + // Do something. + ConversationProfile response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_createconversationprofile_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfile.java new file mode 100644 index 000000000000..c01c9dd39fce --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfile.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_createconversationprofile_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.CreateConversationProfileRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncCreateConversationProfile { + + public static void main(String[] args) throws Exception { + syncCreateConversationProfile(); + } + + public static void syncCreateConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + CreateConversationProfileRequest request = + CreateConversationProfileRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setConversationProfile(ConversationProfile.newBuilder().build()) + .build(); + ConversationProfile response = conversationProfilesClient.createConversationProfile(request); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_createconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileLocationnameConversationprofile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileLocationnameConversationprofile.java new file mode 100644 index 000000000000..1cf125521b07 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileLocationnameConversationprofile.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationprofilesclient_createconversationprofile_locationnameconversationprofile_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncCreateConversationProfileLocationnameConversationprofile { + + public static void main(String[] args) throws Exception { + syncCreateConversationProfileLocationnameConversationprofile(); + } + + public static void syncCreateConversationProfileLocationnameConversationprofile() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + ConversationProfile response = + conversationProfilesClient.createConversationProfile(parent, conversationProfile); + } + } +} +// [END +// dialogflow_v2_generated_conversationprofilesclient_createconversationprofile_locationnameconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileProjectnameConversationprofile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileProjectnameConversationprofile.java new file mode 100644 index 000000000000..df15c38a44f7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileProjectnameConversationprofile.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationprofilesclient_createconversationprofile_projectnameconversationprofile_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncCreateConversationProfileProjectnameConversationprofile { + + public static void main(String[] args) throws Exception { + syncCreateConversationProfileProjectnameConversationprofile(); + } + + public static void syncCreateConversationProfileProjectnameConversationprofile() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + ConversationProfile response = + conversationProfilesClient.createConversationProfile(parent, conversationProfile); + } + } +} +// [END +// dialogflow_v2_generated_conversationprofilesclient_createconversationprofile_projectnameconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileStringConversationprofile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileStringConversationprofile.java new file mode 100644 index 000000000000..424308dad510 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileStringConversationprofile.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationprofilesclient_createconversationprofile_stringconversationprofile_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncCreateConversationProfileStringConversationprofile { + + public static void main(String[] args) throws Exception { + syncCreateConversationProfileStringConversationprofile(); + } + + public static void syncCreateConversationProfileStringConversationprofile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + ConversationProfile response = + conversationProfilesClient.createConversationProfile(parent, conversationProfile); + } + } +} +// [END +// dialogflow_v2_generated_conversationprofilesclient_createconversationprofile_stringconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/AsyncDeleteConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/AsyncDeleteConversationProfile.java new file mode 100644 index 000000000000..0d710960763c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/AsyncDeleteConversationProfile.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_deleteconversationprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationProfileName; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.DeleteConversationProfileRequest; +import com.google.protobuf.Empty; + +public class AsyncDeleteConversationProfile { + + public static void main(String[] args) throws Exception { + asyncDeleteConversationProfile(); + } + + public static void asyncDeleteConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + DeleteConversationProfileRequest request = + DeleteConversationProfileRequest.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .build(); + ApiFuture future = + conversationProfilesClient.deleteConversationProfileCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_deleteconversationprofile_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfile.java new file mode 100644 index 000000000000..1a08773b1a07 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfile.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_deleteconversationprofile_sync] +import com.google.cloud.dialogflow.v2.ConversationProfileName; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.DeleteConversationProfileRequest; + +public class SyncDeleteConversationProfile { + + public static void main(String[] args) throws Exception { + syncDeleteConversationProfile(); + } + + public static void syncDeleteConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + DeleteConversationProfileRequest request = + DeleteConversationProfileRequest.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .build(); + conversationProfilesClient.deleteConversationProfile(request); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_deleteconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileConversationprofilename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileConversationprofilename.java new file mode 100644 index 000000000000..9ed1b4fc0537 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileConversationprofilename.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationprofilesclient_deleteconversationprofile_conversationprofilename_sync] +import com.google.cloud.dialogflow.v2.ConversationProfileName; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; + +public class SyncDeleteConversationProfileConversationprofilename { + + public static void main(String[] args) throws Exception { + syncDeleteConversationProfileConversationprofilename(); + } + + public static void syncDeleteConversationProfileConversationprofilename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ConversationProfileName name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]"); + conversationProfilesClient.deleteConversationProfile(name); + } + } +} +// [END +// dialogflow_v2_generated_conversationprofilesclient_deleteconversationprofile_conversationprofilename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileString.java new file mode 100644 index 000000000000..78c443042610 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_deleteconversationprofile_string_sync] +import com.google.cloud.dialogflow.v2.ConversationProfileName; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; + +public class SyncDeleteConversationProfileString { + + public static void main(String[] args) throws Exception { + syncDeleteConversationProfileString(); + } + + public static void syncDeleteConversationProfileString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + String name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString(); + conversationProfilesClient.deleteConversationProfile(name); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_deleteconversationprofile_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/AsyncGetConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/AsyncGetConversationProfile.java new file mode 100644 index 000000000000..1bf06da5efcf --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/AsyncGetConversationProfile.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_getconversationprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfileName; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.GetConversationProfileRequest; + +public class AsyncGetConversationProfile { + + public static void main(String[] args) throws Exception { + asyncGetConversationProfile(); + } + + public static void asyncGetConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + GetConversationProfileRequest request = + GetConversationProfileRequest.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .build(); + ApiFuture future = + conversationProfilesClient.getConversationProfileCallable().futureCall(request); + // Do something. + ConversationProfile response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_getconversationprofile_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/SyncGetConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/SyncGetConversationProfile.java new file mode 100644 index 000000000000..4545e1670497 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/SyncGetConversationProfile.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_getconversationprofile_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfileName; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.GetConversationProfileRequest; + +public class SyncGetConversationProfile { + + public static void main(String[] args) throws Exception { + syncGetConversationProfile(); + } + + public static void syncGetConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + GetConversationProfileRequest request = + GetConversationProfileRequest.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .build(); + ConversationProfile response = conversationProfilesClient.getConversationProfile(request); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_getconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileConversationprofilename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileConversationprofilename.java new file mode 100644 index 000000000000..659dcacbd41d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileConversationprofilename.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationprofilesclient_getconversationprofile_conversationprofilename_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfileName; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; + +public class SyncGetConversationProfileConversationprofilename { + + public static void main(String[] args) throws Exception { + syncGetConversationProfileConversationprofilename(); + } + + public static void syncGetConversationProfileConversationprofilename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ConversationProfileName name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]"); + ConversationProfile response = conversationProfilesClient.getConversationProfile(name); + } + } +} +// [END +// dialogflow_v2_generated_conversationprofilesclient_getconversationprofile_conversationprofilename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileString.java new file mode 100644 index 000000000000..a83674b3df95 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_getconversationprofile_string_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfileName; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; + +public class SyncGetConversationProfileString { + + public static void main(String[] args) throws Exception { + syncGetConversationProfileString(); + } + + public static void syncGetConversationProfileString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + String name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString(); + ConversationProfile response = conversationProfilesClient.getConversationProfile(name); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_getconversationprofile_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfiles.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfiles.java new file mode 100644 index 000000000000..5be5c6babe62 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfiles.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_listconversationprofiles_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.ListConversationProfilesRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class AsyncListConversationProfiles { + + public static void main(String[] args) throws Exception { + asyncListConversationProfiles(); + } + + public static void asyncListConversationProfiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ListConversationProfilesRequest request = + ListConversationProfilesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + conversationProfilesClient.listConversationProfilesPagedCallable().futureCall(request); + // Do something. + for (ConversationProfile element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_listconversationprofiles_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfilesPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfilesPaged.java new file mode 100644 index 000000000000..313ccdd0453c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfilesPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_listconversationprofiles_paged_async] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.ListConversationProfilesRequest; +import com.google.cloud.dialogflow.v2.ListConversationProfilesResponse; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListConversationProfilesPaged { + + public static void main(String[] args) throws Exception { + asyncListConversationProfilesPaged(); + } + + public static void asyncListConversationProfilesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ListConversationProfilesRequest request = + ListConversationProfilesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListConversationProfilesResponse response = + conversationProfilesClient.listConversationProfilesCallable().call(request); + for (ConversationProfile element : response.getConversationProfilesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_listconversationprofiles_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfiles.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfiles.java new file mode 100644 index 000000000000..59cb80587d31 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfiles.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_listconversationprofiles_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.ListConversationProfilesRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncListConversationProfiles { + + public static void main(String[] args) throws Exception { + syncListConversationProfiles(); + } + + public static void syncListConversationProfiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ListConversationProfilesRequest request = + ListConversationProfilesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ConversationProfile element : + conversationProfilesClient.listConversationProfiles(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_listconversationprofiles_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesLocationname.java new file mode 100644 index 000000000000..de967ade97d2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesLocationname.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationprofilesclient_listconversationprofiles_locationname_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncListConversationProfilesLocationname { + + public static void main(String[] args) throws Exception { + syncListConversationProfilesLocationname(); + } + + public static void syncListConversationProfilesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (ConversationProfile element : + conversationProfilesClient.listConversationProfiles(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// dialogflow_v2_generated_conversationprofilesclient_listconversationprofiles_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesProjectname.java new file mode 100644 index 000000000000..4876ca481827 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesProjectname.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationprofilesclient_listconversationprofiles_projectname_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncListConversationProfilesProjectname { + + public static void main(String[] args) throws Exception { + syncListConversationProfilesProjectname(); + } + + public static void syncListConversationProfilesProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (ConversationProfile element : + conversationProfilesClient.listConversationProfiles(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// dialogflow_v2_generated_conversationprofilesclient_listconversationprofiles_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesString.java new file mode 100644 index 000000000000..a81773317d75 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_listconversationprofiles_string_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncListConversationProfilesString { + + public static void main(String[] args) throws Exception { + syncListConversationProfilesString(); + } + + public static void syncListConversationProfilesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (ConversationProfile element : + conversationProfilesClient.listConversationProfiles(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_listconversationprofiles_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfig.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfig.java new file mode 100644 index 000000000000..fb1e6b350b4d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfig.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_setsuggestionfeatureconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.HumanAgentAssistantConfig; +import com.google.cloud.dialogflow.v2.SetSuggestionFeatureConfigRequest; +import com.google.longrunning.Operation; + +public class AsyncSetSuggestionFeatureConfig { + + public static void main(String[] args) throws Exception { + asyncSetSuggestionFeatureConfig(); + } + + public static void asyncSetSuggestionFeatureConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + SetSuggestionFeatureConfigRequest request = + SetSuggestionFeatureConfigRequest.newBuilder() + .setConversationProfile("conversationProfile1691597734") + .setSuggestionFeatureConfig( + HumanAgentAssistantConfig.SuggestionFeatureConfig.newBuilder().build()) + .build(); + ApiFuture future = + conversationProfilesClient.setSuggestionFeatureConfigCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_setsuggestionfeatureconfig_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfigLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfigLRO.java new file mode 100644 index 000000000000..3f6b9135bdcb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfigLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_setsuggestionfeatureconfig_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.HumanAgentAssistantConfig; +import com.google.cloud.dialogflow.v2.SetSuggestionFeatureConfigOperationMetadata; +import com.google.cloud.dialogflow.v2.SetSuggestionFeatureConfigRequest; + +public class AsyncSetSuggestionFeatureConfigLRO { + + public static void main(String[] args) throws Exception { + asyncSetSuggestionFeatureConfigLRO(); + } + + public static void asyncSetSuggestionFeatureConfigLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + SetSuggestionFeatureConfigRequest request = + SetSuggestionFeatureConfigRequest.newBuilder() + .setConversationProfile("conversationProfile1691597734") + .setSuggestionFeatureConfig( + HumanAgentAssistantConfig.SuggestionFeatureConfig.newBuilder().build()) + .build(); + OperationFuture future = + conversationProfilesClient + .setSuggestionFeatureConfigOperationCallable() + .futureCall(request); + // Do something. + ConversationProfile response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_setsuggestionfeatureconfig_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfig.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfig.java new file mode 100644 index 000000000000..4e7921c79f52 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_setsuggestionfeatureconfig_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.HumanAgentAssistantConfig; +import com.google.cloud.dialogflow.v2.SetSuggestionFeatureConfigRequest; + +public class SyncSetSuggestionFeatureConfig { + + public static void main(String[] args) throws Exception { + syncSetSuggestionFeatureConfig(); + } + + public static void syncSetSuggestionFeatureConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + SetSuggestionFeatureConfigRequest request = + SetSuggestionFeatureConfigRequest.newBuilder() + .setConversationProfile("conversationProfile1691597734") + .setSuggestionFeatureConfig( + HumanAgentAssistantConfig.SuggestionFeatureConfig.newBuilder().build()) + .build(); + ConversationProfile response = + conversationProfilesClient.setSuggestionFeatureConfigAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_setsuggestionfeatureconfig_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfigString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfigString.java new file mode 100644 index 000000000000..e3aacd694ed8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfigString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_setsuggestionfeatureconfig_string_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; + +public class SyncSetSuggestionFeatureConfigString { + + public static void main(String[] args) throws Exception { + syncSetSuggestionFeatureConfigString(); + } + + public static void syncSetSuggestionFeatureConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + String conversationProfile = "conversationProfile1691597734"; + ConversationProfile response = + conversationProfilesClient.setSuggestionFeatureConfigAsync(conversationProfile).get(); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_setsuggestionfeatureconfig_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/updateconversationprofile/AsyncUpdateConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/updateconversationprofile/AsyncUpdateConversationProfile.java new file mode 100644 index 000000000000..c73b28138816 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/updateconversationprofile/AsyncUpdateConversationProfile.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_updateconversationprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.UpdateConversationProfileRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateConversationProfile { + + public static void main(String[] args) throws Exception { + asyncUpdateConversationProfile(); + } + + public static void asyncUpdateConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + UpdateConversationProfileRequest request = + UpdateConversationProfileRequest.newBuilder() + .setConversationProfile(ConversationProfile.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + conversationProfilesClient.updateConversationProfileCallable().futureCall(request); + // Do something. + ConversationProfile response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_updateconversationprofile_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfile.java new file mode 100644 index 000000000000..5358caa064f3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfile.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesclient_updateconversationprofile_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2.UpdateConversationProfileRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateConversationProfile { + + public static void main(String[] args) throws Exception { + syncUpdateConversationProfile(); + } + + public static void syncUpdateConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + UpdateConversationProfileRequest request = + UpdateConversationProfileRequest.newBuilder() + .setConversationProfile(ConversationProfile.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ConversationProfile response = conversationProfilesClient.updateConversationProfile(request); + } + } +} +// [END dialogflow_v2_generated_conversationprofilesclient_updateconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfileConversationprofileFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfileConversationprofileFieldmask.java new file mode 100644 index 000000000000..4f50ee0c51f0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfileConversationprofileFieldmask.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationprofilesclient_updateconversationprofile_conversationprofilefieldmask_sync] +import com.google.cloud.dialogflow.v2.ConversationProfile; +import com.google.cloud.dialogflow.v2.ConversationProfilesClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateConversationProfileConversationprofileFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateConversationProfileConversationprofileFieldmask(); + } + + public static void syncUpdateConversationProfileConversationprofileFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ConversationProfile response = + conversationProfilesClient.updateConversationProfile(conversationProfile, updateMask); + } + } +} +// [END +// dialogflow_v2_generated_conversationprofilesclient_updateconversationprofile_conversationprofilefieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilessettings/getconversationprofile/SyncGetConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilessettings/getconversationprofile/SyncGetConversationProfile.java new file mode 100644 index 000000000000..700f3b84c0fc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationprofilessettings/getconversationprofile/SyncGetConversationProfile.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilessettings_getconversationprofile_sync] +import com.google.cloud.dialogflow.v2.ConversationProfilesSettings; +import java.time.Duration; + +public class SyncGetConversationProfile { + + public static void main(String[] args) throws Exception { + syncGetConversationProfile(); + } + + public static void syncGetConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationProfilesSettings.Builder conversationProfilesSettingsBuilder = + ConversationProfilesSettings.newBuilder(); + conversationProfilesSettingsBuilder + .getConversationProfileSettings() + .setRetrySettings( + conversationProfilesSettingsBuilder + .getConversationProfileSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConversationProfilesSettings conversationProfilesSettings = + conversationProfilesSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_conversationprofilessettings_getconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/AsyncCompleteConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/AsyncCompleteConversation.java new file mode 100644 index 000000000000..bb9daa69034b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/AsyncCompleteConversation.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_completeconversation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.CompleteConversationRequest; +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ConversationsClient; + +public class AsyncCompleteConversation { + + public static void main(String[] args) throws Exception { + asyncCompleteConversation(); + } + + public static void asyncCompleteConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + CompleteConversationRequest request = + CompleteConversationRequest.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .build(); + ApiFuture future = + conversationsClient.completeConversationCallable().futureCall(request); + // Do something. + Conversation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationsclient_completeconversation_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/SyncCompleteConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/SyncCompleteConversation.java new file mode 100644 index 000000000000..7cadb8b80ea9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/SyncCompleteConversation.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_completeconversation_sync] +import com.google.cloud.dialogflow.v2.CompleteConversationRequest; +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ConversationsClient; + +public class SyncCompleteConversation { + + public static void main(String[] args) throws Exception { + syncCompleteConversation(); + } + + public static void syncCompleteConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + CompleteConversationRequest request = + CompleteConversationRequest.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .build(); + Conversation response = conversationsClient.completeConversation(request); + } + } +} +// [END dialogflow_v2_generated_conversationsclient_completeconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/SyncCompleteConversationConversationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/SyncCompleteConversationConversationname.java new file mode 100644 index 000000000000..db3466158e2e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/SyncCompleteConversationConversationname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_completeconversation_conversationname_sync] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ConversationsClient; + +public class SyncCompleteConversationConversationname { + + public static void main(String[] args) throws Exception { + syncCompleteConversationConversationname(); + } + + public static void syncCompleteConversationConversationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ConversationName name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + Conversation response = conversationsClient.completeConversation(name); + } + } +} +// [END dialogflow_v2_generated_conversationsclient_completeconversation_conversationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/SyncCompleteConversationString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/SyncCompleteConversationString.java new file mode 100644 index 000000000000..58599012c49b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/completeconversation/SyncCompleteConversationString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_completeconversation_string_sync] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ConversationsClient; + +public class SyncCompleteConversationString { + + public static void main(String[] args) throws Exception { + syncCompleteConversationString(); + } + + public static void syncCompleteConversationString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + String name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString(); + Conversation response = conversationsClient.completeConversation(name); + } + } +} +// [END dialogflow_v2_generated_conversationsclient_completeconversation_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..9e46996538d3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.ConversationsSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationsSettings conversationsSettings = + ConversationsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings); + } +} +// [END dialogflow_v2_generated_conversationsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..b6bb87837ccb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.ConversationsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationsSettings conversationsSettings = + ConversationsSettings.newBuilder() + .setTransportChannelProvider( + ConversationsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings); + } +} +// [END dialogflow_v2_generated_conversationsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..62b5c8a41361 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.ConversationsSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationsSettings conversationsSettings = + ConversationsSettings.newBuilder().setEndpoint(myEndpoint).build(); + ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings); + } +} +// [END dialogflow_v2_generated_conversationsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/AsyncCreateConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/AsyncCreateConversation.java new file mode 100644 index 000000000000..eec956381796 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/AsyncCreateConversation.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_createconversation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.CreateConversationRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class AsyncCreateConversation { + + public static void main(String[] args) throws Exception { + asyncCreateConversation(); + } + + public static void asyncCreateConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + CreateConversationRequest request = + CreateConversationRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setConversation(Conversation.newBuilder().build()) + .setConversationId("conversationId-1676095234") + .build(); + ApiFuture future = + conversationsClient.createConversationCallable().futureCall(request); + // Do something. + Conversation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationsclient_createconversation_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversation.java new file mode 100644 index 000000000000..8667ffcd0b07 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversation.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_createconversation_sync] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.CreateConversationRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncCreateConversation { + + public static void main(String[] args) throws Exception { + syncCreateConversation(); + } + + public static void syncCreateConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + CreateConversationRequest request = + CreateConversationRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setConversation(Conversation.newBuilder().build()) + .setConversationId("conversationId-1676095234") + .build(); + Conversation response = conversationsClient.createConversation(request); + } + } +} +// [END dialogflow_v2_generated_conversationsclient_createconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversationLocationnameConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversationLocationnameConversation.java new file mode 100644 index 000000000000..88480dda1f89 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversationLocationnameConversation.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationsclient_createconversation_locationnameconversation_sync] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncCreateConversationLocationnameConversation { + + public static void main(String[] args) throws Exception { + syncCreateConversationLocationnameConversation(); + } + + public static void syncCreateConversationLocationnameConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Conversation conversation = Conversation.newBuilder().build(); + Conversation response = conversationsClient.createConversation(parent, conversation); + } + } +} +// [END +// dialogflow_v2_generated_conversationsclient_createconversation_locationnameconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversationProjectnameConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversationProjectnameConversation.java new file mode 100644 index 000000000000..cbe588806267 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversationProjectnameConversation.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_conversationsclient_createconversation_projectnameconversation_sync] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncCreateConversationProjectnameConversation { + + public static void main(String[] args) throws Exception { + syncCreateConversationProjectnameConversation(); + } + + public static void syncCreateConversationProjectnameConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + Conversation conversation = Conversation.newBuilder().build(); + Conversation response = conversationsClient.createConversation(parent, conversation); + } + } +} +// [END dialogflow_v2_generated_conversationsclient_createconversation_projectnameconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversationStringConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversationStringConversation.java new file mode 100644 index 000000000000..9c7997f20da1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/createconversation/SyncCreateConversationStringConversation.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_createconversation_stringconversation_sync] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncCreateConversationStringConversation { + + public static void main(String[] args) throws Exception { + syncCreateConversationStringConversation(); + } + + public static void syncCreateConversationStringConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + Conversation conversation = Conversation.newBuilder().build(); + Conversation response = conversationsClient.createConversation(parent, conversation); + } + } +} +// [END dialogflow_v2_generated_conversationsclient_createconversation_stringconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/AsyncGetConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/AsyncGetConversation.java new file mode 100644 index 000000000000..b66ed71a7a73 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/AsyncGetConversation.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_getconversation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.GetConversationRequest; + +public class AsyncGetConversation { + + public static void main(String[] args) throws Exception { + asyncGetConversation(); + } + + public static void asyncGetConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + GetConversationRequest request = + GetConversationRequest.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .build(); + ApiFuture future = + conversationsClient.getConversationCallable().futureCall(request); + // Do something. + Conversation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_conversationsclient_getconversation_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/SyncGetConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/SyncGetConversation.java new file mode 100644 index 000000000000..e89ea99d05c2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/SyncGetConversation.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_getconversation_sync] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.GetConversationRequest; + +public class SyncGetConversation { + + public static void main(String[] args) throws Exception { + syncGetConversation(); + } + + public static void syncGetConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + GetConversationRequest request = + GetConversationRequest.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .build(); + Conversation response = conversationsClient.getConversation(request); + } + } +} +// [END dialogflow_v2_generated_conversationsclient_getconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/SyncGetConversationConversationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/SyncGetConversationConversationname.java new file mode 100644 index 000000000000..b304930badd1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/SyncGetConversationConversationname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_getconversation_conversationname_sync] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ConversationsClient; + +public class SyncGetConversationConversationname { + + public static void main(String[] args) throws Exception { + syncGetConversationConversationname(); + } + + public static void syncGetConversationConversationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ConversationName name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + Conversation response = conversationsClient.getConversation(name); + } + } +} +// [END dialogflow_v2_generated_conversationsclient_getconversation_conversationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/SyncGetConversationString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/SyncGetConversationString.java new file mode 100644 index 000000000000..f157b7bfa120 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/getconversation/SyncGetConversationString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_getconversation_string_sync] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ConversationsClient; + +public class SyncGetConversationString { + + public static void main(String[] args) throws Exception { + syncGetConversationString(); + } + + public static void syncGetConversationString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + String name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString(); + Conversation response = conversationsClient.getConversation(name); + } + } +} +// [END dialogflow_v2_generated_conversationsclient_getconversation_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/AsyncListConversations.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/AsyncListConversations.java new file mode 100644 index 000000000000..4594ae05385a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/AsyncListConversations.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_listconversations_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.ListConversationsRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class AsyncListConversations { + + public static void main(String[] args) throws Exception { + asyncListConversations(); + } + + public static void asyncListConversations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ListConversationsRequest request = + ListConversationsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + conversationsClient.listConversationsPagedCallable().futureCall(request); + // Do something. + for (Conversation element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationsclient_listconversations_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/AsyncListConversationsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/AsyncListConversationsPaged.java new file mode 100644 index 000000000000..9ee6ad4909d2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/AsyncListConversationsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_listconversations_paged_async] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.ListConversationsRequest; +import com.google.cloud.dialogflow.v2.ListConversationsResponse; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListConversationsPaged { + + public static void main(String[] args) throws Exception { + asyncListConversationsPaged(); + } + + public static void asyncListConversationsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ListConversationsRequest request = + ListConversationsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListConversationsResponse response = + conversationsClient.listConversationsCallable().call(request); + for (Conversation element : response.getConversationsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2_generated_conversationsclient_listconversations_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversations.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversations.java new file mode 100644 index 000000000000..9753b30be1c6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversations.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_listconversations_sync] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.ListConversationsRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncListConversations { + + public static void main(String[] args) throws Exception { + syncListConversations(); + } + + public static void syncListConversations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ListConversationsRequest request = + ListConversationsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Conversation element : conversationsClient.listConversations(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationsclient_listconversations_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversationsLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversationsLocationname.java new file mode 100644 index 000000000000..3c5ee8185fef --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversationsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_listconversations_locationname_sync] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncListConversationsLocationname { + + public static void main(String[] args) throws Exception { + syncListConversationsLocationname(); + } + + public static void syncListConversationsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationsclient_listconversations_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversationsProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversationsProjectname.java new file mode 100644 index 000000000000..47e77d6560c8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversationsProjectname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_listconversations_projectname_sync] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncListConversationsProjectname { + + public static void main(String[] args) throws Exception { + syncListConversationsProjectname(); + } + + public static void syncListConversationsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationsclient_listconversations_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversationsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversationsString.java new file mode 100644 index 000000000000..8ef3d5f39248 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listconversations/SyncListConversationsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_listconversations_string_sync] +import com.google.cloud.dialogflow.v2.Conversation; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncListConversationsString { + + public static void main(String[] args) throws Exception { + syncListConversationsString(); + } + + public static void syncListConversationsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationsclient_listconversations_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/AsyncListMessages.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/AsyncListMessages.java new file mode 100644 index 000000000000..07d1a35ccfbb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/AsyncListMessages.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_listmessages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.ListMessagesRequest; +import com.google.cloud.dialogflow.v2.Message; + +public class AsyncListMessages { + + public static void main(String[] args) throws Exception { + asyncListMessages(); + } + + public static void asyncListMessages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ListMessagesRequest request = + ListMessagesRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + conversationsClient.listMessagesPagedCallable().futureCall(request); + // Do something. + for (Message element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationsclient_listmessages_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/AsyncListMessagesPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/AsyncListMessagesPaged.java new file mode 100644 index 000000000000..9f396025e930 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/AsyncListMessagesPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_listmessages_paged_async] +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.ListMessagesRequest; +import com.google.cloud.dialogflow.v2.ListMessagesResponse; +import com.google.cloud.dialogflow.v2.Message; +import com.google.common.base.Strings; + +public class AsyncListMessagesPaged { + + public static void main(String[] args) throws Exception { + asyncListMessagesPaged(); + } + + public static void asyncListMessagesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ListMessagesRequest request = + ListMessagesRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListMessagesResponse response = conversationsClient.listMessagesCallable().call(request); + for (Message element : response.getMessagesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2_generated_conversationsclient_listmessages_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/SyncListMessages.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/SyncListMessages.java new file mode 100644 index 000000000000..0acd095dd111 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/SyncListMessages.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_listmessages_sync] +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.ListMessagesRequest; +import com.google.cloud.dialogflow.v2.Message; + +public class SyncListMessages { + + public static void main(String[] args) throws Exception { + syncListMessages(); + } + + public static void syncListMessages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ListMessagesRequest request = + ListMessagesRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Message element : conversationsClient.listMessages(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationsclient_listmessages_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/SyncListMessagesConversationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/SyncListMessagesConversationname.java new file mode 100644 index 000000000000..86ea7dbc3cb0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/SyncListMessagesConversationname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_listmessages_conversationname_sync] +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.Message; + +public class SyncListMessagesConversationname { + + public static void main(String[] args) throws Exception { + syncListMessagesConversationname(); + } + + public static void syncListMessagesConversationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + for (Message element : conversationsClient.listMessages(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationsclient_listmessages_conversationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/SyncListMessagesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/SyncListMessagesString.java new file mode 100644 index 000000000000..5a8b34e669c7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationsclient/listmessages/SyncListMessagesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsclient_listmessages_string_sync] +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ConversationsClient; +import com.google.cloud.dialogflow.v2.Message; + +public class SyncListMessagesString { + + public static void main(String[] args) throws Exception { + syncListMessagesString(); + } + + public static void syncListMessagesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + String parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString(); + for (Message element : conversationsClient.listMessages(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_conversationsclient_listmessages_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationssettings/createconversation/SyncCreateConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationssettings/createconversation/SyncCreateConversation.java new file mode 100644 index 000000000000..00df03b43ac8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/conversationssettings/createconversation/SyncCreateConversation.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationssettings_createconversation_sync] +import com.google.cloud.dialogflow.v2.ConversationsSettings; +import java.time.Duration; + +public class SyncCreateConversation { + + public static void main(String[] args) throws Exception { + syncCreateConversation(); + } + + public static void syncCreateConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationsSettings.Builder conversationsSettingsBuilder = ConversationsSettings.newBuilder(); + conversationsSettingsBuilder + .createConversationSettings() + .setRetrySettings( + conversationsSettingsBuilder + .createConversationSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConversationsSettings conversationsSettings = conversationsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_conversationssettings_createconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..b8bb02e51049 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.DocumentsSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentsSettings documentsSettings = + DocumentsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + DocumentsClient documentsClient = DocumentsClient.create(documentsSettings); + } +} +// [END dialogflow_v2_generated_documentsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..a1406f35d47c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.DocumentsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentsSettings documentsSettings = + DocumentsSettings.newBuilder() + .setTransportChannelProvider( + DocumentsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + DocumentsClient documentsClient = DocumentsClient.create(documentsSettings); + } +} +// [END dialogflow_v2_generated_documentsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..dbb39001c82f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.DocumentsSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentsSettings documentsSettings = + DocumentsSettings.newBuilder().setEndpoint(myEndpoint).build(); + DocumentsClient documentsClient = DocumentsClient.create(documentsSettings); + } +} +// [END dialogflow_v2_generated_documentsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/AsyncCreateDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/AsyncCreateDocument.java new file mode 100644 index 000000000000..5525742c1be2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/AsyncCreateDocument.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_createdocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.CreateDocumentRequest; +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.longrunning.Operation; + +public class AsyncCreateDocument { + + public static void main(String[] args) throws Exception { + asyncCreateDocument(); + } + + public static void asyncCreateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + CreateDocumentRequest request = + CreateDocumentRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocument(Document.newBuilder().build()) + .build(); + ApiFuture future = documentsClient.createDocumentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_createdocument_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/AsyncCreateDocumentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/AsyncCreateDocumentLRO.java new file mode 100644 index 000000000000..e71dfa2de312 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/AsyncCreateDocumentLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_createdocument_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.CreateDocumentRequest; +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2.KnowledgeOperationMetadata; + +public class AsyncCreateDocumentLRO { + + public static void main(String[] args) throws Exception { + asyncCreateDocumentLRO(); + } + + public static void asyncCreateDocumentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + CreateDocumentRequest request = + CreateDocumentRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocument(Document.newBuilder().build()) + .build(); + OperationFuture future = + documentsClient.createDocumentOperationCallable().futureCall(request); + // Do something. + Document response = future.get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_createdocument_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/SyncCreateDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/SyncCreateDocument.java new file mode 100644 index 000000000000..6b903e30522e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/SyncCreateDocument.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_createdocument_sync] +import com.google.cloud.dialogflow.v2.CreateDocumentRequest; +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; + +public class SyncCreateDocument { + + public static void main(String[] args) throws Exception { + syncCreateDocument(); + } + + public static void syncCreateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + CreateDocumentRequest request = + CreateDocumentRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocument(Document.newBuilder().build()) + .build(); + Document response = documentsClient.createDocumentAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_createdocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/SyncCreateDocumentKnowledgebasenameDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/SyncCreateDocumentKnowledgebasenameDocument.java new file mode 100644 index 000000000000..0be29af01e57 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/SyncCreateDocumentKnowledgebasenameDocument.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_createdocument_knowledgebasenamedocument_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; + +public class SyncCreateDocumentKnowledgebasenameDocument { + + public static void main(String[] args) throws Exception { + syncCreateDocumentKnowledgebasenameDocument(); + } + + public static void syncCreateDocumentKnowledgebasenameDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + KnowledgeBaseName parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + Document document = Document.newBuilder().build(); + Document response = documentsClient.createDocumentAsync(parent, document).get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_createdocument_knowledgebasenamedocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/SyncCreateDocumentStringDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/SyncCreateDocumentStringDocument.java new file mode 100644 index 000000000000..8fcb7f68acc9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/createdocument/SyncCreateDocumentStringDocument.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_createdocument_stringdocument_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; + +public class SyncCreateDocumentStringDocument { + + public static void main(String[] args) throws Exception { + syncCreateDocumentStringDocument(); + } + + public static void syncCreateDocumentStringDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + String parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]").toString(); + Document document = Document.newBuilder().build(); + Document response = documentsClient.createDocumentAsync(parent, document).get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_createdocument_stringdocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/AsyncDeleteDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/AsyncDeleteDocument.java new file mode 100644 index 000000000000..f12dc46155d1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/AsyncDeleteDocument.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_deletedocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.DeleteDocumentRequest; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteDocument { + + public static void main(String[] args) throws Exception { + asyncDeleteDocument(); + } + + public static void asyncDeleteDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + DeleteDocumentRequest request = + DeleteDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .build(); + ApiFuture future = documentsClient.deleteDocumentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_deletedocument_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/AsyncDeleteDocumentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/AsyncDeleteDocumentLRO.java new file mode 100644 index 000000000000..23c9b65cdb69 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/AsyncDeleteDocumentLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_deletedocument_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.DeleteDocumentRequest; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.KnowledgeOperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteDocumentLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteDocumentLRO(); + } + + public static void asyncDeleteDocumentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + DeleteDocumentRequest request = + DeleteDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .build(); + OperationFuture future = + documentsClient.deleteDocumentOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_deletedocument_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/SyncDeleteDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/SyncDeleteDocument.java new file mode 100644 index 000000000000..e5a52cd0e5cb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/SyncDeleteDocument.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_deletedocument_sync] +import com.google.cloud.dialogflow.v2.DeleteDocumentRequest; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; + +public class SyncDeleteDocument { + + public static void main(String[] args) throws Exception { + syncDeleteDocument(); + } + + public static void syncDeleteDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + DeleteDocumentRequest request = + DeleteDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .build(); + documentsClient.deleteDocumentAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_deletedocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/SyncDeleteDocumentDocumentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/SyncDeleteDocumentDocumentname.java new file mode 100644 index 000000000000..19440c5bc9ea --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/SyncDeleteDocumentDocumentname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_deletedocument_documentname_sync] +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; + +public class SyncDeleteDocumentDocumentname { + + public static void main(String[] args) throws Exception { + syncDeleteDocumentDocumentname(); + } + + public static void syncDeleteDocumentDocumentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + documentsClient.deleteDocumentAsync(name).get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_deletedocument_documentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/SyncDeleteDocumentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/SyncDeleteDocumentString.java new file mode 100644 index 000000000000..d39ae1f6e6f1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/deletedocument/SyncDeleteDocumentString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_deletedocument_string_sync] +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; + +public class SyncDeleteDocumentString { + + public static void main(String[] args) throws Exception { + syncDeleteDocumentString(); + } + + public static void syncDeleteDocumentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + String name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString(); + documentsClient.deleteDocumentAsync(name).get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_deletedocument_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/exportdocument/AsyncExportDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/exportdocument/AsyncExportDocument.java new file mode 100644 index 000000000000..1f9af370e7cf --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/exportdocument/AsyncExportDocument.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_exportdocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.ExportDocumentRequest; +import com.google.longrunning.Operation; + +public class AsyncExportDocument { + + public static void main(String[] args) throws Exception { + asyncExportDocument(); + } + + public static void asyncExportDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ExportDocumentRequest request = + ExportDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setExportFullContent(true) + .setSmartMessagingPartialUpdate(true) + .build(); + ApiFuture future = documentsClient.exportDocumentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_exportdocument_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/exportdocument/AsyncExportDocumentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/exportdocument/AsyncExportDocumentLRO.java new file mode 100644 index 000000000000..595e50526d6b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/exportdocument/AsyncExportDocumentLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_exportdocument_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.ExportDocumentRequest; +import com.google.cloud.dialogflow.v2.KnowledgeOperationMetadata; + +public class AsyncExportDocumentLRO { + + public static void main(String[] args) throws Exception { + asyncExportDocumentLRO(); + } + + public static void asyncExportDocumentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ExportDocumentRequest request = + ExportDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setExportFullContent(true) + .setSmartMessagingPartialUpdate(true) + .build(); + OperationFuture future = + documentsClient.exportDocumentOperationCallable().futureCall(request); + // Do something. + Document response = future.get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_exportdocument_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/exportdocument/SyncExportDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/exportdocument/SyncExportDocument.java new file mode 100644 index 000000000000..e666791a4229 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/exportdocument/SyncExportDocument.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_exportdocument_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.ExportDocumentRequest; + +public class SyncExportDocument { + + public static void main(String[] args) throws Exception { + syncExportDocument(); + } + + public static void syncExportDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ExportDocumentRequest request = + ExportDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setExportFullContent(true) + .setSmartMessagingPartialUpdate(true) + .build(); + Document response = documentsClient.exportDocumentAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_exportdocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/AsyncGetDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/AsyncGetDocument.java new file mode 100644 index 000000000000..ff203182b274 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/AsyncGetDocument.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_getdocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.GetDocumentRequest; + +public class AsyncGetDocument { + + public static void main(String[] args) throws Exception { + asyncGetDocument(); + } + + public static void asyncGetDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + GetDocumentRequest request = + GetDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .build(); + ApiFuture future = documentsClient.getDocumentCallable().futureCall(request); + // Do something. + Document response = future.get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_getdocument_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/SyncGetDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/SyncGetDocument.java new file mode 100644 index 000000000000..8791e51f645c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/SyncGetDocument.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_getdocument_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.GetDocumentRequest; + +public class SyncGetDocument { + + public static void main(String[] args) throws Exception { + syncGetDocument(); + } + + public static void syncGetDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + GetDocumentRequest request = + GetDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .build(); + Document response = documentsClient.getDocument(request); + } + } +} +// [END dialogflow_v2_generated_documentsclient_getdocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/SyncGetDocumentDocumentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/SyncGetDocumentDocumentname.java new file mode 100644 index 000000000000..2982f7d59721 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/SyncGetDocumentDocumentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_getdocument_documentname_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; + +public class SyncGetDocumentDocumentname { + + public static void main(String[] args) throws Exception { + syncGetDocumentDocumentname(); + } + + public static void syncGetDocumentDocumentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + Document response = documentsClient.getDocument(name); + } + } +} +// [END dialogflow_v2_generated_documentsclient_getdocument_documentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/SyncGetDocumentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/SyncGetDocumentString.java new file mode 100644 index 000000000000..b827a1275d3e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/getdocument/SyncGetDocumentString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_getdocument_string_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; + +public class SyncGetDocumentString { + + public static void main(String[] args) throws Exception { + syncGetDocumentString(); + } + + public static void syncGetDocumentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + String name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString(); + Document response = documentsClient.getDocument(name); + } + } +} +// [END dialogflow_v2_generated_documentsclient_getdocument_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/importdocuments/AsyncImportDocuments.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/importdocuments/AsyncImportDocuments.java new file mode 100644 index 000000000000..e3bb1c92b62f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/importdocuments/AsyncImportDocuments.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_importdocuments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.ImportDocumentTemplate; +import com.google.cloud.dialogflow.v2.ImportDocumentsRequest; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.longrunning.Operation; + +public class AsyncImportDocuments { + + public static void main(String[] args) throws Exception { + asyncImportDocuments(); + } + + public static void asyncImportDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ImportDocumentsRequest request = + ImportDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocumentTemplate(ImportDocumentTemplate.newBuilder().build()) + .setImportGcsCustomMetadata(true) + .build(); + ApiFuture future = documentsClient.importDocumentsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_importdocuments_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/importdocuments/AsyncImportDocumentsLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/importdocuments/AsyncImportDocumentsLRO.java new file mode 100644 index 000000000000..0936a7a218e6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/importdocuments/AsyncImportDocumentsLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_importdocuments_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.ImportDocumentTemplate; +import com.google.cloud.dialogflow.v2.ImportDocumentsRequest; +import com.google.cloud.dialogflow.v2.ImportDocumentsResponse; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2.KnowledgeOperationMetadata; + +public class AsyncImportDocumentsLRO { + + public static void main(String[] args) throws Exception { + asyncImportDocumentsLRO(); + } + + public static void asyncImportDocumentsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ImportDocumentsRequest request = + ImportDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocumentTemplate(ImportDocumentTemplate.newBuilder().build()) + .setImportGcsCustomMetadata(true) + .build(); + OperationFuture future = + documentsClient.importDocumentsOperationCallable().futureCall(request); + // Do something. + ImportDocumentsResponse response = future.get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_importdocuments_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/importdocuments/SyncImportDocuments.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/importdocuments/SyncImportDocuments.java new file mode 100644 index 000000000000..e1d41462289b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/importdocuments/SyncImportDocuments.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_importdocuments_sync] +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.ImportDocumentTemplate; +import com.google.cloud.dialogflow.v2.ImportDocumentsRequest; +import com.google.cloud.dialogflow.v2.ImportDocumentsResponse; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; + +public class SyncImportDocuments { + + public static void main(String[] args) throws Exception { + syncImportDocuments(); + } + + public static void syncImportDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ImportDocumentsRequest request = + ImportDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocumentTemplate(ImportDocumentTemplate.newBuilder().build()) + .setImportGcsCustomMetadata(true) + .build(); + ImportDocumentsResponse response = documentsClient.importDocumentsAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_importdocuments_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/AsyncListDocuments.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/AsyncListDocuments.java new file mode 100644 index 000000000000..7d8f7941b84f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/AsyncListDocuments.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_listdocuments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2.ListDocumentsRequest; + +public class AsyncListDocuments { + + public static void main(String[] args) throws Exception { + asyncListDocuments(); + } + + public static void asyncListDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ListDocumentsRequest request = + ListDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = documentsClient.listDocumentsPagedCallable().futureCall(request); + // Do something. + for (Document element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_documentsclient_listdocuments_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/AsyncListDocumentsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/AsyncListDocumentsPaged.java new file mode 100644 index 000000000000..7e43910e57fc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/AsyncListDocumentsPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_listdocuments_paged_async] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2.ListDocumentsRequest; +import com.google.cloud.dialogflow.v2.ListDocumentsResponse; +import com.google.common.base.Strings; + +public class AsyncListDocumentsPaged { + + public static void main(String[] args) throws Exception { + asyncListDocumentsPaged(); + } + + public static void asyncListDocumentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ListDocumentsRequest request = + ListDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListDocumentsResponse response = documentsClient.listDocumentsCallable().call(request); + for (Document element : response.getDocumentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2_generated_documentsclient_listdocuments_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/SyncListDocuments.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/SyncListDocuments.java new file mode 100644 index 000000000000..bd7a626d1f60 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/SyncListDocuments.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_listdocuments_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2.ListDocumentsRequest; + +public class SyncListDocuments { + + public static void main(String[] args) throws Exception { + syncListDocuments(); + } + + public static void syncListDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ListDocumentsRequest request = + ListDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Document element : documentsClient.listDocuments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_documentsclient_listdocuments_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/SyncListDocumentsKnowledgebasename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/SyncListDocumentsKnowledgebasename.java new file mode 100644 index 000000000000..dd02c8a9bce5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/SyncListDocumentsKnowledgebasename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_listdocuments_knowledgebasename_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; + +public class SyncListDocumentsKnowledgebasename { + + public static void main(String[] args) throws Exception { + syncListDocumentsKnowledgebasename(); + } + + public static void syncListDocumentsKnowledgebasename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + KnowledgeBaseName parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + for (Document element : documentsClient.listDocuments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_documentsclient_listdocuments_knowledgebasename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/SyncListDocumentsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/SyncListDocumentsString.java new file mode 100644 index 000000000000..e60e000791b4 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/listdocuments/SyncListDocumentsString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_listdocuments_string_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; + +public class SyncListDocumentsString { + + public static void main(String[] args) throws Exception { + syncListDocumentsString(); + } + + public static void syncListDocumentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + String parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]").toString(); + for (Document element : documentsClient.listDocuments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_documentsclient_listdocuments_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/AsyncReloadDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/AsyncReloadDocument.java new file mode 100644 index 000000000000..f92353f084d9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/AsyncReloadDocument.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_reloaddocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.ReloadDocumentRequest; +import com.google.longrunning.Operation; + +public class AsyncReloadDocument { + + public static void main(String[] args) throws Exception { + asyncReloadDocument(); + } + + public static void asyncReloadDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ReloadDocumentRequest request = + ReloadDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setImportGcsCustomMetadata(true) + .setSmartMessagingPartialUpdate(true) + .build(); + ApiFuture future = documentsClient.reloadDocumentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_reloaddocument_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/AsyncReloadDocumentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/AsyncReloadDocumentLRO.java new file mode 100644 index 000000000000..d52196c1875f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/AsyncReloadDocumentLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_reloaddocument_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.KnowledgeOperationMetadata; +import com.google.cloud.dialogflow.v2.ReloadDocumentRequest; + +public class AsyncReloadDocumentLRO { + + public static void main(String[] args) throws Exception { + asyncReloadDocumentLRO(); + } + + public static void asyncReloadDocumentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ReloadDocumentRequest request = + ReloadDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setImportGcsCustomMetadata(true) + .setSmartMessagingPartialUpdate(true) + .build(); + OperationFuture future = + documentsClient.reloadDocumentOperationCallable().futureCall(request); + // Do something. + Document response = future.get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_reloaddocument_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/SyncReloadDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/SyncReloadDocument.java new file mode 100644 index 000000000000..a7602ff88248 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/SyncReloadDocument.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_reloaddocument_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.ReloadDocumentRequest; + +public class SyncReloadDocument { + + public static void main(String[] args) throws Exception { + syncReloadDocument(); + } + + public static void syncReloadDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ReloadDocumentRequest request = + ReloadDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setImportGcsCustomMetadata(true) + .setSmartMessagingPartialUpdate(true) + .build(); + Document response = documentsClient.reloadDocumentAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_reloaddocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/SyncReloadDocumentDocumentnameString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/SyncReloadDocumentDocumentnameString.java new file mode 100644 index 000000000000..a1eebe916d32 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/SyncReloadDocumentDocumentnameString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_reloaddocument_documentnamestring_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; + +public class SyncReloadDocumentDocumentnameString { + + public static void main(String[] args) throws Exception { + syncReloadDocumentDocumentnameString(); + } + + public static void syncReloadDocumentDocumentnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + String contentUri = "contentUri264542771"; + Document response = documentsClient.reloadDocumentAsync(name, contentUri).get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_reloaddocument_documentnamestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/SyncReloadDocumentStringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/SyncReloadDocumentStringString.java new file mode 100644 index 000000000000..8b6fb8adf63b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/reloaddocument/SyncReloadDocumentStringString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_reloaddocument_stringstring_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentName; +import com.google.cloud.dialogflow.v2.DocumentsClient; + +public class SyncReloadDocumentStringString { + + public static void main(String[] args) throws Exception { + syncReloadDocumentStringString(); + } + + public static void syncReloadDocumentStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + String name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString(); + String contentUri = "contentUri264542771"; + Document response = documentsClient.reloadDocumentAsync(name, contentUri).get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_reloaddocument_stringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/AsyncUpdateDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/AsyncUpdateDocument.java new file mode 100644 index 000000000000..ac116f28398d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/AsyncUpdateDocument.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_updatedocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.UpdateDocumentRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateDocument { + + public static void main(String[] args) throws Exception { + asyncUpdateDocument(); + } + + public static void asyncUpdateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + UpdateDocumentRequest request = + UpdateDocumentRequest.newBuilder() + .setDocument(Document.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = documentsClient.updateDocumentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_updatedocument_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/AsyncUpdateDocumentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/AsyncUpdateDocumentLRO.java new file mode 100644 index 000000000000..ea53d6e2444f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/AsyncUpdateDocumentLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_updatedocument_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.KnowledgeOperationMetadata; +import com.google.cloud.dialogflow.v2.UpdateDocumentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateDocumentLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateDocumentLRO(); + } + + public static void asyncUpdateDocumentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + UpdateDocumentRequest request = + UpdateDocumentRequest.newBuilder() + .setDocument(Document.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + documentsClient.updateDocumentOperationCallable().futureCall(request); + // Do something. + Document response = future.get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_updatedocument_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/SyncUpdateDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/SyncUpdateDocument.java new file mode 100644 index 000000000000..8732626b95b6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/SyncUpdateDocument.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_updatedocument_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.cloud.dialogflow.v2.UpdateDocumentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateDocument { + + public static void main(String[] args) throws Exception { + syncUpdateDocument(); + } + + public static void syncUpdateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + UpdateDocumentRequest request = + UpdateDocumentRequest.newBuilder() + .setDocument(Document.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Document response = documentsClient.updateDocumentAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_updatedocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/SyncUpdateDocumentDocumentFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/SyncUpdateDocumentDocumentFieldmask.java new file mode 100644 index 000000000000..c33de6525c83 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentsclient/updatedocument/SyncUpdateDocumentDocumentFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsclient_updatedocument_documentfieldmask_sync] +import com.google.cloud.dialogflow.v2.Document; +import com.google.cloud.dialogflow.v2.DocumentsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateDocumentDocumentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateDocumentDocumentFieldmask(); + } + + public static void syncUpdateDocumentDocumentFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + Document document = Document.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Document response = documentsClient.updateDocumentAsync(document, updateMask).get(); + } + } +} +// [END dialogflow_v2_generated_documentsclient_updatedocument_documentfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentssettings/getdocument/SyncGetDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentssettings/getdocument/SyncGetDocument.java new file mode 100644 index 000000000000..49390e67fff6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/documentssettings/getdocument/SyncGetDocument.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentssettings_getdocument_sync] +import com.google.cloud.dialogflow.v2.DocumentsSettings; +import java.time.Duration; + +public class SyncGetDocument { + + public static void main(String[] args) throws Exception { + syncGetDocument(); + } + + public static void syncGetDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentsSettings.Builder documentsSettingsBuilder = DocumentsSettings.newBuilder(); + documentsSettingsBuilder + .getDocumentSettings() + .setRetrySettings( + documentsSettingsBuilder + .getDocumentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DocumentsSettings documentsSettings = documentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_documentssettings_getdocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/AsyncBatchCreateEntities.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/AsyncBatchCreateEntities.java new file mode 100644 index 000000000000..1cbe9ce4c619 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/AsyncBatchCreateEntities.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchcreateentities_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.BatchCreateEntitiesRequest; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncBatchCreateEntities { + + public static void main(String[] args) throws Exception { + asyncBatchCreateEntities(); + } + + public static void asyncBatchCreateEntities() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchCreateEntitiesRequest request = + BatchCreateEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntities(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + ApiFuture future = + entityTypesClient.batchCreateEntitiesCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchcreateentities_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/AsyncBatchCreateEntitiesLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/AsyncBatchCreateEntitiesLRO.java new file mode 100644 index 000000000000..9f3694f88ca7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/AsyncBatchCreateEntitiesLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchcreateentities_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.BatchCreateEntitiesRequest; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.util.ArrayList; + +public class AsyncBatchCreateEntitiesLRO { + + public static void main(String[] args) throws Exception { + asyncBatchCreateEntitiesLRO(); + } + + public static void asyncBatchCreateEntitiesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchCreateEntitiesRequest request = + BatchCreateEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntities(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + OperationFuture future = + entityTypesClient.batchCreateEntitiesOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchcreateentities_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntities.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntities.java new file mode 100644 index 000000000000..4f49f489478a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntities.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchcreateentities_sync] +import com.google.cloud.dialogflow.v2.BatchCreateEntitiesRequest; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; + +public class SyncBatchCreateEntities { + + public static void main(String[] args) throws Exception { + syncBatchCreateEntities(); + } + + public static void syncBatchCreateEntities() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchCreateEntitiesRequest request = + BatchCreateEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntities(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + entityTypesClient.batchCreateEntitiesAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchcreateentities_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentity.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentity.java new file mode 100644 index 000000000000..ea820aa62d8e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentity.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_entitytypesclient_batchcreateentities_entitytypenamelistentitytypeentity_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchCreateEntitiesEntitytypenameListentitytypeentity { + + public static void main(String[] args) throws Exception { + syncBatchCreateEntitiesEntitytypenameListentitytypeentity(); + } + + public static void syncBatchCreateEntitiesEntitytypenameListentitytypeentity() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + entityTypesClient.batchCreateEntitiesAsync(parent, entities).get(); + } + } +} +// [END +// dialogflow_v2_generated_entitytypesclient_batchcreateentities_entitytypenamelistentitytypeentity_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentityString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentityString.java new file mode 100644 index 000000000000..e7d7ce647d90 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentityString.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_entitytypesclient_batchcreateentities_entitytypenamelistentitytypeentitystring_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchCreateEntitiesEntitytypenameListentitytypeentityString { + + public static void main(String[] args) throws Exception { + syncBatchCreateEntitiesEntitytypenameListentitytypeentityString(); + } + + public static void syncBatchCreateEntitiesEntitytypenameListentitytypeentityString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + entityTypesClient.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + } + } +} +// [END +// dialogflow_v2_generated_entitytypesclient_batchcreateentities_entitytypenamelistentitytypeentitystring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentity.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentity.java new file mode 100644 index 000000000000..b378b73348b5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentity.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_entitytypesclient_batchcreateentities_stringlistentitytypeentity_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchCreateEntitiesStringListentitytypeentity { + + public static void main(String[] args) throws Exception { + syncBatchCreateEntitiesStringListentitytypeentity(); + } + + public static void syncBatchCreateEntitiesStringListentitytypeentity() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + List entities = new ArrayList<>(); + entityTypesClient.batchCreateEntitiesAsync(parent, entities).get(); + } + } +} +// [END +// dialogflow_v2_generated_entitytypesclient_batchcreateentities_stringlistentitytypeentity_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentityString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentityString.java new file mode 100644 index 000000000000..e801aaf367ec --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentityString.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_entitytypesclient_batchcreateentities_stringlistentitytypeentitystring_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchCreateEntitiesStringListentitytypeentityString { + + public static void main(String[] args) throws Exception { + syncBatchCreateEntitiesStringListentitytypeentityString(); + } + + public static void syncBatchCreateEntitiesStringListentitytypeentityString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + entityTypesClient.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + } + } +} +// [END +// dialogflow_v2_generated_entitytypesclient_batchcreateentities_stringlistentitytypeentitystring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntities.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntities.java new file mode 100644 index 000000000000..a78c6ecbe164 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntities.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchdeleteentities_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.BatchDeleteEntitiesRequest; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncBatchDeleteEntities { + + public static void main(String[] args) throws Exception { + asyncBatchDeleteEntities(); + } + + public static void asyncBatchDeleteEntities() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchDeleteEntitiesRequest request = + BatchDeleteEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntityValues(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + ApiFuture future = + entityTypesClient.batchDeleteEntitiesCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchdeleteentities_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntitiesLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntitiesLRO.java new file mode 100644 index 000000000000..b88896f8f212 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntitiesLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchdeleteentities_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.BatchDeleteEntitiesRequest; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.util.ArrayList; + +public class AsyncBatchDeleteEntitiesLRO { + + public static void main(String[] args) throws Exception { + asyncBatchDeleteEntitiesLRO(); + } + + public static void asyncBatchDeleteEntitiesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchDeleteEntitiesRequest request = + BatchDeleteEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntityValues(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + OperationFuture future = + entityTypesClient.batchDeleteEntitiesOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchdeleteentities_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntities.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntities.java new file mode 100644 index 000000000000..8b296afa0e74 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntities.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchdeleteentities_sync] +import com.google.cloud.dialogflow.v2.BatchDeleteEntitiesRequest; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; + +public class SyncBatchDeleteEntities { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntities(); + } + + public static void syncBatchDeleteEntities() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchDeleteEntitiesRequest request = + BatchDeleteEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntityValues(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + entityTypesClient.batchDeleteEntitiesAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchdeleteentities_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstring.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstring.java new file mode 100644 index 000000000000..1c3dca6eda83 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstring.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_entitytypesclient_batchdeleteentities_entitytypenameliststring_sync] +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteEntitiesEntitytypenameListstring { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntitiesEntitytypenameListstring(); + } + + public static void syncBatchDeleteEntitiesEntitytypenameListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + entityTypesClient.batchDeleteEntitiesAsync(parent, entityValues).get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchdeleteentities_entitytypenameliststring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstringString.java new file mode 100644 index 000000000000..f2e922b5a9be --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstringString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_entitytypesclient_batchdeleteentities_entitytypenameliststringstring_sync] +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteEntitiesEntitytypenameListstringString { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntitiesEntitytypenameListstringString(); + } + + public static void syncBatchDeleteEntitiesEntitytypenameListstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + entityTypesClient.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + } + } +} +// [END +// dialogflow_v2_generated_entitytypesclient_batchdeleteentities_entitytypenameliststringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstring.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstring.java new file mode 100644 index 000000000000..1bd1be5ca938 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstring.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchdeleteentities_stringliststring_sync] +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteEntitiesStringListstring { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntitiesStringListstring(); + } + + public static void syncBatchDeleteEntitiesStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + List entityValues = new ArrayList<>(); + entityTypesClient.batchDeleteEntitiesAsync(parent, entityValues).get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchdeleteentities_stringliststring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstringString.java new file mode 100644 index 000000000000..57f20e52b6d8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstringString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchdeleteentities_stringliststringstring_sync] +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteEntitiesStringListstringString { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntitiesStringListstringString(); + } + + public static void syncBatchDeleteEntitiesStringListstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + entityTypesClient.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchdeleteentities_stringliststringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypes.java new file mode 100644 index 000000000000..858502e95d2a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypes.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchdeleteentitytypes_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchDeleteEntityTypesRequest; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncBatchDeleteEntityTypes { + + public static void main(String[] args) throws Exception { + asyncBatchDeleteEntityTypes(); + } + + public static void asyncBatchDeleteEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchDeleteEntityTypesRequest request = + BatchDeleteEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .addAllEntityTypeNames(new ArrayList()) + .build(); + ApiFuture future = + entityTypesClient.batchDeleteEntityTypesCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchdeleteentitytypes_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypesLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypesLRO.java new file mode 100644 index 000000000000..3e23fbcd4c9e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypesLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchdeleteentitytypes_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchDeleteEntityTypesRequest; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.util.ArrayList; + +public class AsyncBatchDeleteEntityTypesLRO { + + public static void main(String[] args) throws Exception { + asyncBatchDeleteEntityTypesLRO(); + } + + public static void asyncBatchDeleteEntityTypesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchDeleteEntityTypesRequest request = + BatchDeleteEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .addAllEntityTypeNames(new ArrayList()) + .build(); + OperationFuture future = + entityTypesClient.batchDeleteEntityTypesOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchdeleteentitytypes_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypes.java new file mode 100644 index 000000000000..638105f6ac15 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypes.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchdeleteentitytypes_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchDeleteEntityTypesRequest; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; + +public class SyncBatchDeleteEntityTypes { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntityTypes(); + } + + public static void syncBatchDeleteEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchDeleteEntityTypesRequest request = + BatchDeleteEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .addAllEntityTypeNames(new ArrayList()) + .build(); + entityTypesClient.batchDeleteEntityTypesAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchdeleteentitytypes_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesAgentnameListstring.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesAgentnameListstring.java new file mode 100644 index 000000000000..fd4c77171842 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesAgentnameListstring.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchdeleteentitytypes_agentnameliststring_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteEntityTypesAgentnameListstring { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntityTypesAgentnameListstring(); + } + + public static void syncBatchDeleteEntityTypesAgentnameListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + List entityTypeNames = new ArrayList<>(); + entityTypesClient.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchdeleteentitytypes_agentnameliststring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesStringListstring.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesStringListstring.java new file mode 100644 index 000000000000..e0e8b178d73f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesStringListstring.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchdeleteentitytypes_stringliststring_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteEntityTypesStringListstring { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntityTypesStringListstring(); + } + + public static void syncBatchDeleteEntityTypesStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + List entityTypeNames = new ArrayList<>(); + entityTypesClient.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchdeleteentitytypes_stringliststring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntities.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntities.java new file mode 100644 index 000000000000..bb8941b756f7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntities.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchupdateentities_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.BatchUpdateEntitiesRequest; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import java.util.ArrayList; + +public class AsyncBatchUpdateEntities { + + public static void main(String[] args) throws Exception { + asyncBatchUpdateEntities(); + } + + public static void asyncBatchUpdateEntities() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchUpdateEntitiesRequest request = + BatchUpdateEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntities(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + entityTypesClient.batchUpdateEntitiesCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchupdateentities_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntitiesLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntitiesLRO.java new file mode 100644 index 000000000000..bad2bd82f0e5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntitiesLRO.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchupdateentities_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.BatchUpdateEntitiesRequest; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Struct; +import java.util.ArrayList; + +public class AsyncBatchUpdateEntitiesLRO { + + public static void main(String[] args) throws Exception { + asyncBatchUpdateEntitiesLRO(); + } + + public static void asyncBatchUpdateEntitiesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchUpdateEntitiesRequest request = + BatchUpdateEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntities(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + entityTypesClient.batchUpdateEntitiesOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchupdateentities_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntities.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntities.java new file mode 100644 index 000000000000..2119067fe906 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntities.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchupdateentities_sync] +import com.google.cloud.dialogflow.v2.BatchUpdateEntitiesRequest; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.protobuf.FieldMask; +import java.util.ArrayList; + +public class SyncBatchUpdateEntities { + + public static void main(String[] args) throws Exception { + syncBatchUpdateEntities(); + } + + public static void syncBatchUpdateEntities() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchUpdateEntitiesRequest request = + BatchUpdateEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntities(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + entityTypesClient.batchUpdateEntitiesAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchupdateentities_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentity.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentity.java new file mode 100644 index 000000000000..52d53c024609 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentity.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_entitytypesclient_batchupdateentities_entitytypenamelistentitytypeentity_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchUpdateEntitiesEntitytypenameListentitytypeentity { + + public static void main(String[] args) throws Exception { + syncBatchUpdateEntitiesEntitytypenameListentitytypeentity(); + } + + public static void syncBatchUpdateEntitiesEntitytypenameListentitytypeentity() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + entityTypesClient.batchUpdateEntitiesAsync(parent, entities).get(); + } + } +} +// [END +// dialogflow_v2_generated_entitytypesclient_batchupdateentities_entitytypenamelistentitytypeentity_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentityString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentityString.java new file mode 100644 index 000000000000..aded71db14d0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentityString.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_entitytypesclient_batchupdateentities_entitytypenamelistentitytypeentitystring_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchUpdateEntitiesEntitytypenameListentitytypeentityString { + + public static void main(String[] args) throws Exception { + syncBatchUpdateEntitiesEntitytypenameListentitytypeentityString(); + } + + public static void syncBatchUpdateEntitiesEntitytypenameListentitytypeentityString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + entityTypesClient.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + } + } +} +// [END +// dialogflow_v2_generated_entitytypesclient_batchupdateentities_entitytypenamelistentitytypeentitystring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentity.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentity.java new file mode 100644 index 000000000000..725db103a243 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentity.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_entitytypesclient_batchupdateentities_stringlistentitytypeentity_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchUpdateEntitiesStringListentitytypeentity { + + public static void main(String[] args) throws Exception { + syncBatchUpdateEntitiesStringListentitytypeentity(); + } + + public static void syncBatchUpdateEntitiesStringListentitytypeentity() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + List entities = new ArrayList<>(); + entityTypesClient.batchUpdateEntitiesAsync(parent, entities).get(); + } + } +} +// [END +// dialogflow_v2_generated_entitytypesclient_batchupdateentities_stringlistentitytypeentity_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentityString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentityString.java new file mode 100644 index 000000000000..ff7934557690 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentityString.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_entitytypesclient_batchupdateentities_stringlistentitytypeentitystring_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchUpdateEntitiesStringListentitytypeentityString { + + public static void main(String[] args) throws Exception { + syncBatchUpdateEntitiesStringListentitytypeentityString(); + } + + public static void syncBatchUpdateEntitiesStringListentitytypeentityString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + entityTypesClient.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + } + } +} +// [END +// dialogflow_v2_generated_entitytypesclient_batchupdateentities_stringlistentitytypeentitystring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypes.java new file mode 100644 index 000000000000..be6eaaaa3c92 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypes.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchupdateentitytypes_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchUpdateEntityTypesRequest; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncBatchUpdateEntityTypes { + + public static void main(String[] args) throws Exception { + asyncBatchUpdateEntityTypes(); + } + + public static void asyncBatchUpdateEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchUpdateEntityTypesRequest request = + BatchUpdateEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + entityTypesClient.batchUpdateEntityTypesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchupdateentitytypes_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypesLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypesLRO.java new file mode 100644 index 000000000000..ade02d52bdbc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypesLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchupdateentitytypes_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchUpdateEntityTypesRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateEntityTypesResponse; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Struct; + +public class AsyncBatchUpdateEntityTypesLRO { + + public static void main(String[] args) throws Exception { + asyncBatchUpdateEntityTypesLRO(); + } + + public static void asyncBatchUpdateEntityTypesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchUpdateEntityTypesRequest request = + BatchUpdateEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + entityTypesClient.batchUpdateEntityTypesOperationCallable().futureCall(request); + // Do something. + BatchUpdateEntityTypesResponse response = future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchupdateentitytypes_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentitytypes/SyncBatchUpdateEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentitytypes/SyncBatchUpdateEntityTypes.java new file mode 100644 index 000000000000..987d5325dd3b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/batchupdateentitytypes/SyncBatchUpdateEntityTypes.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_batchupdateentitytypes_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchUpdateEntityTypesRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateEntityTypesResponse; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.protobuf.FieldMask; + +public class SyncBatchUpdateEntityTypes { + + public static void main(String[] args) throws Exception { + syncBatchUpdateEntityTypes(); + } + + public static void syncBatchUpdateEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchUpdateEntityTypesRequest request = + BatchUpdateEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + BatchUpdateEntityTypesResponse response = + entityTypesClient.batchUpdateEntityTypesAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_batchupdateentitytypes_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..ccb7cd0e3e37 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.cloud.dialogflow.v2.EntityTypesSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EntityTypesSettings entityTypesSettings = + EntityTypesSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + EntityTypesClient entityTypesClient = EntityTypesClient.create(entityTypesSettings); + } +} +// [END dialogflow_v2_generated_entitytypesclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..829ce0b69765 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.cloud.dialogflow.v2.EntityTypesSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EntityTypesSettings entityTypesSettings = + EntityTypesSettings.newBuilder() + .setTransportChannelProvider( + EntityTypesSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + EntityTypesClient entityTypesClient = EntityTypesClient.create(entityTypesSettings); + } +} +// [END dialogflow_v2_generated_entitytypesclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..fb6214934bff --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.cloud.dialogflow.v2.EntityTypesSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EntityTypesSettings entityTypesSettings = + EntityTypesSettings.newBuilder().setEndpoint(myEndpoint).build(); + EntityTypesClient entityTypesClient = EntityTypesClient.create(entityTypesSettings); + } +} +// [END dialogflow_v2_generated_entitytypesclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/AsyncCreateEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/AsyncCreateEntityType.java new file mode 100644 index 000000000000..815a113f69bb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/AsyncCreateEntityType.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_createentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.CreateEntityTypeRequest; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class AsyncCreateEntityType { + + public static void main(String[] args) throws Exception { + asyncCreateEntityType(); + } + + public static void asyncCreateEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + CreateEntityTypeRequest request = + CreateEntityTypeRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setEntityType(EntityType.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .build(); + ApiFuture future = + entityTypesClient.createEntityTypeCallable().futureCall(request); + // Do something. + EntityType response = future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_createentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityType.java new file mode 100644 index 000000000000..9fe3515267e9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityType.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_createentitytype_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.CreateEntityTypeRequest; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncCreateEntityType { + + public static void main(String[] args) throws Exception { + syncCreateEntityType(); + } + + public static void syncCreateEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + CreateEntityTypeRequest request = + CreateEntityTypeRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setEntityType(EntityType.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .build(); + EntityType response = entityTypesClient.createEntityType(request); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_createentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytype.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytype.java new file mode 100644 index 000000000000..cad7460b1241 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytype.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_createentitytype_agentnameentitytype_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncCreateEntityTypeAgentnameEntitytype { + + public static void main(String[] args) throws Exception { + syncCreateEntityTypeAgentnameEntitytype(); + } + + public static void syncCreateEntityTypeAgentnameEntitytype() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + EntityType response = entityTypesClient.createEntityType(parent, entityType); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_createentitytype_agentnameentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytypeString.java new file mode 100644 index 000000000000..546b27c6926f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytypeString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_createentitytype_agentnameentitytypestring_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncCreateEntityTypeAgentnameEntitytypeString { + + public static void main(String[] args) throws Exception { + syncCreateEntityTypeAgentnameEntitytypeString(); + } + + public static void syncCreateEntityTypeAgentnameEntitytypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + EntityType response = entityTypesClient.createEntityType(parent, entityType, languageCode); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_createentitytype_agentnameentitytypestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytype.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytype.java new file mode 100644 index 000000000000..59fe9121eff8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytype.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_createentitytype_stringentitytype_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncCreateEntityTypeStringEntitytype { + + public static void main(String[] args) throws Exception { + syncCreateEntityTypeStringEntitytype(); + } + + public static void syncCreateEntityTypeStringEntitytype() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + EntityType entityType = EntityType.newBuilder().build(); + EntityType response = entityTypesClient.createEntityType(parent, entityType); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_createentitytype_stringentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytypeString.java new file mode 100644 index 000000000000..5461ba8dfd94 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytypeString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_createentitytype_stringentitytypestring_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncCreateEntityTypeStringEntitytypeString { + + public static void main(String[] args) throws Exception { + syncCreateEntityTypeStringEntitytypeString(); + } + + public static void syncCreateEntityTypeStringEntitytypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + EntityType response = entityTypesClient.createEntityType(parent, entityType, languageCode); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_createentitytype_stringentitytypestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/AsyncDeleteEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/AsyncDeleteEntityType.java new file mode 100644 index 000000000000..066c248e4f28 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/AsyncDeleteEntityType.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_deleteentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.DeleteEntityTypeRequest; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteEntityType { + + public static void main(String[] args) throws Exception { + asyncDeleteEntityType(); + } + + public static void asyncDeleteEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + DeleteEntityTypeRequest request = + DeleteEntityTypeRequest.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .build(); + ApiFuture future = entityTypesClient.deleteEntityTypeCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_deleteentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/SyncDeleteEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/SyncDeleteEntityType.java new file mode 100644 index 000000000000..79cd7701923a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/SyncDeleteEntityType.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_deleteentitytype_sync] +import com.google.cloud.dialogflow.v2.DeleteEntityTypeRequest; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncDeleteEntityType { + + public static void main(String[] args) throws Exception { + syncDeleteEntityType(); + } + + public static void syncDeleteEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + DeleteEntityTypeRequest request = + DeleteEntityTypeRequest.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .build(); + entityTypesClient.deleteEntityType(request); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_deleteentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeEntitytypename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeEntitytypename.java new file mode 100644 index 000000000000..aeba3f1d4e57 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeEntitytypename.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_deleteentitytype_entitytypename_sync] +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncDeleteEntityTypeEntitytypename { + + public static void main(String[] args) throws Exception { + syncDeleteEntityTypeEntitytypename(); + } + + public static void syncDeleteEntityTypeEntitytypename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + entityTypesClient.deleteEntityType(name); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_deleteentitytype_entitytypename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeString.java new file mode 100644 index 000000000000..ad1045139079 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_deleteentitytype_string_sync] +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncDeleteEntityTypeString { + + public static void main(String[] args) throws Exception { + syncDeleteEntityTypeString(); + } + + public static void syncDeleteEntityTypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + entityTypesClient.deleteEntityType(name); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_deleteentitytype_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/AsyncGetEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/AsyncGetEntityType.java new file mode 100644 index 000000000000..e65874839fe5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/AsyncGetEntityType.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_getentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.cloud.dialogflow.v2.GetEntityTypeRequest; + +public class AsyncGetEntityType { + + public static void main(String[] args) throws Exception { + asyncGetEntityType(); + } + + public static void asyncGetEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + GetEntityTypeRequest request = + GetEntityTypeRequest.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setLanguageCode("languageCode-2092349083") + .build(); + ApiFuture future = entityTypesClient.getEntityTypeCallable().futureCall(request); + // Do something. + EntityType response = future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_getentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityType.java new file mode 100644 index 000000000000..11a2db60f1b5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityType.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_getentitytype_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.cloud.dialogflow.v2.GetEntityTypeRequest; + +public class SyncGetEntityType { + + public static void main(String[] args) throws Exception { + syncGetEntityType(); + } + + public static void syncGetEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + GetEntityTypeRequest request = + GetEntityTypeRequest.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setLanguageCode("languageCode-2092349083") + .build(); + EntityType response = entityTypesClient.getEntityType(request); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_getentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypename.java new file mode 100644 index 000000000000..5cc9b8c479ac --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypename.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_getentitytype_entitytypename_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncGetEntityTypeEntitytypename { + + public static void main(String[] args) throws Exception { + syncGetEntityTypeEntitytypename(); + } + + public static void syncGetEntityTypeEntitytypename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + EntityType response = entityTypesClient.getEntityType(name); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_getentitytype_entitytypename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypenameString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypenameString.java new file mode 100644 index 000000000000..1d1686d89d6d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypenameString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_getentitytype_entitytypenamestring_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncGetEntityTypeEntitytypenameString { + + public static void main(String[] args) throws Exception { + syncGetEntityTypeEntitytypenameString(); + } + + public static void syncGetEntityTypeEntitytypenameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + String languageCode = "languageCode-2092349083"; + EntityType response = entityTypesClient.getEntityType(name, languageCode); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_getentitytype_entitytypenamestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeString.java new file mode 100644 index 000000000000..1d22abe2fead --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_getentitytype_string_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncGetEntityTypeString { + + public static void main(String[] args) throws Exception { + syncGetEntityTypeString(); + } + + public static void syncGetEntityTypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + EntityType response = entityTypesClient.getEntityType(name); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_getentitytype_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeStringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeStringString.java new file mode 100644 index 000000000000..a705710bb3c6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/getentitytype/SyncGetEntityTypeStringString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_getentitytype_stringstring_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypeName; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncGetEntityTypeStringString { + + public static void main(String[] args) throws Exception { + syncGetEntityTypeStringString(); + } + + public static void syncGetEntityTypeStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + String languageCode = "languageCode-2092349083"; + EntityType response = entityTypesClient.getEntityType(name, languageCode); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_getentitytype_stringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/AsyncListEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/AsyncListEntityTypes.java new file mode 100644 index 000000000000..7cf37d723308 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/AsyncListEntityTypes.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_listentitytypes_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.cloud.dialogflow.v2.ListEntityTypesRequest; + +public class AsyncListEntityTypes { + + public static void main(String[] args) throws Exception { + asyncListEntityTypes(); + } + + public static void asyncListEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + ListEntityTypesRequest request = + ListEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + entityTypesClient.listEntityTypesPagedCallable().futureCall(request); + // Do something. + for (EntityType element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_listentitytypes_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/AsyncListEntityTypesPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/AsyncListEntityTypesPaged.java new file mode 100644 index 000000000000..5eaa7db6d406 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/AsyncListEntityTypesPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_listentitytypes_paged_async] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.cloud.dialogflow.v2.ListEntityTypesRequest; +import com.google.cloud.dialogflow.v2.ListEntityTypesResponse; +import com.google.common.base.Strings; + +public class AsyncListEntityTypesPaged { + + public static void main(String[] args) throws Exception { + asyncListEntityTypesPaged(); + } + + public static void asyncListEntityTypesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + ListEntityTypesRequest request = + ListEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .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; + } + } + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_listentitytypes_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypes.java new file mode 100644 index 000000000000..ddcaefa56c5b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypes.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_listentitytypes_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.cloud.dialogflow.v2.ListEntityTypesRequest; + +public class SyncListEntityTypes { + + public static void main(String[] args) throws Exception { + syncListEntityTypes(); + } + + public static void syncListEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + ListEntityTypesRequest request = + ListEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (EntityType element : entityTypesClient.listEntityTypes(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_listentitytypes_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesAgentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesAgentname.java new file mode 100644 index 000000000000..c6ab599f7820 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesAgentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_listentitytypes_agentname_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncListEntityTypesAgentname { + + public static void main(String[] args) throws Exception { + syncListEntityTypesAgentname(); + } + + public static void syncListEntityTypesAgentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + for (EntityType element : entityTypesClient.listEntityTypes(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_listentitytypes_agentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesAgentnameString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesAgentnameString.java new file mode 100644 index 000000000000..a1f8adc55a65 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesAgentnameString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_listentitytypes_agentnamestring_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncListEntityTypesAgentnameString { + + public static void main(String[] args) throws Exception { + syncListEntityTypesAgentnameString(); + } + + public static void syncListEntityTypesAgentnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String languageCode = "languageCode-2092349083"; + for (EntityType element : + entityTypesClient.listEntityTypes(parent, languageCode).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_listentitytypes_agentnamestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesString.java new file mode 100644 index 000000000000..ce985428c21f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_listentitytypes_string_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncListEntityTypesString { + + public static void main(String[] args) throws Exception { + syncListEntityTypesString(); + } + + public static void syncListEntityTypesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + for (EntityType element : entityTypesClient.listEntityTypes(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_listentitytypes_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesStringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesStringString.java new file mode 100644 index 000000000000..d8d35472fdef --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/listentitytypes/SyncListEntityTypesStringString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_listentitytypes_stringstring_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncListEntityTypesStringString { + + public static void main(String[] args) throws Exception { + syncListEntityTypesStringString(); + } + + public static void syncListEntityTypesStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + String languageCode = "languageCode-2092349083"; + for (EntityType element : + entityTypesClient.listEntityTypes(parent, languageCode).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_listentitytypes_stringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/AsyncUpdateEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/AsyncUpdateEntityType.java new file mode 100644 index 000000000000..a305ee07d096 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/AsyncUpdateEntityType.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_updateentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.cloud.dialogflow.v2.UpdateEntityTypeRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateEntityType { + + public static void main(String[] args) throws Exception { + asyncUpdateEntityType(); + } + + public static void asyncUpdateEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + UpdateEntityTypeRequest request = + UpdateEntityTypeRequest.newBuilder() + .setEntityType(EntityType.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + entityTypesClient.updateEntityTypeCallable().futureCall(request); + // Do something. + EntityType response = future.get(); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_updateentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/SyncUpdateEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/SyncUpdateEntityType.java new file mode 100644 index 000000000000..ed90e112c2fc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/SyncUpdateEntityType.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_updateentitytype_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; +import com.google.cloud.dialogflow.v2.UpdateEntityTypeRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateEntityType { + + public static void main(String[] args) throws Exception { + syncUpdateEntityType(); + } + + public static void syncUpdateEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + UpdateEntityTypeRequest request = + UpdateEntityTypeRequest.newBuilder() + .setEntityType(EntityType.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + EntityType response = entityTypesClient.updateEntityType(request); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_updateentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytype.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytype.java new file mode 100644 index 000000000000..1ccd78867b18 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytype.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_updateentitytype_entitytype_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncUpdateEntityTypeEntitytype { + + public static void main(String[] args) throws Exception { + syncUpdateEntityTypeEntitytype(); + } + + public static void syncUpdateEntityTypeEntitytype() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityType entityType = EntityType.newBuilder().build(); + EntityType response = entityTypesClient.updateEntityType(entityType); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_updateentitytype_entitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytypeString.java new file mode 100644 index 000000000000..cf8a0f24a9c1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytypeString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesclient_updateentitytype_entitytypestring_sync] +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.EntityTypesClient; + +public class SyncUpdateEntityTypeEntitytypeString { + + public static void main(String[] args) throws Exception { + syncUpdateEntityTypeEntitytypeString(); + } + + public static void syncUpdateEntityTypeEntitytypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + EntityType response = entityTypesClient.updateEntityType(entityType, languageCode); + } + } +} +// [END dialogflow_v2_generated_entitytypesclient_updateentitytype_entitytypestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypessettings/getentitytype/SyncGetEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypessettings/getentitytype/SyncGetEntityType.java new file mode 100644 index 000000000000..1194df5e992c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/entitytypessettings/getentitytype/SyncGetEntityType.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypessettings_getentitytype_sync] +import com.google.cloud.dialogflow.v2.EntityTypesSettings; +import java.time.Duration; + +public class SyncGetEntityType { + + public static void main(String[] args) throws Exception { + syncGetEntityType(); + } + + public static void syncGetEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EntityTypesSettings.Builder entityTypesSettingsBuilder = EntityTypesSettings.newBuilder(); + entityTypesSettingsBuilder + .getEntityTypeSettings() + .setRetrySettings( + entityTypesSettingsBuilder + .getEntityTypeSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + EntityTypesSettings entityTypesSettings = entityTypesSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_entitytypessettings_getentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..0355dc149239 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.cloud.dialogflow.v2.EnvironmentsSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsSettings environmentsSettings = + EnvironmentsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); + } +} +// [END dialogflow_v2_generated_environmentsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..64c745bf6630 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.cloud.dialogflow.v2.EnvironmentsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsSettings environmentsSettings = + EnvironmentsSettings.newBuilder() + .setTransportChannelProvider( + EnvironmentsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); + } +} +// [END dialogflow_v2_generated_environmentsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..00bd2bd94526 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.cloud.dialogflow.v2.EnvironmentsSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsSettings environmentsSettings = + EnvironmentsSettings.newBuilder().setEndpoint(myEndpoint).build(); + EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); + } +} +// [END dialogflow_v2_generated_environmentsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/createenvironment/AsyncCreateEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/createenvironment/AsyncCreateEnvironment.java new file mode 100644 index 000000000000..7fffa49f6eae --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/createenvironment/AsyncCreateEnvironment.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_createenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.CreateEnvironmentRequest; +import com.google.cloud.dialogflow.v2.Environment; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; + +public class AsyncCreateEnvironment { + + public static void main(String[] args) throws Exception { + asyncCreateEnvironment(); + } + + public static void asyncCreateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setEnvironment(Environment.newBuilder().build()) + .setEnvironmentId("environmentId-950205810") + .build(); + ApiFuture future = + environmentsClient.createEnvironmentCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END dialogflow_v2_generated_environmentsclient_createenvironment_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/createenvironment/SyncCreateEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/createenvironment/SyncCreateEnvironment.java new file mode 100644 index 000000000000..2ba0ad4125a7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/createenvironment/SyncCreateEnvironment.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_createenvironment_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.CreateEnvironmentRequest; +import com.google.cloud.dialogflow.v2.Environment; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; + +public class SyncCreateEnvironment { + + public static void main(String[] args) throws Exception { + syncCreateEnvironment(); + } + + public static void syncCreateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setEnvironment(Environment.newBuilder().build()) + .setEnvironmentId("environmentId-950205810") + .build(); + Environment response = environmentsClient.createEnvironment(request); + } + } +} +// [END dialogflow_v2_generated_environmentsclient_createenvironment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.java new file mode 100644 index 000000000000..eaf503c01eea --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_deleteenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.DeleteEnvironmentRequest; +import com.google.cloud.dialogflow.v2.EnvironmentName; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteEnvironment { + + public static void main(String[] args) throws Exception { + asyncDeleteEnvironment(); + } + + public static void asyncDeleteEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + ApiFuture future = environmentsClient.deleteEnvironmentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_environmentsclient_deleteenvironment_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/deleteenvironment/SyncDeleteEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/deleteenvironment/SyncDeleteEnvironment.java new file mode 100644 index 000000000000..ae664ba02cfd --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/deleteenvironment/SyncDeleteEnvironment.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_deleteenvironment_sync] +import com.google.cloud.dialogflow.v2.DeleteEnvironmentRequest; +import com.google.cloud.dialogflow.v2.EnvironmentName; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; + +public class SyncDeleteEnvironment { + + public static void main(String[] args) throws Exception { + syncDeleteEnvironment(); + } + + public static void syncDeleteEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + environmentsClient.deleteEnvironment(request); + } + } +} +// [END dialogflow_v2_generated_environmentsclient_deleteenvironment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironment/AsyncGetEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironment/AsyncGetEnvironment.java new file mode 100644 index 000000000000..0ecfdd6ea0bb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironment/AsyncGetEnvironment.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_getenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Environment; +import com.google.cloud.dialogflow.v2.EnvironmentName; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.cloud.dialogflow.v2.GetEnvironmentRequest; + +public class AsyncGetEnvironment { + + public static void main(String[] args) throws Exception { + asyncGetEnvironment(); + } + + public static void asyncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + ApiFuture future = + environmentsClient.getEnvironmentCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END dialogflow_v2_generated_environmentsclient_getenvironment_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironment/SyncGetEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironment/SyncGetEnvironment.java new file mode 100644 index 000000000000..64efeb551bae --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironment/SyncGetEnvironment.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_getenvironment_sync] +import com.google.cloud.dialogflow.v2.Environment; +import com.google.cloud.dialogflow.v2.EnvironmentName; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.cloud.dialogflow.v2.GetEnvironmentRequest; + +public class SyncGetEnvironment { + + public static void main(String[] args) throws Exception { + syncGetEnvironment(); + } + + public static void syncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + Environment response = environmentsClient.getEnvironment(request); + } + } +} +// [END dialogflow_v2_generated_environmentsclient_getenvironment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistory.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistory.java new file mode 100644 index 000000000000..f09a98b0b963 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistory.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_getenvironmenthistory_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.EnvironmentHistory; +import com.google.cloud.dialogflow.v2.EnvironmentName; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.cloud.dialogflow.v2.GetEnvironmentHistoryRequest; + +public class AsyncGetEnvironmentHistory { + + public static void main(String[] args) throws Exception { + asyncGetEnvironmentHistory(); + } + + public static void asyncGetEnvironmentHistory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentHistoryRequest request = + GetEnvironmentHistoryRequest.newBuilder() + .setParent( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + environmentsClient.getEnvironmentHistoryPagedCallable().futureCall(request); + // Do something. + for (EnvironmentHistory.Entry element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_environmentsclient_getenvironmenthistory_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistoryPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistoryPaged.java new file mode 100644 index 000000000000..ebef1202ebd5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistoryPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_getenvironmenthistory_paged_async] +import com.google.cloud.dialogflow.v2.EnvironmentHistory; +import com.google.cloud.dialogflow.v2.EnvironmentName; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.cloud.dialogflow.v2.GetEnvironmentHistoryRequest; +import com.google.common.base.Strings; + +public class AsyncGetEnvironmentHistoryPaged { + + public static void main(String[] args) throws Exception { + asyncGetEnvironmentHistoryPaged(); + } + + public static void asyncGetEnvironmentHistoryPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentHistoryRequest request = + GetEnvironmentHistoryRequest.newBuilder() + .setParent( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + EnvironmentHistory response = + environmentsClient.getEnvironmentHistoryCallable().call(request); + for (EnvironmentHistory.Entry element : response.getEntriesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2_generated_environmentsclient_getenvironmenthistory_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironmenthistory/SyncGetEnvironmentHistory.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironmenthistory/SyncGetEnvironmentHistory.java new file mode 100644 index 000000000000..ca57a72ae7cc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/getenvironmenthistory/SyncGetEnvironmentHistory.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_getenvironmenthistory_sync] +import com.google.cloud.dialogflow.v2.EnvironmentHistory; +import com.google.cloud.dialogflow.v2.EnvironmentName; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.cloud.dialogflow.v2.GetEnvironmentHistoryRequest; + +public class SyncGetEnvironmentHistory { + + public static void main(String[] args) throws Exception { + syncGetEnvironmentHistory(); + } + + public static void syncGetEnvironmentHistory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentHistoryRequest request = + GetEnvironmentHistoryRequest.newBuilder() + .setParent( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (EnvironmentHistory.Entry element : + environmentsClient.getEnvironmentHistory(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_environmentsclient_getenvironmenthistory_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/AsyncListEnvironments.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/AsyncListEnvironments.java new file mode 100644 index 000000000000..880ebc8d19b1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/AsyncListEnvironments.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_listenvironments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Environment; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.cloud.dialogflow.v2.ListEnvironmentsRequest; + +public class AsyncListEnvironments { + + public static void main(String[] args) throws Exception { + asyncListEnvironments(); + } + + public static void asyncListEnvironments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + ListEnvironmentsRequest request = + ListEnvironmentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + environmentsClient.listEnvironmentsPagedCallable().futureCall(request); + // Do something. + for (Environment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_environmentsclient_listenvironments_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.java new file mode 100644 index 000000000000..ca7ccd147e8c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_listenvironments_paged_async] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Environment; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.cloud.dialogflow.v2.ListEnvironmentsRequest; +import com.google.cloud.dialogflow.v2.ListEnvironmentsResponse; +import com.google.common.base.Strings; + +public class AsyncListEnvironmentsPaged { + + public static void main(String[] args) throws Exception { + asyncListEnvironmentsPaged(); + } + + public static void asyncListEnvironmentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + ListEnvironmentsRequest request = + ListEnvironmentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListEnvironmentsResponse response = + environmentsClient.listEnvironmentsCallable().call(request); + for (Environment element : response.getEnvironmentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2_generated_environmentsclient_listenvironments_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/SyncListEnvironments.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/SyncListEnvironments.java new file mode 100644 index 000000000000..19f5354ed6da --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/SyncListEnvironments.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_listenvironments_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Environment; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.cloud.dialogflow.v2.ListEnvironmentsRequest; + +public class SyncListEnvironments { + + public static void main(String[] args) throws Exception { + syncListEnvironments(); + } + + public static void syncListEnvironments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + ListEnvironmentsRequest request = + ListEnvironmentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Environment element : environmentsClient.listEnvironments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_environmentsclient_listenvironments_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/SyncListEnvironmentsAgentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/SyncListEnvironmentsAgentname.java new file mode 100644 index 000000000000..c2400cb157d5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/SyncListEnvironmentsAgentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_listenvironments_agentname_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Environment; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; + +public class SyncListEnvironmentsAgentname { + + public static void main(String[] args) throws Exception { + syncListEnvironmentsAgentname(); + } + + public static void syncListEnvironmentsAgentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + for (Environment element : environmentsClient.listEnvironments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_environmentsclient_listenvironments_agentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/SyncListEnvironmentsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/SyncListEnvironmentsString.java new file mode 100644 index 000000000000..c42b3679c0e1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/listenvironments/SyncListEnvironmentsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_listenvironments_string_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Environment; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; + +public class SyncListEnvironmentsString { + + public static void main(String[] args) throws Exception { + syncListEnvironmentsString(); + } + + public static void syncListEnvironmentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + for (Environment element : environmentsClient.listEnvironments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_environmentsclient_listenvironments_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/updateenvironment/AsyncUpdateEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/updateenvironment/AsyncUpdateEnvironment.java new file mode 100644 index 000000000000..ce014173654c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/updateenvironment/AsyncUpdateEnvironment.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_updateenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Environment; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.cloud.dialogflow.v2.UpdateEnvironmentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateEnvironment { + + public static void main(String[] args) throws Exception { + asyncUpdateEnvironment(); + } + + public static void asyncUpdateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setEnvironment(Environment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowLoadToDraftAndDiscardChanges(true) + .build(); + ApiFuture future = + environmentsClient.updateEnvironmentCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END dialogflow_v2_generated_environmentsclient_updateenvironment_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/updateenvironment/SyncUpdateEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/updateenvironment/SyncUpdateEnvironment.java new file mode 100644 index 000000000000..ae63dca0ddac --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentsclient/updateenvironment/SyncUpdateEnvironment.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsclient_updateenvironment_sync] +import com.google.cloud.dialogflow.v2.Environment; +import com.google.cloud.dialogflow.v2.EnvironmentsClient; +import com.google.cloud.dialogflow.v2.UpdateEnvironmentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateEnvironment { + + public static void main(String[] args) throws Exception { + syncUpdateEnvironment(); + } + + public static void syncUpdateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setEnvironment(Environment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowLoadToDraftAndDiscardChanges(true) + .build(); + Environment response = environmentsClient.updateEnvironment(request); + } + } +} +// [END dialogflow_v2_generated_environmentsclient_updateenvironment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentssettings/getenvironment/SyncGetEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentssettings/getenvironment/SyncGetEnvironment.java new file mode 100644 index 000000000000..5b7969f6d49f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/environmentssettings/getenvironment/SyncGetEnvironment.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentssettings_getenvironment_sync] +import com.google.cloud.dialogflow.v2.EnvironmentsSettings; +import java.time.Duration; + +public class SyncGetEnvironment { + + public static void main(String[] args) throws Exception { + syncGetEnvironment(); + } + + public static void syncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsSettings.Builder environmentsSettingsBuilder = EnvironmentsSettings.newBuilder(); + environmentsSettingsBuilder + .getEnvironmentSettings() + .setRetrySettings( + environmentsSettingsBuilder + .getEnvironmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + EnvironmentsSettings environmentsSettings = environmentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_environmentssettings_getenvironment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..de36d6cdca0b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_fulfillmentsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.FulfillmentsClient; +import com.google.cloud.dialogflow.v2.FulfillmentsSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + FulfillmentsSettings fulfillmentsSettings = + FulfillmentsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create(fulfillmentsSettings); + } +} +// [END dialogflow_v2_generated_fulfillmentsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..6c3eb9bca1e4 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_fulfillmentsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.FulfillmentsClient; +import com.google.cloud.dialogflow.v2.FulfillmentsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + FulfillmentsSettings fulfillmentsSettings = + FulfillmentsSettings.newBuilder() + .setTransportChannelProvider( + FulfillmentsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create(fulfillmentsSettings); + } +} +// [END dialogflow_v2_generated_fulfillmentsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..f11035583163 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_fulfillmentsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.FulfillmentsClient; +import com.google.cloud.dialogflow.v2.FulfillmentsSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + FulfillmentsSettings fulfillmentsSettings = + FulfillmentsSettings.newBuilder().setEndpoint(myEndpoint).build(); + FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create(fulfillmentsSettings); + } +} +// [END dialogflow_v2_generated_fulfillmentsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/AsyncGetFulfillment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/AsyncGetFulfillment.java new file mode 100644 index 000000000000..1c8ea5a5bc31 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/AsyncGetFulfillment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_fulfillmentsclient_getfulfillment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Fulfillment; +import com.google.cloud.dialogflow.v2.FulfillmentName; +import com.google.cloud.dialogflow.v2.FulfillmentsClient; +import com.google.cloud.dialogflow.v2.GetFulfillmentRequest; + +public class AsyncGetFulfillment { + + public static void main(String[] args) throws Exception { + asyncGetFulfillment(); + } + + public static void asyncGetFulfillment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + GetFulfillmentRequest request = + GetFulfillmentRequest.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .build(); + ApiFuture future = + fulfillmentsClient.getFulfillmentCallable().futureCall(request); + // Do something. + Fulfillment response = future.get(); + } + } +} +// [END dialogflow_v2_generated_fulfillmentsclient_getfulfillment_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/SyncGetFulfillment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/SyncGetFulfillment.java new file mode 100644 index 000000000000..6c663eebefab --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/SyncGetFulfillment.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_fulfillmentsclient_getfulfillment_sync] +import com.google.cloud.dialogflow.v2.Fulfillment; +import com.google.cloud.dialogflow.v2.FulfillmentName; +import com.google.cloud.dialogflow.v2.FulfillmentsClient; +import com.google.cloud.dialogflow.v2.GetFulfillmentRequest; + +public class SyncGetFulfillment { + + public static void main(String[] args) throws Exception { + syncGetFulfillment(); + } + + public static void syncGetFulfillment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + GetFulfillmentRequest request = + GetFulfillmentRequest.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .build(); + Fulfillment response = fulfillmentsClient.getFulfillment(request); + } + } +} +// [END dialogflow_v2_generated_fulfillmentsclient_getfulfillment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/SyncGetFulfillmentFulfillmentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/SyncGetFulfillmentFulfillmentname.java new file mode 100644 index 000000000000..43366dd601ee --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/SyncGetFulfillmentFulfillmentname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_fulfillmentsclient_getfulfillment_fulfillmentname_sync] +import com.google.cloud.dialogflow.v2.Fulfillment; +import com.google.cloud.dialogflow.v2.FulfillmentName; +import com.google.cloud.dialogflow.v2.FulfillmentsClient; + +public class SyncGetFulfillmentFulfillmentname { + + public static void main(String[] args) throws Exception { + syncGetFulfillmentFulfillmentname(); + } + + public static void syncGetFulfillmentFulfillmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + FulfillmentName name = FulfillmentName.ofProjectName("[PROJECT]"); + Fulfillment response = fulfillmentsClient.getFulfillment(name); + } + } +} +// [END dialogflow_v2_generated_fulfillmentsclient_getfulfillment_fulfillmentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/SyncGetFulfillmentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/SyncGetFulfillmentString.java new file mode 100644 index 000000000000..e83a51e33d67 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/getfulfillment/SyncGetFulfillmentString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_fulfillmentsclient_getfulfillment_string_sync] +import com.google.cloud.dialogflow.v2.Fulfillment; +import com.google.cloud.dialogflow.v2.FulfillmentName; +import com.google.cloud.dialogflow.v2.FulfillmentsClient; + +public class SyncGetFulfillmentString { + + public static void main(String[] args) throws Exception { + syncGetFulfillmentString(); + } + + public static void syncGetFulfillmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + String name = FulfillmentName.ofProjectName("[PROJECT]").toString(); + Fulfillment response = fulfillmentsClient.getFulfillment(name); + } + } +} +// [END dialogflow_v2_generated_fulfillmentsclient_getfulfillment_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/updatefulfillment/AsyncUpdateFulfillment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/updatefulfillment/AsyncUpdateFulfillment.java new file mode 100644 index 000000000000..8527b5cbee1a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/updatefulfillment/AsyncUpdateFulfillment.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_fulfillmentsclient_updatefulfillment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Fulfillment; +import com.google.cloud.dialogflow.v2.FulfillmentsClient; +import com.google.cloud.dialogflow.v2.UpdateFulfillmentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateFulfillment { + + public static void main(String[] args) throws Exception { + asyncUpdateFulfillment(); + } + + public static void asyncUpdateFulfillment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + UpdateFulfillmentRequest request = + UpdateFulfillmentRequest.newBuilder() + .setFulfillment(Fulfillment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + fulfillmentsClient.updateFulfillmentCallable().futureCall(request); + // Do something. + Fulfillment response = future.get(); + } + } +} +// [END dialogflow_v2_generated_fulfillmentsclient_updatefulfillment_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillment.java new file mode 100644 index 000000000000..782f5f649cfe --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillment.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_fulfillmentsclient_updatefulfillment_sync] +import com.google.cloud.dialogflow.v2.Fulfillment; +import com.google.cloud.dialogflow.v2.FulfillmentsClient; +import com.google.cloud.dialogflow.v2.UpdateFulfillmentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateFulfillment { + + public static void main(String[] args) throws Exception { + syncUpdateFulfillment(); + } + + public static void syncUpdateFulfillment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + UpdateFulfillmentRequest request = + UpdateFulfillmentRequest.newBuilder() + .setFulfillment(Fulfillment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Fulfillment response = fulfillmentsClient.updateFulfillment(request); + } + } +} +// [END dialogflow_v2_generated_fulfillmentsclient_updatefulfillment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillmentFulfillmentFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillmentFulfillmentFieldmask.java new file mode 100644 index 000000000000..b58f1f9ca838 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillmentFulfillmentFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_fulfillmentsclient_updatefulfillment_fulfillmentfieldmask_sync] +import com.google.cloud.dialogflow.v2.Fulfillment; +import com.google.cloud.dialogflow.v2.FulfillmentsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateFulfillmentFulfillmentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateFulfillmentFulfillmentFieldmask(); + } + + public static void syncUpdateFulfillmentFulfillmentFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + Fulfillment fulfillment = Fulfillment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Fulfillment response = fulfillmentsClient.updateFulfillment(fulfillment, updateMask); + } + } +} +// [END dialogflow_v2_generated_fulfillmentsclient_updatefulfillment_fulfillmentfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentssettings/getfulfillment/SyncGetFulfillment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentssettings/getfulfillment/SyncGetFulfillment.java new file mode 100644 index 000000000000..9ba60883c117 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/fulfillmentssettings/getfulfillment/SyncGetFulfillment.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_fulfillmentssettings_getfulfillment_sync] +import com.google.cloud.dialogflow.v2.FulfillmentsSettings; +import java.time.Duration; + +public class SyncGetFulfillment { + + public static void main(String[] args) throws Exception { + syncGetFulfillment(); + } + + public static void syncGetFulfillment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + FulfillmentsSettings.Builder fulfillmentsSettingsBuilder = FulfillmentsSettings.newBuilder(); + fulfillmentsSettingsBuilder + .getFulfillmentSettings() + .setRetrySettings( + fulfillmentsSettingsBuilder + .getFulfillmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + FulfillmentsSettings fulfillmentsSettings = fulfillmentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_fulfillmentssettings_getfulfillment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/AsyncBatchDeleteIntents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/AsyncBatchDeleteIntents.java new file mode 100644 index 000000000000..631dac9213d2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/AsyncBatchDeleteIntents.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_batchdeleteintents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchDeleteIntentsRequest; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncBatchDeleteIntents { + + public static void main(String[] args) throws Exception { + asyncBatchDeleteIntents(); + } + + public static void asyncBatchDeleteIntents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + BatchDeleteIntentsRequest request = + BatchDeleteIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .addAllIntents(new ArrayList()) + .build(); + ApiFuture future = intentsClient.batchDeleteIntentsCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_batchdeleteintents_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/AsyncBatchDeleteIntentsLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/AsyncBatchDeleteIntentsLRO.java new file mode 100644 index 000000000000..4245c5877a74 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/AsyncBatchDeleteIntentsLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_batchdeleteintents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchDeleteIntentsRequest; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.util.ArrayList; + +public class AsyncBatchDeleteIntentsLRO { + + public static void main(String[] args) throws Exception { + asyncBatchDeleteIntentsLRO(); + } + + public static void asyncBatchDeleteIntentsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + BatchDeleteIntentsRequest request = + BatchDeleteIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .addAllIntents(new ArrayList()) + .build(); + OperationFuture future = + intentsClient.batchDeleteIntentsOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_batchdeleteintents_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/SyncBatchDeleteIntents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/SyncBatchDeleteIntents.java new file mode 100644 index 000000000000..5ce4bf20db44 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/SyncBatchDeleteIntents.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_batchdeleteintents_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchDeleteIntentsRequest; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; +import java.util.ArrayList; + +public class SyncBatchDeleteIntents { + + public static void main(String[] args) throws Exception { + syncBatchDeleteIntents(); + } + + public static void syncBatchDeleteIntents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + BatchDeleteIntentsRequest request = + BatchDeleteIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .addAllIntents(new ArrayList()) + .build(); + intentsClient.batchDeleteIntentsAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_batchdeleteintents_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsAgentnameListintent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsAgentnameListintent.java new file mode 100644 index 000000000000..be55ec61cd84 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsAgentnameListintent.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_batchdeleteintents_agentnamelistintent_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteIntentsAgentnameListintent { + + public static void main(String[] args) throws Exception { + syncBatchDeleteIntentsAgentnameListintent(); + } + + public static void syncBatchDeleteIntentsAgentnameListintent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + List intents = new ArrayList<>(); + intentsClient.batchDeleteIntentsAsync(parent, intents).get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_batchdeleteintents_agentnamelistintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsStringListintent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsStringListintent.java new file mode 100644 index 000000000000..8235400c31de --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsStringListintent.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_batchdeleteintents_stringlistintent_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteIntentsStringListintent { + + public static void main(String[] args) throws Exception { + syncBatchDeleteIntentsStringListintent(); + } + + public static void syncBatchDeleteIntentsStringListintent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + List intents = new ArrayList<>(); + intentsClient.batchDeleteIntentsAsync(parent, intents).get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_batchdeleteintents_stringlistintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/AsyncBatchUpdateIntents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/AsyncBatchUpdateIntents.java new file mode 100644 index 000000000000..115d6569d27a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/AsyncBatchUpdateIntents.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_batchupdateintents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsRequest; +import com.google.cloud.dialogflow.v2.IntentView; +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncBatchUpdateIntents { + + public static void main(String[] args) throws Exception { + asyncBatchUpdateIntents(); + } + + public static void asyncBatchUpdateIntents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + BatchUpdateIntentsRequest request = + BatchUpdateIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .setIntentView(IntentView.forNumber(0)) + .build(); + ApiFuture future = intentsClient.batchUpdateIntentsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_batchupdateintents_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/AsyncBatchUpdateIntentsLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/AsyncBatchUpdateIntentsLRO.java new file mode 100644 index 000000000000..5cfa2c484ba0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/AsyncBatchUpdateIntentsLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_batchupdateintents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2.IntentView; +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Struct; + +public class AsyncBatchUpdateIntentsLRO { + + public static void main(String[] args) throws Exception { + asyncBatchUpdateIntentsLRO(); + } + + public static void asyncBatchUpdateIntentsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + BatchUpdateIntentsRequest request = + BatchUpdateIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .setIntentView(IntentView.forNumber(0)) + .build(); + OperationFuture future = + intentsClient.batchUpdateIntentsOperationCallable().futureCall(request); + // Do something. + BatchUpdateIntentsResponse response = future.get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_batchupdateintents_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntents.java new file mode 100644 index 000000000000..b165d1c785e3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntents.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_batchupdateintents_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2.IntentView; +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.protobuf.FieldMask; + +public class SyncBatchUpdateIntents { + + public static void main(String[] args) throws Exception { + syncBatchUpdateIntents(); + } + + public static void syncBatchUpdateIntents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + BatchUpdateIntentsRequest request = + BatchUpdateIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .setIntentView(IntentView.forNumber(0)) + .build(); + BatchUpdateIntentsResponse response = intentsClient.batchUpdateIntentsAsync(request).get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_batchupdateintents_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameIntentbatch.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameIntentbatch.java new file mode 100644 index 000000000000..3eccd86935a1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameIntentbatch.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_batchupdateintents_agentnameintentbatch_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2.IntentBatch; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncBatchUpdateIntentsAgentnameIntentbatch { + + public static void main(String[] args) throws Exception { + syncBatchUpdateIntentsAgentnameIntentbatch(); + } + + public static void syncBatchUpdateIntentsAgentnameIntentbatch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + IntentBatch intentBatchInline = IntentBatch.newBuilder().build(); + BatchUpdateIntentsResponse response = + intentsClient.batchUpdateIntentsAsync(parent, intentBatchInline).get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_batchupdateintents_agentnameintentbatch_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameString.java new file mode 100644 index 000000000000..384f127cd30b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_batchupdateintents_agentnamestring_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncBatchUpdateIntentsAgentnameString { + + public static void main(String[] args) throws Exception { + syncBatchUpdateIntentsAgentnameString(); + } + + public static void syncBatchUpdateIntentsAgentnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String intentBatchUri = "intentBatchUri544125582"; + BatchUpdateIntentsResponse response = + intentsClient.batchUpdateIntentsAsync(parent, intentBatchUri).get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_batchupdateintents_agentnamestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringIntentbatch.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringIntentbatch.java new file mode 100644 index 000000000000..456d3f7f4792 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringIntentbatch.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_batchupdateintents_stringintentbatch_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2.IntentBatch; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncBatchUpdateIntentsStringIntentbatch { + + public static void main(String[] args) throws Exception { + syncBatchUpdateIntentsStringIntentbatch(); + } + + public static void syncBatchUpdateIntentsStringIntentbatch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + IntentBatch intentBatchInline = IntentBatch.newBuilder().build(); + BatchUpdateIntentsResponse response = + intentsClient.batchUpdateIntentsAsync(parent, intentBatchInline).get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_batchupdateintents_stringintentbatch_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringString.java new file mode 100644 index 000000000000..19f3af2077c8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_batchupdateintents_stringstring_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncBatchUpdateIntentsStringString { + + public static void main(String[] args) throws Exception { + syncBatchUpdateIntentsStringString(); + } + + public static void syncBatchUpdateIntentsStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + String intentBatchUri = "intentBatchUri544125582"; + BatchUpdateIntentsResponse response = + intentsClient.batchUpdateIntentsAsync(parent, intentBatchUri).get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_batchupdateintents_stringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..f9ef85fb3887 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.cloud.dialogflow.v2.IntentsSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + IntentsSettings intentsSettings = + IntentsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + IntentsClient intentsClient = IntentsClient.create(intentsSettings); + } +} +// [END dialogflow_v2_generated_intentsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..7239ac112a18 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.cloud.dialogflow.v2.IntentsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + IntentsSettings intentsSettings = + IntentsSettings.newBuilder() + .setTransportChannelProvider( + IntentsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + IntentsClient intentsClient = IntentsClient.create(intentsSettings); + } +} +// [END dialogflow_v2_generated_intentsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..a18840b517cb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,37 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.cloud.dialogflow.v2.IntentsSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + IntentsSettings intentsSettings = IntentsSettings.newBuilder().setEndpoint(myEndpoint).build(); + IntentsClient intentsClient = IntentsClient.create(intentsSettings); + } +} +// [END dialogflow_v2_generated_intentsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/AsyncCreateIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/AsyncCreateIntent.java new file mode 100644 index 000000000000..3e8cb9f07e5e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/AsyncCreateIntent.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_createintent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.CreateIntentRequest; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentView; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class AsyncCreateIntent { + + public static void main(String[] args) throws Exception { + asyncCreateIntent(); + } + + public static void asyncCreateIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + CreateIntentRequest request = + CreateIntentRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setIntent(Intent.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .build(); + ApiFuture future = intentsClient.createIntentCallable().futureCall(request); + // Do something. + Intent response = future.get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_createintent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntent.java new file mode 100644 index 000000000000..68c5424ddae6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntent.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_createintent_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.CreateIntentRequest; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentView; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncCreateIntent { + + public static void main(String[] args) throws Exception { + syncCreateIntent(); + } + + public static void syncCreateIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + CreateIntentRequest request = + CreateIntentRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setIntent(Intent.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .build(); + Intent response = intentsClient.createIntent(request); + } + } +} +// [END dialogflow_v2_generated_intentsclient_createintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentAgentnameIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentAgentnameIntent.java new file mode 100644 index 000000000000..ccd0dbc0fa79 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentAgentnameIntent.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_createintent_agentnameintent_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncCreateIntentAgentnameIntent { + + public static void main(String[] args) throws Exception { + syncCreateIntentAgentnameIntent(); + } + + public static void syncCreateIntentAgentnameIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + Intent response = intentsClient.createIntent(parent, intent); + } + } +} +// [END dialogflow_v2_generated_intentsclient_createintent_agentnameintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentAgentnameIntentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentAgentnameIntentString.java new file mode 100644 index 000000000000..2bf921cb0bfc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentAgentnameIntentString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_createintent_agentnameintentstring_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncCreateIntentAgentnameIntentString { + + public static void main(String[] args) throws Exception { + syncCreateIntentAgentnameIntentString(); + } + + public static void syncCreateIntentAgentnameIntentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + Intent response = intentsClient.createIntent(parent, intent, languageCode); + } + } +} +// [END dialogflow_v2_generated_intentsclient_createintent_agentnameintentstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentStringIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentStringIntent.java new file mode 100644 index 000000000000..ba3e518fb88e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentStringIntent.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_createintent_stringintent_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncCreateIntentStringIntent { + + public static void main(String[] args) throws Exception { + syncCreateIntentStringIntent(); + } + + public static void syncCreateIntentStringIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + Intent intent = Intent.newBuilder().build(); + Intent response = intentsClient.createIntent(parent, intent); + } + } +} +// [END dialogflow_v2_generated_intentsclient_createintent_stringintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentStringIntentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentStringIntentString.java new file mode 100644 index 000000000000..da236383cf8d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/createintent/SyncCreateIntentStringIntentString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_createintent_stringintentstring_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncCreateIntentStringIntentString { + + public static void main(String[] args) throws Exception { + syncCreateIntentStringIntentString(); + } + + public static void syncCreateIntentStringIntentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + Intent response = intentsClient.createIntent(parent, intent, languageCode); + } + } +} +// [END dialogflow_v2_generated_intentsclient_createintent_stringintentstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/AsyncDeleteIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/AsyncDeleteIntent.java new file mode 100644 index 000000000000..bc9c2ef290fb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/AsyncDeleteIntent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_deleteintent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.DeleteIntentRequest; +import com.google.cloud.dialogflow.v2.IntentName; +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteIntent { + + public static void main(String[] args) throws Exception { + asyncDeleteIntent(); + } + + public static void asyncDeleteIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + DeleteIntentRequest request = + DeleteIntentRequest.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .build(); + ApiFuture future = intentsClient.deleteIntentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_deleteintent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/SyncDeleteIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/SyncDeleteIntent.java new file mode 100644 index 000000000000..92ddea3a6543 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/SyncDeleteIntent.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_deleteintent_sync] +import com.google.cloud.dialogflow.v2.DeleteIntentRequest; +import com.google.cloud.dialogflow.v2.IntentName; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncDeleteIntent { + + public static void main(String[] args) throws Exception { + syncDeleteIntent(); + } + + public static void syncDeleteIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + DeleteIntentRequest request = + DeleteIntentRequest.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .build(); + intentsClient.deleteIntent(request); + } + } +} +// [END dialogflow_v2_generated_intentsclient_deleteintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/SyncDeleteIntentIntentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/SyncDeleteIntentIntentname.java new file mode 100644 index 000000000000..d046d4c96d81 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/SyncDeleteIntentIntentname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_deleteintent_intentname_sync] +import com.google.cloud.dialogflow.v2.IntentName; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncDeleteIntentIntentname { + + public static void main(String[] args) throws Exception { + syncDeleteIntentIntentname(); + } + + public static void syncDeleteIntentIntentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + intentsClient.deleteIntent(name); + } + } +} +// [END dialogflow_v2_generated_intentsclient_deleteintent_intentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/SyncDeleteIntentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/SyncDeleteIntentString.java new file mode 100644 index 000000000000..eee02b6d276f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/deleteintent/SyncDeleteIntentString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_deleteintent_string_sync] +import com.google.cloud.dialogflow.v2.IntentName; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncDeleteIntentString { + + public static void main(String[] args) throws Exception { + syncDeleteIntentString(); + } + + public static void syncDeleteIntentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString(); + intentsClient.deleteIntent(name); + } + } +} +// [END dialogflow_v2_generated_intentsclient_deleteintent_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/AsyncGetIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/AsyncGetIntent.java new file mode 100644 index 000000000000..1408422dff63 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/AsyncGetIntent.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_getintent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.GetIntentRequest; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentName; +import com.google.cloud.dialogflow.v2.IntentView; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class AsyncGetIntent { + + public static void main(String[] args) throws Exception { + asyncGetIntent(); + } + + public static void asyncGetIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + GetIntentRequest request = + GetIntentRequest.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .build(); + ApiFuture future = intentsClient.getIntentCallable().futureCall(request); + // Do something. + Intent response = future.get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_getintent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntent.java new file mode 100644 index 000000000000..b74e3ee709f6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_getintent_sync] +import com.google.cloud.dialogflow.v2.GetIntentRequest; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentName; +import com.google.cloud.dialogflow.v2.IntentView; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncGetIntent { + + public static void main(String[] args) throws Exception { + syncGetIntent(); + } + + public static void syncGetIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + GetIntentRequest request = + GetIntentRequest.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .build(); + Intent response = intentsClient.getIntent(request); + } + } +} +// [END dialogflow_v2_generated_intentsclient_getintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentIntentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentIntentname.java new file mode 100644 index 000000000000..465c9e2f7d07 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentIntentname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_getintent_intentname_sync] +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentName; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncGetIntentIntentname { + + public static void main(String[] args) throws Exception { + syncGetIntentIntentname(); + } + + public static void syncGetIntentIntentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + Intent response = intentsClient.getIntent(name); + } + } +} +// [END dialogflow_v2_generated_intentsclient_getintent_intentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentIntentnameString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentIntentnameString.java new file mode 100644 index 000000000000..64f84d6e7077 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentIntentnameString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_getintent_intentnamestring_sync] +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentName; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncGetIntentIntentnameString { + + public static void main(String[] args) throws Exception { + syncGetIntentIntentnameString(); + } + + public static void syncGetIntentIntentnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + String languageCode = "languageCode-2092349083"; + Intent response = intentsClient.getIntent(name, languageCode); + } + } +} +// [END dialogflow_v2_generated_intentsclient_getintent_intentnamestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentString.java new file mode 100644 index 000000000000..9f5f086470ca --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_getintent_string_sync] +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentName; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncGetIntentString { + + public static void main(String[] args) throws Exception { + syncGetIntentString(); + } + + public static void syncGetIntentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString(); + Intent response = intentsClient.getIntent(name); + } + } +} +// [END dialogflow_v2_generated_intentsclient_getintent_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentStringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentStringString.java new file mode 100644 index 000000000000..dd9d048e4229 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/getintent/SyncGetIntentStringString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_getintent_stringstring_sync] +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentName; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncGetIntentStringString { + + public static void main(String[] args) throws Exception { + syncGetIntentStringString(); + } + + public static void syncGetIntentStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString(); + String languageCode = "languageCode-2092349083"; + Intent response = intentsClient.getIntent(name, languageCode); + } + } +} +// [END dialogflow_v2_generated_intentsclient_getintent_stringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/AsyncListIntents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/AsyncListIntents.java new file mode 100644 index 000000000000..f3603499dc33 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/AsyncListIntents.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_listintents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentView; +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.cloud.dialogflow.v2.ListIntentsRequest; + +public class AsyncListIntents { + + public static void main(String[] args) throws Exception { + asyncListIntents(); + } + + public static void asyncListIntents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + ListIntentsRequest request = + ListIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = intentsClient.listIntentsPagedCallable().futureCall(request); + // Do something. + for (Intent element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_intentsclient_listintents_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/AsyncListIntentsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/AsyncListIntentsPaged.java new file mode 100644 index 000000000000..6c00d25da7ab --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/AsyncListIntentsPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_listintents_paged_async] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentView; +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.cloud.dialogflow.v2.ListIntentsRequest; +import com.google.cloud.dialogflow.v2.ListIntentsResponse; +import com.google.common.base.Strings; + +public class AsyncListIntentsPaged { + + public static void main(String[] args) throws Exception { + asyncListIntentsPaged(); + } + + public static void asyncListIntentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + ListIntentsRequest request = + ListIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .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; + } + } + } + } +} +// [END dialogflow_v2_generated_intentsclient_listintents_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntents.java new file mode 100644 index 000000000000..3f7135402314 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntents.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_listintents_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentView; +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.cloud.dialogflow.v2.ListIntentsRequest; + +public class SyncListIntents { + + public static void main(String[] args) throws Exception { + syncListIntents(); + } + + public static void syncListIntents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + ListIntentsRequest request = + ListIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Intent element : intentsClient.listIntents(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_intentsclient_listintents_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsAgentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsAgentname.java new file mode 100644 index 000000000000..2618139e5d15 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsAgentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_listintents_agentname_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncListIntentsAgentname { + + public static void main(String[] args) throws Exception { + syncListIntentsAgentname(); + } + + public static void syncListIntentsAgentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + for (Intent element : intentsClient.listIntents(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_intentsclient_listintents_agentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsAgentnameString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsAgentnameString.java new file mode 100644 index 000000000000..dc3b4921ba1c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsAgentnameString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_listintents_agentnamestring_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncListIntentsAgentnameString { + + public static void main(String[] args) throws Exception { + syncListIntentsAgentnameString(); + } + + public static void syncListIntentsAgentnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String languageCode = "languageCode-2092349083"; + for (Intent element : intentsClient.listIntents(parent, languageCode).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_intentsclient_listintents_agentnamestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsString.java new file mode 100644 index 000000000000..17a012fd33be --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_listintents_string_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncListIntentsString { + + public static void main(String[] args) throws Exception { + syncListIntentsString(); + } + + public static void syncListIntentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + for (Intent element : intentsClient.listIntents(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_intentsclient_listintents_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsStringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsStringString.java new file mode 100644 index 000000000000..cd6145ce92c0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/listintents/SyncListIntentsStringString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_listintents_stringstring_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncListIntentsStringString { + + public static void main(String[] args) throws Exception { + syncListIntentsStringString(); + } + + public static void syncListIntentsStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + String languageCode = "languageCode-2092349083"; + for (Intent element : intentsClient.listIntents(parent, languageCode).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_intentsclient_listintents_stringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/AsyncUpdateIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/AsyncUpdateIntent.java new file mode 100644 index 000000000000..cb27bb1dab06 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/AsyncUpdateIntent.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_updateintent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentView; +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.cloud.dialogflow.v2.UpdateIntentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateIntent { + + public static void main(String[] args) throws Exception { + asyncUpdateIntent(); + } + + public static void asyncUpdateIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + UpdateIntentRequest request = + UpdateIntentRequest.newBuilder() + .setIntent(Intent.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .setIntentView(IntentView.forNumber(0)) + .build(); + ApiFuture future = intentsClient.updateIntentCallable().futureCall(request); + // Do something. + Intent response = future.get(); + } + } +} +// [END dialogflow_v2_generated_intentsclient_updateintent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/SyncUpdateIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/SyncUpdateIntent.java new file mode 100644 index 000000000000..22dc72616e52 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/SyncUpdateIntent.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_updateintent_sync] +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentView; +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.cloud.dialogflow.v2.UpdateIntentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateIntent { + + public static void main(String[] args) throws Exception { + syncUpdateIntent(); + } + + public static void syncUpdateIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + UpdateIntentRequest request = + UpdateIntentRequest.newBuilder() + .setIntent(Intent.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .setIntentView(IntentView.forNumber(0)) + .build(); + Intent response = intentsClient.updateIntent(request); + } + } +} +// [END dialogflow_v2_generated_intentsclient_updateintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/SyncUpdateIntentIntentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/SyncUpdateIntentIntentString.java new file mode 100644 index 000000000000..f7ad67734471 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/SyncUpdateIntentIntentString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_updateintent_intentstring_sync] +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; + +public class SyncUpdateIntentIntentString { + + public static void main(String[] args) throws Exception { + syncUpdateIntentIntentString(); + } + + public static void syncUpdateIntentIntentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + Intent response = intentsClient.updateIntent(intent, languageCode); + } + } +} +// [END dialogflow_v2_generated_intentsclient_updateintent_intentstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/SyncUpdateIntentIntentStringFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/SyncUpdateIntentIntentStringFieldmask.java new file mode 100644 index 000000000000..9f7649e43286 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentsclient/updateintent/SyncUpdateIntentIntentStringFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsclient_updateintent_intentstringfieldmask_sync] +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.IntentsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateIntentIntentStringFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateIntentIntentStringFieldmask(); + } + + public static void syncUpdateIntentIntentStringFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + FieldMask updateMask = FieldMask.newBuilder().build(); + Intent response = intentsClient.updateIntent(intent, languageCode, updateMask); + } + } +} +// [END dialogflow_v2_generated_intentsclient_updateintent_intentstringfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentssettings/getintent/SyncGetIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentssettings/getintent/SyncGetIntent.java new file mode 100644 index 000000000000..f361ca85a07f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/intentssettings/getintent/SyncGetIntent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentssettings_getintent_sync] +import com.google.cloud.dialogflow.v2.IntentsSettings; +import java.time.Duration; + +public class SyncGetIntent { + + public static void main(String[] args) throws Exception { + syncGetIntent(); + } + + public static void syncGetIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + IntentsSettings.Builder intentsSettingsBuilder = IntentsSettings.newBuilder(); + intentsSettingsBuilder + .getIntentSettings() + .setRetrySettings( + intentsSettingsBuilder + .getIntentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + IntentsSettings intentsSettings = intentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_intentssettings_getintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..ef120c7ca808 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.KnowledgeBasesSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + KnowledgeBasesSettings knowledgeBasesSettings = + KnowledgeBasesSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create(knowledgeBasesSettings); + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..380994c56c04 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.KnowledgeBasesSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + KnowledgeBasesSettings knowledgeBasesSettings = + KnowledgeBasesSettings.newBuilder() + .setTransportChannelProvider( + KnowledgeBasesSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create(knowledgeBasesSettings); + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..fdb4f7359f95 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.KnowledgeBasesSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + KnowledgeBasesSettings knowledgeBasesSettings = + KnowledgeBasesSettings.newBuilder().setEndpoint(myEndpoint).build(); + KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create(knowledgeBasesSettings); + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/AsyncCreateKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/AsyncCreateKnowledgeBase.java new file mode 100644 index 000000000000..22c6d71e7bb5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/AsyncCreateKnowledgeBase.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_createknowledgebase_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.CreateKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class AsyncCreateKnowledgeBase { + + public static void main(String[] args) throws Exception { + asyncCreateKnowledgeBase(); + } + + public static void asyncCreateKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + CreateKnowledgeBaseRequest request = + CreateKnowledgeBaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setKnowledgeBase(KnowledgeBase.newBuilder().build()) + .build(); + ApiFuture future = + knowledgeBasesClient.createKnowledgeBaseCallable().futureCall(request); + // Do something. + KnowledgeBase response = future.get(); + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_createknowledgebase_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBase.java new file mode 100644 index 000000000000..6bc1863ea1a0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBase.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_createknowledgebase_sync] +import com.google.cloud.dialogflow.v2.CreateKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncCreateKnowledgeBase { + + public static void main(String[] args) throws Exception { + syncCreateKnowledgeBase(); + } + + public static void syncCreateKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + CreateKnowledgeBaseRequest request = + CreateKnowledgeBaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setKnowledgeBase(KnowledgeBase.newBuilder().build()) + .build(); + KnowledgeBase response = knowledgeBasesClient.createKnowledgeBase(request); + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_createknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseLocationnameKnowledgebase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseLocationnameKnowledgebase.java new file mode 100644 index 000000000000..3940a04b8f73 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseLocationnameKnowledgebase.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_knowledgebasesclient_createknowledgebase_locationnameknowledgebase_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncCreateKnowledgeBaseLocationnameKnowledgebase { + + public static void main(String[] args) throws Exception { + syncCreateKnowledgeBaseLocationnameKnowledgebase(); + } + + public static void syncCreateKnowledgeBaseLocationnameKnowledgebase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + KnowledgeBase response = knowledgeBasesClient.createKnowledgeBase(parent, knowledgeBase); + } + } +} +// [END +// dialogflow_v2_generated_knowledgebasesclient_createknowledgebase_locationnameknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseProjectnameKnowledgebase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseProjectnameKnowledgebase.java new file mode 100644 index 000000000000..a8fade69d938 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseProjectnameKnowledgebase.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_knowledgebasesclient_createknowledgebase_projectnameknowledgebase_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncCreateKnowledgeBaseProjectnameKnowledgebase { + + public static void main(String[] args) throws Exception { + syncCreateKnowledgeBaseProjectnameKnowledgebase(); + } + + public static void syncCreateKnowledgeBaseProjectnameKnowledgebase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + KnowledgeBase response = knowledgeBasesClient.createKnowledgeBase(parent, knowledgeBase); + } + } +} +// [END +// dialogflow_v2_generated_knowledgebasesclient_createknowledgebase_projectnameknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseStringKnowledgebase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseStringKnowledgebase.java new file mode 100644 index 000000000000..7f717581a727 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseStringKnowledgebase.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_createknowledgebase_stringknowledgebase_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncCreateKnowledgeBaseStringKnowledgebase { + + public static void main(String[] args) throws Exception { + syncCreateKnowledgeBaseStringKnowledgebase(); + } + + public static void syncCreateKnowledgeBaseStringKnowledgebase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + KnowledgeBase response = knowledgeBasesClient.createKnowledgeBase(parent, knowledgeBase); + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_createknowledgebase_stringknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/AsyncDeleteKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/AsyncDeleteKnowledgeBase.java new file mode 100644 index 000000000000..3a8cd6bd0544 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/AsyncDeleteKnowledgeBase.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_deleteknowledgebase_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.DeleteKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteKnowledgeBase { + + public static void main(String[] args) throws Exception { + asyncDeleteKnowledgeBase(); + } + + public static void asyncDeleteKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + DeleteKnowledgeBaseRequest request = + DeleteKnowledgeBaseRequest.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setForce(true) + .build(); + ApiFuture future = + knowledgeBasesClient.deleteKnowledgeBaseCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_deleteknowledgebase_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBase.java new file mode 100644 index 000000000000..f0eccf2bf69f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBase.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_deleteknowledgebase_sync] +import com.google.cloud.dialogflow.v2.DeleteKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; + +public class SyncDeleteKnowledgeBase { + + public static void main(String[] args) throws Exception { + syncDeleteKnowledgeBase(); + } + + public static void syncDeleteKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + DeleteKnowledgeBaseRequest request = + DeleteKnowledgeBaseRequest.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setForce(true) + .build(); + knowledgeBasesClient.deleteKnowledgeBase(request); + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_deleteknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseKnowledgebasename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseKnowledgebasename.java new file mode 100644 index 000000000000..d212a543df66 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseKnowledgebasename.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_deleteknowledgebase_knowledgebasename_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; + +public class SyncDeleteKnowledgeBaseKnowledgebasename { + + public static void main(String[] args) throws Exception { + syncDeleteKnowledgeBaseKnowledgebasename(); + } + + public static void syncDeleteKnowledgeBaseKnowledgebasename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + KnowledgeBaseName name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + knowledgeBasesClient.deleteKnowledgeBase(name); + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_deleteknowledgebase_knowledgebasename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseString.java new file mode 100644 index 000000000000..afe0bca29ab8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_deleteknowledgebase_string_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; + +public class SyncDeleteKnowledgeBaseString { + + public static void main(String[] args) throws Exception { + syncDeleteKnowledgeBaseString(); + } + + public static void syncDeleteKnowledgeBaseString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + String name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]").toString(); + knowledgeBasesClient.deleteKnowledgeBase(name); + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_deleteknowledgebase_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/AsyncGetKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/AsyncGetKnowledgeBase.java new file mode 100644 index 000000000000..69f6d3d1f4c1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/AsyncGetKnowledgeBase.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_getknowledgebase_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.GetKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; + +public class AsyncGetKnowledgeBase { + + public static void main(String[] args) throws Exception { + asyncGetKnowledgeBase(); + } + + public static void asyncGetKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + GetKnowledgeBaseRequest request = + GetKnowledgeBaseRequest.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .build(); + ApiFuture future = + knowledgeBasesClient.getKnowledgeBaseCallable().futureCall(request); + // Do something. + KnowledgeBase response = future.get(); + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_getknowledgebase_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBase.java new file mode 100644 index 000000000000..981b37c0d565 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBase.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_getknowledgebase_sync] +import com.google.cloud.dialogflow.v2.GetKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; + +public class SyncGetKnowledgeBase { + + public static void main(String[] args) throws Exception { + syncGetKnowledgeBase(); + } + + public static void syncGetKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + GetKnowledgeBaseRequest request = + GetKnowledgeBaseRequest.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .build(); + KnowledgeBase response = knowledgeBasesClient.getKnowledgeBase(request); + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_getknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseKnowledgebasename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseKnowledgebasename.java new file mode 100644 index 000000000000..8b1a584bd2d4 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseKnowledgebasename.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_getknowledgebase_knowledgebasename_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; + +public class SyncGetKnowledgeBaseKnowledgebasename { + + public static void main(String[] args) throws Exception { + syncGetKnowledgeBaseKnowledgebasename(); + } + + public static void syncGetKnowledgeBaseKnowledgebasename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + KnowledgeBaseName name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + KnowledgeBase response = knowledgeBasesClient.getKnowledgeBase(name); + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_getknowledgebase_knowledgebasename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseString.java new file mode 100644 index 000000000000..c53cfbe34a48 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_getknowledgebase_string_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; + +public class SyncGetKnowledgeBaseString { + + public static void main(String[] args) throws Exception { + syncGetKnowledgeBaseString(); + } + + public static void syncGetKnowledgeBaseString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + String name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]").toString(); + KnowledgeBase response = knowledgeBasesClient.getKnowledgeBase(name); + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_getknowledgebase_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBases.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBases.java new file mode 100644 index 000000000000..a36b341b7d7a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBases.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_listknowledgebases_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.ListKnowledgeBasesRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class AsyncListKnowledgeBases { + + public static void main(String[] args) throws Exception { + asyncListKnowledgeBases(); + } + + public static void asyncListKnowledgeBases() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + ListKnowledgeBasesRequest request = + ListKnowledgeBasesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + knowledgeBasesClient.listKnowledgeBasesPagedCallable().futureCall(request); + // Do something. + for (KnowledgeBase element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_listknowledgebases_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBasesPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBasesPaged.java new file mode 100644 index 000000000000..b9d7455576c0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBasesPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_listknowledgebases_paged_async] +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.ListKnowledgeBasesRequest; +import com.google.cloud.dialogflow.v2.ListKnowledgeBasesResponse; +import com.google.cloud.dialogflow.v2.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListKnowledgeBasesPaged { + + public static void main(String[] args) throws Exception { + asyncListKnowledgeBasesPaged(); + } + + public static void asyncListKnowledgeBasesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + ListKnowledgeBasesRequest request = + ListKnowledgeBasesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListKnowledgeBasesResponse response = + knowledgeBasesClient.listKnowledgeBasesCallable().call(request); + for (KnowledgeBase element : response.getKnowledgeBasesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_listknowledgebases_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBases.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBases.java new file mode 100644 index 000000000000..62852bb3797c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBases.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_listknowledgebases_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.ListKnowledgeBasesRequest; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncListKnowledgeBases { + + public static void main(String[] args) throws Exception { + syncListKnowledgeBases(); + } + + public static void syncListKnowledgeBases() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + ListKnowledgeBasesRequest request = + ListKnowledgeBasesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (KnowledgeBase element : knowledgeBasesClient.listKnowledgeBases(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_listknowledgebases_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesLocationname.java new file mode 100644 index 000000000000..9372cfcd7c4f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_listknowledgebases_locationname_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.LocationName; + +public class SyncListKnowledgeBasesLocationname { + + public static void main(String[] args) throws Exception { + syncListKnowledgeBasesLocationname(); + } + + public static void syncListKnowledgeBasesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (KnowledgeBase element : knowledgeBasesClient.listKnowledgeBases(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_listknowledgebases_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesProjectname.java new file mode 100644 index 000000000000..3603bcde56f6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesProjectname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_listknowledgebases_projectname_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncListKnowledgeBasesProjectname { + + public static void main(String[] args) throws Exception { + syncListKnowledgeBasesProjectname(); + } + + public static void syncListKnowledgeBasesProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (KnowledgeBase element : knowledgeBasesClient.listKnowledgeBases(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_listknowledgebases_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesString.java new file mode 100644 index 000000000000..93130b7df12c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_listknowledgebases_string_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.ProjectName; + +public class SyncListKnowledgeBasesString { + + public static void main(String[] args) throws Exception { + syncListKnowledgeBasesString(); + } + + public static void syncListKnowledgeBasesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (KnowledgeBase element : knowledgeBasesClient.listKnowledgeBases(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_listknowledgebases_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/updateknowledgebase/AsyncUpdateKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/updateknowledgebase/AsyncUpdateKnowledgeBase.java new file mode 100644 index 000000000000..e4a3e5b579b6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/updateknowledgebase/AsyncUpdateKnowledgeBase.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_updateknowledgebase_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.UpdateKnowledgeBaseRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateKnowledgeBase { + + public static void main(String[] args) throws Exception { + asyncUpdateKnowledgeBase(); + } + + public static void asyncUpdateKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + UpdateKnowledgeBaseRequest request = + UpdateKnowledgeBaseRequest.newBuilder() + .setKnowledgeBase(KnowledgeBase.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + knowledgeBasesClient.updateKnowledgeBaseCallable().futureCall(request); + // Do something. + KnowledgeBase response = future.get(); + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_updateknowledgebase_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBase.java new file mode 100644 index 000000000000..ec63875f26d1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBase.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesclient_updateknowledgebase_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2.UpdateKnowledgeBaseRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateKnowledgeBase { + + public static void main(String[] args) throws Exception { + syncUpdateKnowledgeBase(); + } + + public static void syncUpdateKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + UpdateKnowledgeBaseRequest request = + UpdateKnowledgeBaseRequest.newBuilder() + .setKnowledgeBase(KnowledgeBase.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + KnowledgeBase response = knowledgeBasesClient.updateKnowledgeBase(request); + } + } +} +// [END dialogflow_v2_generated_knowledgebasesclient_updateknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBaseKnowledgebaseFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBaseKnowledgebaseFieldmask.java new file mode 100644 index 000000000000..c02cd0348996 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBaseKnowledgebaseFieldmask.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_knowledgebasesclient_updateknowledgebase_knowledgebasefieldmask_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBase; +import com.google.cloud.dialogflow.v2.KnowledgeBasesClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateKnowledgeBaseKnowledgebaseFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateKnowledgeBaseKnowledgebaseFieldmask(); + } + + public static void syncUpdateKnowledgeBaseKnowledgebaseFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + KnowledgeBase response = knowledgeBasesClient.updateKnowledgeBase(knowledgeBase, updateMask); + } + } +} +// [END +// dialogflow_v2_generated_knowledgebasesclient_updateknowledgebase_knowledgebasefieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasessettings/getknowledgebase/SyncGetKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasessettings/getknowledgebase/SyncGetKnowledgeBase.java new file mode 100644 index 000000000000..f03bf693be62 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/knowledgebasessettings/getknowledgebase/SyncGetKnowledgeBase.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasessettings_getknowledgebase_sync] +import com.google.cloud.dialogflow.v2.KnowledgeBasesSettings; +import java.time.Duration; + +public class SyncGetKnowledgeBase { + + public static void main(String[] args) throws Exception { + syncGetKnowledgeBase(); + } + + public static void syncGetKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + KnowledgeBasesSettings.Builder knowledgeBasesSettingsBuilder = + KnowledgeBasesSettings.newBuilder(); + knowledgeBasesSettingsBuilder + .getKnowledgeBaseSettings() + .setRetrySettings( + knowledgeBasesSettingsBuilder + .getKnowledgeBaseSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + KnowledgeBasesSettings knowledgeBasesSettings = knowledgeBasesSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_knowledgebasessettings_getknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/AsyncAnalyzeContent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/AsyncAnalyzeContent.java new file mode 100644 index 000000000000..4c1a6742a1c2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/AsyncAnalyzeContent.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_analyzecontent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AnalyzeContentRequest; +import com.google.cloud.dialogflow.v2.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2.AssistQueryParameters; +import com.google.cloud.dialogflow.v2.OutputAudioConfig; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.QueryParameters; +import com.google.protobuf.Struct; + +public class AsyncAnalyzeContent { + + public static void main(String[] args) throws Exception { + asyncAnalyzeContent(); + } + + public static void asyncAnalyzeContent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + AnalyzeContentRequest request = + AnalyzeContentRequest.newBuilder() + .setParticipant( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setReplyAudioConfig(OutputAudioConfig.newBuilder().build()) + .setQueryParams(QueryParameters.newBuilder().build()) + .setAssistQueryParams(AssistQueryParameters.newBuilder().build()) + .setCxParameters(Struct.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + participantsClient.analyzeContentCallable().futureCall(request); + // Do something. + AnalyzeContentResponse response = future.get(); + } + } +} +// [END dialogflow_v2_generated_participantsclient_analyzecontent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContent.java new file mode 100644 index 000000000000..55adb372f2be --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContent.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_analyzecontent_sync] +import com.google.cloud.dialogflow.v2.AnalyzeContentRequest; +import com.google.cloud.dialogflow.v2.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2.AssistQueryParameters; +import com.google.cloud.dialogflow.v2.OutputAudioConfig; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.QueryParameters; +import com.google.protobuf.Struct; + +public class SyncAnalyzeContent { + + public static void main(String[] args) throws Exception { + syncAnalyzeContent(); + } + + public static void syncAnalyzeContent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + AnalyzeContentRequest request = + AnalyzeContentRequest.newBuilder() + .setParticipant( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setReplyAudioConfig(OutputAudioConfig.newBuilder().build()) + .setQueryParams(QueryParameters.newBuilder().build()) + .setAssistQueryParams(AssistQueryParameters.newBuilder().build()) + .setCxParameters(Struct.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + AnalyzeContentResponse response = participantsClient.analyzeContent(request); + } + } +} +// [END dialogflow_v2_generated_participantsclient_analyzecontent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameEventinput.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameEventinput.java new file mode 100644 index 000000000000..a17ee257021e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameEventinput.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_analyzecontent_participantnameeventinput_sync] +import com.google.cloud.dialogflow.v2.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2.EventInput; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class SyncAnalyzeContentParticipantnameEventinput { + + public static void main(String[] args) throws Exception { + syncAnalyzeContentParticipantnameEventinput(); + } + + public static void syncAnalyzeContentParticipantnameEventinput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ParticipantName participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + EventInput eventInput = EventInput.newBuilder().build(); + AnalyzeContentResponse response = participantsClient.analyzeContent(participant, eventInput); + } + } +} +// [END dialogflow_v2_generated_participantsclient_analyzecontent_participantnameeventinput_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameTextinput.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameTextinput.java new file mode 100644 index 000000000000..b152df06b774 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameTextinput.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_analyzecontent_participantnametextinput_sync] +import com.google.cloud.dialogflow.v2.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.TextInput; + +public class SyncAnalyzeContentParticipantnameTextinput { + + public static void main(String[] args) throws Exception { + syncAnalyzeContentParticipantnameTextinput(); + } + + public static void syncAnalyzeContentParticipantnameTextinput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ParticipantName participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + TextInput textInput = TextInput.newBuilder().build(); + AnalyzeContentResponse response = participantsClient.analyzeContent(participant, textInput); + } + } +} +// [END dialogflow_v2_generated_participantsclient_analyzecontent_participantnametextinput_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentStringEventinput.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentStringEventinput.java new file mode 100644 index 000000000000..198d20fa5ff6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentStringEventinput.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_analyzecontent_stringeventinput_sync] +import com.google.cloud.dialogflow.v2.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2.EventInput; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class SyncAnalyzeContentStringEventinput { + + public static void main(String[] args) throws Exception { + syncAnalyzeContentStringEventinput(); + } + + public static void syncAnalyzeContentStringEventinput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString(); + EventInput eventInput = EventInput.newBuilder().build(); + AnalyzeContentResponse response = participantsClient.analyzeContent(participant, eventInput); + } + } +} +// [END dialogflow_v2_generated_participantsclient_analyzecontent_stringeventinput_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentStringTextinput.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentStringTextinput.java new file mode 100644 index 000000000000..0eba5c2b486c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/analyzecontent/SyncAnalyzeContentStringTextinput.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_analyzecontent_stringtextinput_sync] +import com.google.cloud.dialogflow.v2.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.TextInput; + +public class SyncAnalyzeContentStringTextinput { + + public static void main(String[] args) throws Exception { + syncAnalyzeContentStringTextinput(); + } + + public static void syncAnalyzeContentStringTextinput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString(); + TextInput textInput = TextInput.newBuilder().build(); + AnalyzeContentResponse response = participantsClient.analyzeContent(participant, textInput); + } + } +} +// [END dialogflow_v2_generated_participantsclient_analyzecontent_stringtextinput_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..f4f1d6c177af --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.ParticipantsSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ParticipantsSettings participantsSettings = + ParticipantsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ParticipantsClient participantsClient = ParticipantsClient.create(participantsSettings); + } +} +// [END dialogflow_v2_generated_participantsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..af0df28f540f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.ParticipantsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ParticipantsSettings participantsSettings = + ParticipantsSettings.newBuilder() + .setTransportChannelProvider( + ParticipantsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ParticipantsClient participantsClient = ParticipantsClient.create(participantsSettings); + } +} +// [END dialogflow_v2_generated_participantsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..00d82e9ec983 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.ParticipantsSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ParticipantsSettings participantsSettings = + ParticipantsSettings.newBuilder().setEndpoint(myEndpoint).build(); + ParticipantsClient participantsClient = ParticipantsClient.create(participantsSettings); + } +} +// [END dialogflow_v2_generated_participantsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/AsyncCreateParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/AsyncCreateParticipant.java new file mode 100644 index 000000000000..36a4b5944ebe --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/AsyncCreateParticipant.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_createparticipant_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.CreateParticipantRequest; +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class AsyncCreateParticipant { + + public static void main(String[] args) throws Exception { + asyncCreateParticipant(); + } + + public static void asyncCreateParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + CreateParticipantRequest request = + CreateParticipantRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setParticipant(Participant.newBuilder().build()) + .build(); + ApiFuture future = + participantsClient.createParticipantCallable().futureCall(request); + // Do something. + Participant response = future.get(); + } + } +} +// [END dialogflow_v2_generated_participantsclient_createparticipant_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/SyncCreateParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/SyncCreateParticipant.java new file mode 100644 index 000000000000..cce3f5cee7a5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/SyncCreateParticipant.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_createparticipant_sync] +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.CreateParticipantRequest; +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class SyncCreateParticipant { + + public static void main(String[] args) throws Exception { + syncCreateParticipant(); + } + + public static void syncCreateParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + CreateParticipantRequest request = + CreateParticipantRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setParticipant(Participant.newBuilder().build()) + .build(); + Participant response = participantsClient.createParticipant(request); + } + } +} +// [END dialogflow_v2_generated_participantsclient_createparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/SyncCreateParticipantConversationnameParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/SyncCreateParticipantConversationnameParticipant.java new file mode 100644 index 000000000000..c1d1bfc9ef4d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/SyncCreateParticipantConversationnameParticipant.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_participantsclient_createparticipant_conversationnameparticipant_sync] +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class SyncCreateParticipantConversationnameParticipant { + + public static void main(String[] args) throws Exception { + syncCreateParticipantConversationnameParticipant(); + } + + public static void syncCreateParticipantConversationnameParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + Participant participant = Participant.newBuilder().build(); + Participant response = participantsClient.createParticipant(parent, participant); + } + } +} +// [END +// dialogflow_v2_generated_participantsclient_createparticipant_conversationnameparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/SyncCreateParticipantStringParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/SyncCreateParticipantStringParticipant.java new file mode 100644 index 000000000000..813fe07abbc0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/createparticipant/SyncCreateParticipantStringParticipant.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_createparticipant_stringparticipant_sync] +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class SyncCreateParticipantStringParticipant { + + public static void main(String[] args) throws Exception { + syncCreateParticipantStringParticipant(); + } + + public static void syncCreateParticipantStringParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString(); + Participant participant = Participant.newBuilder().build(); + Participant response = participantsClient.createParticipant(parent, participant); + } + } +} +// [END dialogflow_v2_generated_participantsclient_createparticipant_stringparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/AsyncGetParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/AsyncGetParticipant.java new file mode 100644 index 000000000000..6e695b1147a6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/AsyncGetParticipant.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_getparticipant_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.GetParticipantRequest; +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class AsyncGetParticipant { + + public static void main(String[] args) throws Exception { + asyncGetParticipant(); + } + + public static void asyncGetParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + GetParticipantRequest request = + GetParticipantRequest.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .build(); + ApiFuture future = + participantsClient.getParticipantCallable().futureCall(request); + // Do something. + Participant response = future.get(); + } + } +} +// [END dialogflow_v2_generated_participantsclient_getparticipant_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/SyncGetParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/SyncGetParticipant.java new file mode 100644 index 000000000000..be8c3a7bc285 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/SyncGetParticipant.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_getparticipant_sync] +import com.google.cloud.dialogflow.v2.GetParticipantRequest; +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class SyncGetParticipant { + + public static void main(String[] args) throws Exception { + syncGetParticipant(); + } + + public static void syncGetParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + GetParticipantRequest request = + GetParticipantRequest.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .build(); + Participant response = participantsClient.getParticipant(request); + } + } +} +// [END dialogflow_v2_generated_participantsclient_getparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/SyncGetParticipantParticipantname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/SyncGetParticipantParticipantname.java new file mode 100644 index 000000000000..9e5064700ce0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/SyncGetParticipantParticipantname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_getparticipant_participantname_sync] +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class SyncGetParticipantParticipantname { + + public static void main(String[] args) throws Exception { + syncGetParticipantParticipantname(); + } + + public static void syncGetParticipantParticipantname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ParticipantName name = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + Participant response = participantsClient.getParticipant(name); + } + } +} +// [END dialogflow_v2_generated_participantsclient_getparticipant_participantname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/SyncGetParticipantString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/SyncGetParticipantString.java new file mode 100644 index 000000000000..ff066b51e2f0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/getparticipant/SyncGetParticipantString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_getparticipant_string_sync] +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class SyncGetParticipantString { + + public static void main(String[] args) throws Exception { + syncGetParticipantString(); + } + + public static void syncGetParticipantString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String name = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString(); + Participant response = participantsClient.getParticipant(name); + } + } +} +// [END dialogflow_v2_generated_participantsclient_getparticipant_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/AsyncListParticipants.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/AsyncListParticipants.java new file mode 100644 index 000000000000..07d0a26fe03d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/AsyncListParticipants.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_listparticipants_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ListParticipantsRequest; +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class AsyncListParticipants { + + public static void main(String[] args) throws Exception { + asyncListParticipants(); + } + + public static void asyncListParticipants() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ListParticipantsRequest request = + ListParticipantsRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + participantsClient.listParticipantsPagedCallable().futureCall(request); + // Do something. + for (Participant element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_participantsclient_listparticipants_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/AsyncListParticipantsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/AsyncListParticipantsPaged.java new file mode 100644 index 000000000000..9915e3a9d74b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/AsyncListParticipantsPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_listparticipants_paged_async] +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ListParticipantsRequest; +import com.google.cloud.dialogflow.v2.ListParticipantsResponse; +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.common.base.Strings; + +public class AsyncListParticipantsPaged { + + public static void main(String[] args) throws Exception { + asyncListParticipantsPaged(); + } + + public static void asyncListParticipantsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ListParticipantsRequest request = + ListParticipantsRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListParticipantsResponse response = + participantsClient.listParticipantsCallable().call(request); + for (Participant element : response.getParticipantsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2_generated_participantsclient_listparticipants_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/SyncListParticipants.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/SyncListParticipants.java new file mode 100644 index 000000000000..e869fee144bf --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/SyncListParticipants.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_listparticipants_sync] +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.ListParticipantsRequest; +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class SyncListParticipants { + + public static void main(String[] args) throws Exception { + syncListParticipants(); + } + + public static void syncListParticipants() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ListParticipantsRequest request = + ListParticipantsRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Participant element : participantsClient.listParticipants(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_participantsclient_listparticipants_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/SyncListParticipantsConversationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/SyncListParticipantsConversationname.java new file mode 100644 index 000000000000..279dcff67ba2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/SyncListParticipantsConversationname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_listparticipants_conversationname_sync] +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class SyncListParticipantsConversationname { + + public static void main(String[] args) throws Exception { + syncListParticipantsConversationname(); + } + + public static void syncListParticipantsConversationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + for (Participant element : participantsClient.listParticipants(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_participantsclient_listparticipants_conversationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/SyncListParticipantsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/SyncListParticipantsString.java new file mode 100644 index 000000000000..85059645ed74 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/listparticipants/SyncListParticipantsString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_listparticipants_string_sync] +import com.google.cloud.dialogflow.v2.ConversationName; +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantsClient; + +public class SyncListParticipantsString { + + public static void main(String[] args) throws Exception { + syncListParticipantsString(); + } + + public static void syncListParticipantsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString(); + for (Participant element : participantsClient.listParticipants(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_participantsclient_listparticipants_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/AsyncSuggestArticles.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/AsyncSuggestArticles.java new file mode 100644 index 000000000000..bbee8d98460e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/AsyncSuggestArticles.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_suggestarticles_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AssistQueryParameters; +import com.google.cloud.dialogflow.v2.MessageName; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.SuggestArticlesRequest; +import com.google.cloud.dialogflow.v2.SuggestArticlesResponse; + +public class AsyncSuggestArticles { + + public static void main(String[] args) throws Exception { + asyncSuggestArticles(); + } + + public static void asyncSuggestArticles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + SuggestArticlesRequest request = + SuggestArticlesRequest.newBuilder() + .setParent( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .setAssistQueryParams(AssistQueryParameters.newBuilder().build()) + .build(); + ApiFuture future = + participantsClient.suggestArticlesCallable().futureCall(request); + // Do something. + SuggestArticlesResponse response = future.get(); + } + } +} +// [END dialogflow_v2_generated_participantsclient_suggestarticles_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/SyncSuggestArticles.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/SyncSuggestArticles.java new file mode 100644 index 000000000000..3696b4ab7a4d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/SyncSuggestArticles.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_suggestarticles_sync] +import com.google.cloud.dialogflow.v2.AssistQueryParameters; +import com.google.cloud.dialogflow.v2.MessageName; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.SuggestArticlesRequest; +import com.google.cloud.dialogflow.v2.SuggestArticlesResponse; + +public class SyncSuggestArticles { + + public static void main(String[] args) throws Exception { + syncSuggestArticles(); + } + + public static void syncSuggestArticles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + SuggestArticlesRequest request = + SuggestArticlesRequest.newBuilder() + .setParent( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .setAssistQueryParams(AssistQueryParameters.newBuilder().build()) + .build(); + SuggestArticlesResponse response = participantsClient.suggestArticles(request); + } + } +} +// [END dialogflow_v2_generated_participantsclient_suggestarticles_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/SyncSuggestArticlesParticipantname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/SyncSuggestArticlesParticipantname.java new file mode 100644 index 000000000000..a82e275321dc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/SyncSuggestArticlesParticipantname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_suggestarticles_participantname_sync] +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.SuggestArticlesResponse; + +public class SyncSuggestArticlesParticipantname { + + public static void main(String[] args) throws Exception { + syncSuggestArticlesParticipantname(); + } + + public static void syncSuggestArticlesParticipantname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + SuggestArticlesResponse response = participantsClient.suggestArticles(parent); + } + } +} +// [END dialogflow_v2_generated_participantsclient_suggestarticles_participantname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/SyncSuggestArticlesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/SyncSuggestArticlesString.java new file mode 100644 index 000000000000..b2099f74e0df --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestarticles/SyncSuggestArticlesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_suggestarticles_string_sync] +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.SuggestArticlesResponse; + +public class SyncSuggestArticlesString { + + public static void main(String[] args) throws Exception { + syncSuggestArticlesString(); + } + + public static void syncSuggestArticlesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString(); + SuggestArticlesResponse response = participantsClient.suggestArticles(parent); + } + } +} +// [END dialogflow_v2_generated_participantsclient_suggestarticles_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/AsyncSuggestFaqAnswers.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/AsyncSuggestFaqAnswers.java new file mode 100644 index 000000000000..822b0d018556 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/AsyncSuggestFaqAnswers.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_suggestfaqanswers_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AssistQueryParameters; +import com.google.cloud.dialogflow.v2.MessageName; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.SuggestFaqAnswersRequest; +import com.google.cloud.dialogflow.v2.SuggestFaqAnswersResponse; + +public class AsyncSuggestFaqAnswers { + + public static void main(String[] args) throws Exception { + asyncSuggestFaqAnswers(); + } + + public static void asyncSuggestFaqAnswers() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + SuggestFaqAnswersRequest request = + SuggestFaqAnswersRequest.newBuilder() + .setParent( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .setAssistQueryParams(AssistQueryParameters.newBuilder().build()) + .build(); + ApiFuture future = + participantsClient.suggestFaqAnswersCallable().futureCall(request); + // Do something. + SuggestFaqAnswersResponse response = future.get(); + } + } +} +// [END dialogflow_v2_generated_participantsclient_suggestfaqanswers_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswers.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswers.java new file mode 100644 index 000000000000..4eb4a5c657d3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswers.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_suggestfaqanswers_sync] +import com.google.cloud.dialogflow.v2.AssistQueryParameters; +import com.google.cloud.dialogflow.v2.MessageName; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.SuggestFaqAnswersRequest; +import com.google.cloud.dialogflow.v2.SuggestFaqAnswersResponse; + +public class SyncSuggestFaqAnswers { + + public static void main(String[] args) throws Exception { + syncSuggestFaqAnswers(); + } + + public static void syncSuggestFaqAnswers() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + SuggestFaqAnswersRequest request = + SuggestFaqAnswersRequest.newBuilder() + .setParent( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .setAssistQueryParams(AssistQueryParameters.newBuilder().build()) + .build(); + SuggestFaqAnswersResponse response = participantsClient.suggestFaqAnswers(request); + } + } +} +// [END dialogflow_v2_generated_participantsclient_suggestfaqanswers_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersParticipantname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersParticipantname.java new file mode 100644 index 000000000000..3329abd75f94 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersParticipantname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_suggestfaqanswers_participantname_sync] +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.SuggestFaqAnswersResponse; + +public class SyncSuggestFaqAnswersParticipantname { + + public static void main(String[] args) throws Exception { + syncSuggestFaqAnswersParticipantname(); + } + + public static void syncSuggestFaqAnswersParticipantname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + SuggestFaqAnswersResponse response = participantsClient.suggestFaqAnswers(parent); + } + } +} +// [END dialogflow_v2_generated_participantsclient_suggestfaqanswers_participantname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersString.java new file mode 100644 index 000000000000..a12dadfd07e0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_suggestfaqanswers_string_sync] +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.SuggestFaqAnswersResponse; + +public class SyncSuggestFaqAnswersString { + + public static void main(String[] args) throws Exception { + syncSuggestFaqAnswersString(); + } + + public static void syncSuggestFaqAnswersString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString(); + SuggestFaqAnswersResponse response = participantsClient.suggestFaqAnswers(parent); + } + } +} +// [END dialogflow_v2_generated_participantsclient_suggestfaqanswers_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/AsyncSuggestSmartReplies.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/AsyncSuggestSmartReplies.java new file mode 100644 index 000000000000..16411849b74a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/AsyncSuggestSmartReplies.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_suggestsmartreplies_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.MessageName; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.SuggestSmartRepliesRequest; +import com.google.cloud.dialogflow.v2.SuggestSmartRepliesResponse; +import com.google.cloud.dialogflow.v2.TextInput; + +public class AsyncSuggestSmartReplies { + + public static void main(String[] args) throws Exception { + asyncSuggestSmartReplies(); + } + + public static void asyncSuggestSmartReplies() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + SuggestSmartRepliesRequest request = + SuggestSmartRepliesRequest.newBuilder() + .setParent( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setCurrentTextInput(TextInput.newBuilder().build()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .build(); + ApiFuture future = + participantsClient.suggestSmartRepliesCallable().futureCall(request); + // Do something. + SuggestSmartRepliesResponse response = future.get(); + } + } +} +// [END dialogflow_v2_generated_participantsclient_suggestsmartreplies_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/SyncSuggestSmartReplies.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/SyncSuggestSmartReplies.java new file mode 100644 index 000000000000..b97f76b9ab7d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/SyncSuggestSmartReplies.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_suggestsmartreplies_sync] +import com.google.cloud.dialogflow.v2.MessageName; +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.SuggestSmartRepliesRequest; +import com.google.cloud.dialogflow.v2.SuggestSmartRepliesResponse; +import com.google.cloud.dialogflow.v2.TextInput; + +public class SyncSuggestSmartReplies { + + public static void main(String[] args) throws Exception { + syncSuggestSmartReplies(); + } + + public static void syncSuggestSmartReplies() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + SuggestSmartRepliesRequest request = + SuggestSmartRepliesRequest.newBuilder() + .setParent( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setCurrentTextInput(TextInput.newBuilder().build()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .build(); + SuggestSmartRepliesResponse response = participantsClient.suggestSmartReplies(request); + } + } +} +// [END dialogflow_v2_generated_participantsclient_suggestsmartreplies_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesParticipantname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesParticipantname.java new file mode 100644 index 000000000000..5a66edce0b0b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesParticipantname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_suggestsmartreplies_participantname_sync] +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.SuggestSmartRepliesResponse; + +public class SyncSuggestSmartRepliesParticipantname { + + public static void main(String[] args) throws Exception { + syncSuggestSmartRepliesParticipantname(); + } + + public static void syncSuggestSmartRepliesParticipantname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + SuggestSmartRepliesResponse response = participantsClient.suggestSmartReplies(parent); + } + } +} +// [END dialogflow_v2_generated_participantsclient_suggestsmartreplies_participantname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesString.java new file mode 100644 index 000000000000..819de3043399 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_suggestsmartreplies_string_sync] +import com.google.cloud.dialogflow.v2.ParticipantName; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.SuggestSmartRepliesResponse; + +public class SyncSuggestSmartRepliesString { + + public static void main(String[] args) throws Exception { + syncSuggestSmartRepliesString(); + } + + public static void syncSuggestSmartRepliesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString(); + SuggestSmartRepliesResponse response = participantsClient.suggestSmartReplies(parent); + } + } +} +// [END dialogflow_v2_generated_participantsclient_suggestsmartreplies_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/updateparticipant/AsyncUpdateParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/updateparticipant/AsyncUpdateParticipant.java new file mode 100644 index 000000000000..0cc40ce1cbca --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/updateparticipant/AsyncUpdateParticipant.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_updateparticipant_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.UpdateParticipantRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateParticipant { + + public static void main(String[] args) throws Exception { + asyncUpdateParticipant(); + } + + public static void asyncUpdateParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + UpdateParticipantRequest request = + UpdateParticipantRequest.newBuilder() + .setParticipant(Participant.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + participantsClient.updateParticipantCallable().futureCall(request); + // Do something. + Participant response = future.get(); + } + } +} +// [END dialogflow_v2_generated_participantsclient_updateparticipant_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/updateparticipant/SyncUpdateParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/updateparticipant/SyncUpdateParticipant.java new file mode 100644 index 000000000000..10646ac09f1a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/updateparticipant/SyncUpdateParticipant.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_updateparticipant_sync] +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.cloud.dialogflow.v2.UpdateParticipantRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateParticipant { + + public static void main(String[] args) throws Exception { + syncUpdateParticipant(); + } + + public static void syncUpdateParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + UpdateParticipantRequest request = + UpdateParticipantRequest.newBuilder() + .setParticipant(Participant.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Participant response = participantsClient.updateParticipant(request); + } + } +} +// [END dialogflow_v2_generated_participantsclient_updateparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/updateparticipant/SyncUpdateParticipantParticipantFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/updateparticipant/SyncUpdateParticipantParticipantFieldmask.java new file mode 100644 index 000000000000..3c0784da5c22 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantsclient/updateparticipant/SyncUpdateParticipantParticipantFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsclient_updateparticipant_participantfieldmask_sync] +import com.google.cloud.dialogflow.v2.Participant; +import com.google.cloud.dialogflow.v2.ParticipantsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateParticipantParticipantFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateParticipantParticipantFieldmask(); + } + + public static void syncUpdateParticipantParticipantFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + Participant participant = Participant.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Participant response = participantsClient.updateParticipant(participant, updateMask); + } + } +} +// [END dialogflow_v2_generated_participantsclient_updateparticipant_participantfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantssettings/createparticipant/SyncCreateParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantssettings/createparticipant/SyncCreateParticipant.java new file mode 100644 index 000000000000..79d38d8fb877 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/participantssettings/createparticipant/SyncCreateParticipant.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantssettings_createparticipant_sync] +import com.google.cloud.dialogflow.v2.ParticipantsSettings; +import java.time.Duration; + +public class SyncCreateParticipant { + + public static void main(String[] args) throws Exception { + syncCreateParticipant(); + } + + public static void syncCreateParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ParticipantsSettings.Builder participantsSettingsBuilder = ParticipantsSettings.newBuilder(); + participantsSettingsBuilder + .createParticipantSettings() + .setRetrySettings( + participantsSettingsBuilder + .createParticipantSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ParticipantsSettings participantsSettings = participantsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_participantssettings_createparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..6b8dbc868349 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.SessionEntityTypesSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionEntityTypesSettings sessionEntityTypesSettings = + SessionEntityTypesSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + SessionEntityTypesClient sessionEntityTypesClient = + SessionEntityTypesClient.create(sessionEntityTypesSettings); + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..1708b38fc832 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.SessionEntityTypesSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionEntityTypesSettings sessionEntityTypesSettings = + SessionEntityTypesSettings.newBuilder() + .setTransportChannelProvider( + SessionEntityTypesSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + SessionEntityTypesClient sessionEntityTypesClient = + SessionEntityTypesClient.create(sessionEntityTypesSettings); + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..f94826af340c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.SessionEntityTypesSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionEntityTypesSettings sessionEntityTypesSettings = + SessionEntityTypesSettings.newBuilder().setEndpoint(myEndpoint).build(); + SessionEntityTypesClient sessionEntityTypesClient = + SessionEntityTypesClient.create(sessionEntityTypesSettings); + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/AsyncCreateSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/AsyncCreateSessionEntityType.java new file mode 100644 index 000000000000..11f6dcdb63dc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/AsyncCreateSessionEntityType.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_createsessionentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.CreateSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class AsyncCreateSessionEntityType { + + public static void main(String[] args) throws Exception { + asyncCreateSessionEntityType(); + } + + public static void asyncCreateSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + CreateSessionEntityTypeRequest request = + CreateSessionEntityTypeRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setSessionEntityType(SessionEntityType.newBuilder().build()) + .build(); + ApiFuture future = + sessionEntityTypesClient.createSessionEntityTypeCallable().futureCall(request); + // Do something. + SessionEntityType response = future.get(); + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_createsessionentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityType.java new file mode 100644 index 000000000000..e801b96ba11a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityType.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_createsessionentitytype_sync] +import com.google.cloud.dialogflow.v2.CreateSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncCreateSessionEntityType { + + public static void main(String[] args) throws Exception { + syncCreateSessionEntityType(); + } + + public static void syncCreateSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + CreateSessionEntityTypeRequest request = + CreateSessionEntityTypeRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setSessionEntityType(SessionEntityType.newBuilder().build()) + .build(); + SessionEntityType response = sessionEntityTypesClient.createSessionEntityType(request); + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_createsessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeSessionnameSessionentitytype.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeSessionnameSessionentitytype.java new file mode 100644 index 000000000000..422961006439 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeSessionnameSessionentitytype.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_sessionentitytypesclient_createsessionentitytype_sessionnamesessionentitytype_sync] +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncCreateSessionEntityTypeSessionnameSessionentitytype { + + public static void main(String[] args) throws Exception { + syncCreateSessionEntityTypeSessionnameSessionentitytype(); + } + + public static void syncCreateSessionEntityTypeSessionnameSessionentitytype() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + SessionEntityType response = + sessionEntityTypesClient.createSessionEntityType(parent, sessionEntityType); + } + } +} +// [END +// dialogflow_v2_generated_sessionentitytypesclient_createsessionentitytype_sessionnamesessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeStringSessionentitytype.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeStringSessionentitytype.java new file mode 100644 index 000000000000..e90436528a8e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeStringSessionentitytype.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_sessionentitytypesclient_createsessionentitytype_stringsessionentitytype_sync] +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncCreateSessionEntityTypeStringSessionentitytype { + + public static void main(String[] args) throws Exception { + syncCreateSessionEntityTypeStringSessionentitytype(); + } + + public static void syncCreateSessionEntityTypeStringSessionentitytype() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + String parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString(); + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + SessionEntityType response = + sessionEntityTypesClient.createSessionEntityType(parent, sessionEntityType); + } + } +} +// [END +// dialogflow_v2_generated_sessionentitytypesclient_createsessionentitytype_stringsessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/AsyncDeleteSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/AsyncDeleteSessionEntityType.java new file mode 100644 index 000000000000..051769fc8c6e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/AsyncDeleteSessionEntityType.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_deletesessionentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.DeleteSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteSessionEntityType { + + public static void main(String[] args) throws Exception { + asyncDeleteSessionEntityType(); + } + + public static void asyncDeleteSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + DeleteSessionEntityTypeRequest request = + DeleteSessionEntityTypeRequest.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .build(); + ApiFuture future = + sessionEntityTypesClient.deleteSessionEntityTypeCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_deletesessionentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityType.java new file mode 100644 index 000000000000..5547525debe5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityType.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_deletesessionentitytype_sync] +import com.google.cloud.dialogflow.v2.DeleteSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; + +public class SyncDeleteSessionEntityType { + + public static void main(String[] args) throws Exception { + syncDeleteSessionEntityType(); + } + + public static void syncDeleteSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + DeleteSessionEntityTypeRequest request = + DeleteSessionEntityTypeRequest.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .build(); + sessionEntityTypesClient.deleteSessionEntityType(request); + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_deletesessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeSessionentitytypename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeSessionentitytypename.java new file mode 100644 index 000000000000..5cfca371e44a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeSessionentitytypename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_sessionentitytypesclient_deletesessionentitytype_sessionentitytypename_sync] +import com.google.cloud.dialogflow.v2.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; + +public class SyncDeleteSessionEntityTypeSessionentitytypename { + + public static void main(String[] args) throws Exception { + syncDeleteSessionEntityTypeSessionentitytypename(); + } + + public static void syncDeleteSessionEntityTypeSessionentitytypename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + SessionEntityTypeName name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + sessionEntityTypesClient.deleteSessionEntityType(name); + } + } +} +// [END +// dialogflow_v2_generated_sessionentitytypesclient_deletesessionentitytype_sessionentitytypename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeString.java new file mode 100644 index 000000000000..6bc6096ee0f8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_deletesessionentitytype_string_sync] +import com.google.cloud.dialogflow.v2.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; + +public class SyncDeleteSessionEntityTypeString { + + public static void main(String[] args) throws Exception { + syncDeleteSessionEntityTypeString(); + } + + public static void syncDeleteSessionEntityTypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + String name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString(); + sessionEntityTypesClient.deleteSessionEntityType(name); + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_deletesessionentitytype_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/AsyncGetSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/AsyncGetSessionEntityType.java new file mode 100644 index 000000000000..e2132d589218 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/AsyncGetSessionEntityType.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_getsessionentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.GetSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; + +public class AsyncGetSessionEntityType { + + public static void main(String[] args) throws Exception { + asyncGetSessionEntityType(); + } + + public static void asyncGetSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + GetSessionEntityTypeRequest request = + GetSessionEntityTypeRequest.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .build(); + ApiFuture future = + sessionEntityTypesClient.getSessionEntityTypeCallable().futureCall(request); + // Do something. + SessionEntityType response = future.get(); + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_getsessionentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityType.java new file mode 100644 index 000000000000..5b7a01e044b9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityType.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_getsessionentitytype_sync] +import com.google.cloud.dialogflow.v2.GetSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; + +public class SyncGetSessionEntityType { + + public static void main(String[] args) throws Exception { + syncGetSessionEntityType(); + } + + public static void syncGetSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + GetSessionEntityTypeRequest request = + GetSessionEntityTypeRequest.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .build(); + SessionEntityType response = sessionEntityTypesClient.getSessionEntityType(request); + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_getsessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeSessionentitytypename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeSessionentitytypename.java new file mode 100644 index 000000000000..0e2b9e2d8d72 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeSessionentitytypename.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_sessionentitytypesclient_getsessionentitytype_sessionentitytypename_sync] +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; + +public class SyncGetSessionEntityTypeSessionentitytypename { + + public static void main(String[] args) throws Exception { + syncGetSessionEntityTypeSessionentitytypename(); + } + + public static void syncGetSessionEntityTypeSessionentitytypename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + SessionEntityTypeName name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + SessionEntityType response = sessionEntityTypesClient.getSessionEntityType(name); + } + } +} +// [END +// dialogflow_v2_generated_sessionentitytypesclient_getsessionentitytype_sessionentitytypename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeString.java new file mode 100644 index 000000000000..053e25203f57 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_getsessionentitytype_string_sync] +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; + +public class SyncGetSessionEntityTypeString { + + public static void main(String[] args) throws Exception { + syncGetSessionEntityTypeString(); + } + + public static void syncGetSessionEntityTypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + String name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString(); + SessionEntityType response = sessionEntityTypesClient.getSessionEntityType(name); + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_getsessionentitytype_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypes.java new file mode 100644 index 000000000000..f438e61c9476 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypes.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_listsessionentitytypes_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.ListSessionEntityTypesRequest; +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class AsyncListSessionEntityTypes { + + public static void main(String[] args) throws Exception { + asyncListSessionEntityTypes(); + } + + public static void asyncListSessionEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + ListSessionEntityTypesRequest request = + ListSessionEntityTypesRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + sessionEntityTypesClient.listSessionEntityTypesPagedCallable().futureCall(request); + // Do something. + for (SessionEntityType element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_listsessionentitytypes_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypesPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypesPaged.java new file mode 100644 index 000000000000..58352b609526 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypesPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_listsessionentitytypes_paged_async] +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.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.SessionName; +import com.google.common.base.Strings; + +public class AsyncListSessionEntityTypesPaged { + + public static void main(String[] args) throws Exception { + asyncListSessionEntityTypesPaged(); + } + + public static void asyncListSessionEntityTypesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + ListSessionEntityTypesRequest request = + ListSessionEntityTypesRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .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; + } + } + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_listsessionentitytypes_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypes.java new file mode 100644 index 000000000000..9db9025e27c4 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypes.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_listsessionentitytypes_sync] +import com.google.cloud.dialogflow.v2.ListSessionEntityTypesRequest; +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncListSessionEntityTypes { + + public static void main(String[] args) throws Exception { + syncListSessionEntityTypes(); + } + + public static void syncListSessionEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + ListSessionEntityTypesRequest request = + ListSessionEntityTypesRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (SessionEntityType element : + sessionEntityTypesClient.listSessionEntityTypes(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_listsessionentitytypes_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesSessionname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesSessionname.java new file mode 100644 index 000000000000..8c7c6dc0e85f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesSessionname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_listsessionentitytypes_sessionname_sync] +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncListSessionEntityTypesSessionname { + + public static void main(String[] args) throws Exception { + syncListSessionEntityTypesSessionname(); + } + + public static void syncListSessionEntityTypesSessionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + for (SessionEntityType element : + sessionEntityTypesClient.listSessionEntityTypes(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_listsessionentitytypes_sessionname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesString.java new file mode 100644 index 000000000000..86f83a34c978 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_listsessionentitytypes_string_sync] +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.SessionName; + +public class SyncListSessionEntityTypesString { + + public static void main(String[] args) throws Exception { + syncListSessionEntityTypesString(); + } + + public static void syncListSessionEntityTypesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + String parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString(); + for (SessionEntityType element : + sessionEntityTypesClient.listSessionEntityTypes(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_listsessionentitytypes_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/AsyncUpdateSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/AsyncUpdateSessionEntityType.java new file mode 100644 index 000000000000..9db1e250bc16 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/AsyncUpdateSessionEntityType.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_updatesessionentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.UpdateSessionEntityTypeRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateSessionEntityType { + + public static void main(String[] args) throws Exception { + asyncUpdateSessionEntityType(); + } + + public static void asyncUpdateSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + UpdateSessionEntityTypeRequest request = + UpdateSessionEntityTypeRequest.newBuilder() + .setSessionEntityType(SessionEntityType.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + sessionEntityTypesClient.updateSessionEntityTypeCallable().futureCall(request); + // Do something. + SessionEntityType response = future.get(); + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_updatesessionentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityType.java new file mode 100644 index 000000000000..ad03eb9269eb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityType.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesclient_updatesessionentitytype_sync] +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2.UpdateSessionEntityTypeRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateSessionEntityType { + + public static void main(String[] args) throws Exception { + syncUpdateSessionEntityType(); + } + + public static void syncUpdateSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + UpdateSessionEntityTypeRequest request = + UpdateSessionEntityTypeRequest.newBuilder() + .setSessionEntityType(SessionEntityType.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + SessionEntityType response = sessionEntityTypesClient.updateSessionEntityType(request); + } + } +} +// [END dialogflow_v2_generated_sessionentitytypesclient_updatesessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytype.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytype.java new file mode 100644 index 000000000000..b9a587b3aa62 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytype.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_sessionentitytypesclient_updatesessionentitytype_sessionentitytype_sync] +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; + +public class SyncUpdateSessionEntityTypeSessionentitytype { + + public static void main(String[] args) throws Exception { + syncUpdateSessionEntityTypeSessionentitytype(); + } + + public static void syncUpdateSessionEntityTypeSessionentitytype() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + SessionEntityType response = + sessionEntityTypesClient.updateSessionEntityType(sessionEntityType); + } + } +} +// [END +// dialogflow_v2_generated_sessionentitytypesclient_updatesessionentitytype_sessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytypeFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytypeFieldmask.java new file mode 100644 index 000000000000..0c1f6c91e1dc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytypeFieldmask.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START +// dialogflow_v2_generated_sessionentitytypesclient_updatesessionentitytype_sessionentitytypefieldmask_sync] +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.SessionEntityTypesClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateSessionEntityTypeSessionentitytypeFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateSessionEntityTypeSessionentitytypeFieldmask(); + } + + public static void syncUpdateSessionEntityTypeSessionentitytypeFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + SessionEntityType response = + sessionEntityTypesClient.updateSessionEntityType(sessionEntityType, updateMask); + } + } +} +// [END +// dialogflow_v2_generated_sessionentitytypesclient_updatesessionentitytype_sessionentitytypefieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypessettings/getsessionentitytype/SyncGetSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypessettings/getsessionentitytype/SyncGetSessionEntityType.java new file mode 100644 index 000000000000..0b5f0c4034b0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionentitytypessettings/getsessionentitytype/SyncGetSessionEntityType.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypessettings_getsessionentitytype_sync] +import com.google.cloud.dialogflow.v2.SessionEntityTypesSettings; +import java.time.Duration; + +public class SyncGetSessionEntityType { + + public static void main(String[] args) throws Exception { + syncGetSessionEntityType(); + } + + public static void syncGetSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionEntityTypesSettings.Builder sessionEntityTypesSettingsBuilder = + SessionEntityTypesSettings.newBuilder(); + sessionEntityTypesSettingsBuilder + .getSessionEntityTypeSettings() + .setRetrySettings( + sessionEntityTypesSettingsBuilder + .getSessionEntityTypeSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SessionEntityTypesSettings sessionEntityTypesSettings = + sessionEntityTypesSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_sessionentitytypessettings_getsessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..1f906fdf2a9a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.SessionsClient; +import com.google.cloud.dialogflow.v2.SessionsSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionsSettings sessionsSettings = + SessionsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + SessionsClient sessionsClient = SessionsClient.create(sessionsSettings); + } +} +// [END dialogflow_v2_generated_sessionsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..38aae9ef7bd6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.SessionsClient; +import com.google.cloud.dialogflow.v2.SessionsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionsSettings sessionsSettings = + SessionsSettings.newBuilder() + .setTransportChannelProvider( + SessionsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + SessionsClient sessionsClient = SessionsClient.create(sessionsSettings); + } +} +// [END dialogflow_v2_generated_sessionsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..44a7beb10974 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.SessionsClient; +import com.google.cloud.dialogflow.v2.SessionsSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionsSettings sessionsSettings = + SessionsSettings.newBuilder().setEndpoint(myEndpoint).build(); + SessionsClient sessionsClient = SessionsClient.create(sessionsSettings); + } +} +// [END dialogflow_v2_generated_sessionsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/AsyncDetectIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/AsyncDetectIntent.java new file mode 100644 index 000000000000..f752c9cce56a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/AsyncDetectIntent.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionsclient_detectintent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.DetectIntentRequest; +import com.google.cloud.dialogflow.v2.DetectIntentResponse; +import com.google.cloud.dialogflow.v2.OutputAudioConfig; +import com.google.cloud.dialogflow.v2.QueryInput; +import com.google.cloud.dialogflow.v2.QueryParameters; +import com.google.cloud.dialogflow.v2.SessionName; +import com.google.cloud.dialogflow.v2.SessionsClient; +import com.google.protobuf.ByteString; +import com.google.protobuf.FieldMask; + +public class AsyncDetectIntent { + + public static void main(String[] args) throws Exception { + asyncDetectIntent(); + } + + public static void asyncDetectIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionsClient sessionsClient = SessionsClient.create()) { + DetectIntentRequest request = + DetectIntentRequest.newBuilder() + .setSession(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setQueryParams(QueryParameters.newBuilder().build()) + .setQueryInput(QueryInput.newBuilder().build()) + .setOutputAudioConfig(OutputAudioConfig.newBuilder().build()) + .setOutputAudioConfigMask(FieldMask.newBuilder().build()) + .setInputAudio(ByteString.EMPTY) + .build(); + ApiFuture future = + sessionsClient.detectIntentCallable().futureCall(request); + // Do something. + DetectIntentResponse response = future.get(); + } + } +} +// [END dialogflow_v2_generated_sessionsclient_detectintent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/SyncDetectIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/SyncDetectIntent.java new file mode 100644 index 000000000000..cd4c4368bae8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/SyncDetectIntent.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionsclient_detectintent_sync] +import com.google.cloud.dialogflow.v2.DetectIntentRequest; +import com.google.cloud.dialogflow.v2.DetectIntentResponse; +import com.google.cloud.dialogflow.v2.OutputAudioConfig; +import com.google.cloud.dialogflow.v2.QueryInput; +import com.google.cloud.dialogflow.v2.QueryParameters; +import com.google.cloud.dialogflow.v2.SessionName; +import com.google.cloud.dialogflow.v2.SessionsClient; +import com.google.protobuf.ByteString; +import com.google.protobuf.FieldMask; + +public class SyncDetectIntent { + + public static void main(String[] args) throws Exception { + syncDetectIntent(); + } + + public static void syncDetectIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionsClient sessionsClient = SessionsClient.create()) { + DetectIntentRequest request = + DetectIntentRequest.newBuilder() + .setSession(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setQueryParams(QueryParameters.newBuilder().build()) + .setQueryInput(QueryInput.newBuilder().build()) + .setOutputAudioConfig(OutputAudioConfig.newBuilder().build()) + .setOutputAudioConfigMask(FieldMask.newBuilder().build()) + .setInputAudio(ByteString.EMPTY) + .build(); + DetectIntentResponse response = sessionsClient.detectIntent(request); + } + } +} +// [END dialogflow_v2_generated_sessionsclient_detectintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/SyncDetectIntentSessionnameQueryinput.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/SyncDetectIntentSessionnameQueryinput.java new file mode 100644 index 000000000000..c8044dfa1fa0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/SyncDetectIntentSessionnameQueryinput.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionsclient_detectintent_sessionnamequeryinput_sync] +import com.google.cloud.dialogflow.v2.DetectIntentResponse; +import com.google.cloud.dialogflow.v2.QueryInput; +import com.google.cloud.dialogflow.v2.SessionName; +import com.google.cloud.dialogflow.v2.SessionsClient; + +public class SyncDetectIntentSessionnameQueryinput { + + public static void main(String[] args) throws Exception { + syncDetectIntentSessionnameQueryinput(); + } + + public static void syncDetectIntentSessionnameQueryinput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionsClient sessionsClient = SessionsClient.create()) { + SessionName session = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + QueryInput queryInput = QueryInput.newBuilder().build(); + DetectIntentResponse response = sessionsClient.detectIntent(session, queryInput); + } + } +} +// [END dialogflow_v2_generated_sessionsclient_detectintent_sessionnamequeryinput_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/SyncDetectIntentStringQueryinput.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/SyncDetectIntentStringQueryinput.java new file mode 100644 index 000000000000..bd6a14bc3002 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/detectintent/SyncDetectIntentStringQueryinput.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionsclient_detectintent_stringqueryinput_sync] +import com.google.cloud.dialogflow.v2.DetectIntentResponse; +import com.google.cloud.dialogflow.v2.QueryInput; +import com.google.cloud.dialogflow.v2.SessionName; +import com.google.cloud.dialogflow.v2.SessionsClient; + +public class SyncDetectIntentStringQueryinput { + + public static void main(String[] args) throws Exception { + syncDetectIntentStringQueryinput(); + } + + public static void syncDetectIntentStringQueryinput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionsClient sessionsClient = SessionsClient.create()) { + String session = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString(); + QueryInput queryInput = QueryInput.newBuilder().build(); + DetectIntentResponse response = sessionsClient.detectIntent(session, queryInput); + } + } +} +// [END dialogflow_v2_generated_sessionsclient_detectintent_stringqueryinput_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/streamingdetectintent/AsyncStreamingDetectIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/streamingdetectintent/AsyncStreamingDetectIntent.java new file mode 100644 index 000000000000..e807295ce4ee --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionsclient/streamingdetectintent/AsyncStreamingDetectIntent.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionsclient_streamingdetectintent_async] +import com.google.api.gax.rpc.BidiStream; +import com.google.cloud.dialogflow.v2.OutputAudioConfig; +import com.google.cloud.dialogflow.v2.QueryInput; +import com.google.cloud.dialogflow.v2.QueryParameters; +import com.google.cloud.dialogflow.v2.SessionName; +import com.google.cloud.dialogflow.v2.SessionsClient; +import com.google.cloud.dialogflow.v2.StreamingDetectIntentRequest; +import com.google.cloud.dialogflow.v2.StreamingDetectIntentResponse; +import com.google.protobuf.ByteString; +import com.google.protobuf.FieldMask; + +public class AsyncStreamingDetectIntent { + + public static void main(String[] args) throws Exception { + asyncStreamingDetectIntent(); + } + + public static void asyncStreamingDetectIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionsClient sessionsClient = SessionsClient.create()) { + BidiStream bidiStream = + sessionsClient.streamingDetectIntentCallable().call(); + StreamingDetectIntentRequest request = + StreamingDetectIntentRequest.newBuilder() + .setSession(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setQueryParams(QueryParameters.newBuilder().build()) + .setQueryInput(QueryInput.newBuilder().build()) + .setSingleUtterance(true) + .setOutputAudioConfig(OutputAudioConfig.newBuilder().build()) + .setOutputAudioConfigMask(FieldMask.newBuilder().build()) + .setInputAudio(ByteString.EMPTY) + .build(); + bidiStream.send(request); + for (StreamingDetectIntentResponse response : bidiStream) { + // Do something when a response is received. + } + } + } +} +// [END dialogflow_v2_generated_sessionsclient_streamingdetectintent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionssettings/detectintent/SyncDetectIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionssettings/detectintent/SyncDetectIntent.java new file mode 100644 index 000000000000..f1ad732acc81 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/sessionssettings/detectintent/SyncDetectIntent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionssettings_detectintent_sync] +import com.google.cloud.dialogflow.v2.SessionsSettings; +import java.time.Duration; + +public class SyncDetectIntent { + + public static void main(String[] args) throws Exception { + syncDetectIntent(); + } + + public static void syncDetectIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionsSettings.Builder sessionsSettingsBuilder = SessionsSettings.newBuilder(); + sessionsSettingsBuilder + .detectIntentSettings() + .setRetrySettings( + sessionsSettingsBuilder + .detectIntentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SessionsSettings sessionsSettings = sessionsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_sessionssettings_detectintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/agentsstubsettings/getagent/SyncGetAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/agentsstubsettings/getagent/SyncGetAgent.java new file mode 100644 index 000000000000..aa208a9806fa --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/agentsstubsettings/getagent/SyncGetAgent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_agentsstubsettings_getagent_sync] +import com.google.cloud.dialogflow.v2.stub.AgentsStubSettings; +import java.time.Duration; + +public class SyncGetAgent { + + public static void main(String[] args) throws Exception { + syncGetAgent(); + } + + public static void syncGetAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AgentsStubSettings.Builder agentsSettingsBuilder = AgentsStubSettings.newBuilder(); + agentsSettingsBuilder + .getAgentSettings() + .setRetrySettings( + agentsSettingsBuilder + .getAgentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + AgentsStubSettings agentsSettings = agentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_agentsstubsettings_getagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/answerrecordsstubsettings/updateanswerrecord/SyncUpdateAnswerRecord.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/answerrecordsstubsettings/updateanswerrecord/SyncUpdateAnswerRecord.java new file mode 100644 index 000000000000..b633221a1ad6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/answerrecordsstubsettings/updateanswerrecord/SyncUpdateAnswerRecord.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_answerrecordsstubsettings_updateanswerrecord_sync] +import com.google.cloud.dialogflow.v2.stub.AnswerRecordsStubSettings; +import java.time.Duration; + +public class SyncUpdateAnswerRecord { + + public static void main(String[] args) throws Exception { + syncUpdateAnswerRecord(); + } + + public static void syncUpdateAnswerRecord() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AnswerRecordsStubSettings.Builder answerRecordsSettingsBuilder = + AnswerRecordsStubSettings.newBuilder(); + answerRecordsSettingsBuilder + .updateAnswerRecordSettings() + .setRetrySettings( + answerRecordsSettingsBuilder + .updateAnswerRecordSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + AnswerRecordsStubSettings answerRecordsSettings = answerRecordsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_answerrecordsstubsettings_updateanswerrecord_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/contextsstubsettings/getcontext/SyncGetContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/contextsstubsettings/getcontext/SyncGetContext.java new file mode 100644 index 000000000000..04aa80761376 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/contextsstubsettings/getcontext/SyncGetContext.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_contextsstubsettings_getcontext_sync] +import com.google.cloud.dialogflow.v2.stub.ContextsStubSettings; +import java.time.Duration; + +public class SyncGetContext { + + public static void main(String[] args) throws Exception { + syncGetContext(); + } + + public static void syncGetContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ContextsStubSettings.Builder contextsSettingsBuilder = ContextsStubSettings.newBuilder(); + contextsSettingsBuilder + .getContextSettings() + .setRetrySettings( + contextsSettingsBuilder + .getContextSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ContextsStubSettings contextsSettings = contextsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_contextsstubsettings_getcontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationdatasetsstubsettings/getconversationdataset/SyncGetConversationDataset.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationdatasetsstubsettings/getconversationdataset/SyncGetConversationDataset.java new file mode 100644 index 000000000000..e4a8924b6357 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationdatasetsstubsettings/getconversationdataset/SyncGetConversationDataset.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationdatasetsstubsettings_getconversationdataset_sync] +import com.google.cloud.dialogflow.v2.stub.ConversationDatasetsStubSettings; +import java.time.Duration; + +public class SyncGetConversationDataset { + + public static void main(String[] args) throws Exception { + syncGetConversationDataset(); + } + + public static void syncGetConversationDataset() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationDatasetsStubSettings.Builder conversationDatasetsSettingsBuilder = + ConversationDatasetsStubSettings.newBuilder(); + conversationDatasetsSettingsBuilder + .getConversationDatasetSettings() + .setRetrySettings( + conversationDatasetsSettingsBuilder + .getConversationDatasetSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConversationDatasetsStubSettings conversationDatasetsSettings = + conversationDatasetsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_conversationdatasetsstubsettings_getconversationdataset_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationmodelsstubsettings/getconversationmodel/SyncGetConversationModel.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationmodelsstubsettings/getconversationmodel/SyncGetConversationModel.java new file mode 100644 index 000000000000..ae3e1b150ca5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationmodelsstubsettings/getconversationmodel/SyncGetConversationModel.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationmodelsstubsettings_getconversationmodel_sync] +import com.google.cloud.dialogflow.v2.stub.ConversationModelsStubSettings; +import java.time.Duration; + +public class SyncGetConversationModel { + + public static void main(String[] args) throws Exception { + syncGetConversationModel(); + } + + public static void syncGetConversationModel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationModelsStubSettings.Builder conversationModelsSettingsBuilder = + ConversationModelsStubSettings.newBuilder(); + conversationModelsSettingsBuilder + .getConversationModelSettings() + .setRetrySettings( + conversationModelsSettingsBuilder + .getConversationModelSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConversationModelsStubSettings conversationModelsSettings = + conversationModelsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_conversationmodelsstubsettings_getconversationmodel_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationprofilesstubsettings/getconversationprofile/SyncGetConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationprofilesstubsettings/getconversationprofile/SyncGetConversationProfile.java new file mode 100644 index 000000000000..2eb32809a19d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationprofilesstubsettings/getconversationprofile/SyncGetConversationProfile.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationprofilesstubsettings_getconversationprofile_sync] +import com.google.cloud.dialogflow.v2.stub.ConversationProfilesStubSettings; +import java.time.Duration; + +public class SyncGetConversationProfile { + + public static void main(String[] args) throws Exception { + syncGetConversationProfile(); + } + + public static void syncGetConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationProfilesStubSettings.Builder conversationProfilesSettingsBuilder = + ConversationProfilesStubSettings.newBuilder(); + conversationProfilesSettingsBuilder + .getConversationProfileSettings() + .setRetrySettings( + conversationProfilesSettingsBuilder + .getConversationProfileSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConversationProfilesStubSettings conversationProfilesSettings = + conversationProfilesSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_conversationprofilesstubsettings_getconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationsstubsettings/createconversation/SyncCreateConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationsstubsettings/createconversation/SyncCreateConversation.java new file mode 100644 index 000000000000..a4c3540bb036 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/conversationsstubsettings/createconversation/SyncCreateConversation.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_conversationsstubsettings_createconversation_sync] +import com.google.cloud.dialogflow.v2.stub.ConversationsStubSettings; +import java.time.Duration; + +public class SyncCreateConversation { + + public static void main(String[] args) throws Exception { + syncCreateConversation(); + } + + public static void syncCreateConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationsStubSettings.Builder conversationsSettingsBuilder = + ConversationsStubSettings.newBuilder(); + conversationsSettingsBuilder + .createConversationSettings() + .setRetrySettings( + conversationsSettingsBuilder + .createConversationSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConversationsStubSettings conversationsSettings = conversationsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_conversationsstubsettings_createconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/documentsstubsettings/getdocument/SyncGetDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/documentsstubsettings/getdocument/SyncGetDocument.java new file mode 100644 index 000000000000..cee7a16cf36e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/documentsstubsettings/getdocument/SyncGetDocument.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_documentsstubsettings_getdocument_sync] +import com.google.cloud.dialogflow.v2.stub.DocumentsStubSettings; +import java.time.Duration; + +public class SyncGetDocument { + + public static void main(String[] args) throws Exception { + syncGetDocument(); + } + + public static void syncGetDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentsStubSettings.Builder documentsSettingsBuilder = DocumentsStubSettings.newBuilder(); + documentsSettingsBuilder + .getDocumentSettings() + .setRetrySettings( + documentsSettingsBuilder + .getDocumentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DocumentsStubSettings documentsSettings = documentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_documentsstubsettings_getdocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/entitytypesstubsettings/getentitytype/SyncGetEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/entitytypesstubsettings/getentitytype/SyncGetEntityType.java new file mode 100644 index 000000000000..5b0617ed3dc9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/entitytypesstubsettings/getentitytype/SyncGetEntityType.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_entitytypesstubsettings_getentitytype_sync] +import com.google.cloud.dialogflow.v2.stub.EntityTypesStubSettings; +import java.time.Duration; + +public class SyncGetEntityType { + + public static void main(String[] args) throws Exception { + syncGetEntityType(); + } + + public static void syncGetEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EntityTypesStubSettings.Builder entityTypesSettingsBuilder = + EntityTypesStubSettings.newBuilder(); + entityTypesSettingsBuilder + .getEntityTypeSettings() + .setRetrySettings( + entityTypesSettingsBuilder + .getEntityTypeSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + EntityTypesStubSettings entityTypesSettings = entityTypesSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_entitytypesstubsettings_getentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.java new file mode 100644 index 000000000000..aad4ce6515b3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_environmentsstubsettings_getenvironment_sync] +import com.google.cloud.dialogflow.v2.stub.EnvironmentsStubSettings; +import java.time.Duration; + +public class SyncGetEnvironment { + + public static void main(String[] args) throws Exception { + syncGetEnvironment(); + } + + public static void syncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsStubSettings.Builder environmentsSettingsBuilder = + EnvironmentsStubSettings.newBuilder(); + environmentsSettingsBuilder + .getEnvironmentSettings() + .setRetrySettings( + environmentsSettingsBuilder + .getEnvironmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + EnvironmentsStubSettings environmentsSettings = environmentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_environmentsstubsettings_getenvironment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/fulfillmentsstubsettings/getfulfillment/SyncGetFulfillment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/fulfillmentsstubsettings/getfulfillment/SyncGetFulfillment.java new file mode 100644 index 000000000000..ad00d92426f8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/fulfillmentsstubsettings/getfulfillment/SyncGetFulfillment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_fulfillmentsstubsettings_getfulfillment_sync] +import com.google.cloud.dialogflow.v2.stub.FulfillmentsStubSettings; +import java.time.Duration; + +public class SyncGetFulfillment { + + public static void main(String[] args) throws Exception { + syncGetFulfillment(); + } + + public static void syncGetFulfillment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + FulfillmentsStubSettings.Builder fulfillmentsSettingsBuilder = + FulfillmentsStubSettings.newBuilder(); + fulfillmentsSettingsBuilder + .getFulfillmentSettings() + .setRetrySettings( + fulfillmentsSettingsBuilder + .getFulfillmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + FulfillmentsStubSettings fulfillmentsSettings = fulfillmentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_fulfillmentsstubsettings_getfulfillment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/intentsstubsettings/getintent/SyncGetIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/intentsstubsettings/getintent/SyncGetIntent.java new file mode 100644 index 000000000000..123fb69b4d1a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/intentsstubsettings/getintent/SyncGetIntent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_intentsstubsettings_getintent_sync] +import com.google.cloud.dialogflow.v2.stub.IntentsStubSettings; +import java.time.Duration; + +public class SyncGetIntent { + + public static void main(String[] args) throws Exception { + syncGetIntent(); + } + + public static void syncGetIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + IntentsStubSettings.Builder intentsSettingsBuilder = IntentsStubSettings.newBuilder(); + intentsSettingsBuilder + .getIntentSettings() + .setRetrySettings( + intentsSettingsBuilder + .getIntentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + IntentsStubSettings intentsSettings = intentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_intentsstubsettings_getintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/knowledgebasesstubsettings/getknowledgebase/SyncGetKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/knowledgebasesstubsettings/getknowledgebase/SyncGetKnowledgeBase.java new file mode 100644 index 000000000000..a2f0a36a16a6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/knowledgebasesstubsettings/getknowledgebase/SyncGetKnowledgeBase.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_knowledgebasesstubsettings_getknowledgebase_sync] +import com.google.cloud.dialogflow.v2.stub.KnowledgeBasesStubSettings; +import java.time.Duration; + +public class SyncGetKnowledgeBase { + + public static void main(String[] args) throws Exception { + syncGetKnowledgeBase(); + } + + public static void syncGetKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + KnowledgeBasesStubSettings.Builder knowledgeBasesSettingsBuilder = + KnowledgeBasesStubSettings.newBuilder(); + knowledgeBasesSettingsBuilder + .getKnowledgeBaseSettings() + .setRetrySettings( + knowledgeBasesSettingsBuilder + .getKnowledgeBaseSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + KnowledgeBasesStubSettings knowledgeBasesSettings = knowledgeBasesSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_knowledgebasesstubsettings_getknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/participantsstubsettings/createparticipant/SyncCreateParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/participantsstubsettings/createparticipant/SyncCreateParticipant.java new file mode 100644 index 000000000000..cc31092b03de --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/participantsstubsettings/createparticipant/SyncCreateParticipant.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_participantsstubsettings_createparticipant_sync] +import com.google.cloud.dialogflow.v2.stub.ParticipantsStubSettings; +import java.time.Duration; + +public class SyncCreateParticipant { + + public static void main(String[] args) throws Exception { + syncCreateParticipant(); + } + + public static void syncCreateParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ParticipantsStubSettings.Builder participantsSettingsBuilder = + ParticipantsStubSettings.newBuilder(); + participantsSettingsBuilder + .createParticipantSettings() + .setRetrySettings( + participantsSettingsBuilder + .createParticipantSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ParticipantsStubSettings participantsSettings = participantsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_participantsstubsettings_createparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/sessionentitytypesstubsettings/getsessionentitytype/SyncGetSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/sessionentitytypesstubsettings/getsessionentitytype/SyncGetSessionEntityType.java new file mode 100644 index 000000000000..cd6f112fe144 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/sessionentitytypesstubsettings/getsessionentitytype/SyncGetSessionEntityType.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionentitytypesstubsettings_getsessionentitytype_sync] +import com.google.cloud.dialogflow.v2.stub.SessionEntityTypesStubSettings; +import java.time.Duration; + +public class SyncGetSessionEntityType { + + public static void main(String[] args) throws Exception { + syncGetSessionEntityType(); + } + + public static void syncGetSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionEntityTypesStubSettings.Builder sessionEntityTypesSettingsBuilder = + SessionEntityTypesStubSettings.newBuilder(); + sessionEntityTypesSettingsBuilder + .getSessionEntityTypeSettings() + .setRetrySettings( + sessionEntityTypesSettingsBuilder + .getSessionEntityTypeSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SessionEntityTypesStubSettings sessionEntityTypesSettings = + sessionEntityTypesSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_sessionentitytypesstubsettings_getsessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/sessionsstubsettings/detectintent/SyncDetectIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/sessionsstubsettings/detectintent/SyncDetectIntent.java new file mode 100644 index 000000000000..54a0dc5401d7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/sessionsstubsettings/detectintent/SyncDetectIntent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_sessionsstubsettings_detectintent_sync] +import com.google.cloud.dialogflow.v2.stub.SessionsStubSettings; +import java.time.Duration; + +public class SyncDetectIntent { + + public static void main(String[] args) throws Exception { + syncDetectIntent(); + } + + public static void syncDetectIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionsStubSettings.Builder sessionsSettingsBuilder = SessionsStubSettings.newBuilder(); + sessionsSettingsBuilder + .detectIntentSettings() + .setRetrySettings( + sessionsSettingsBuilder + .detectIntentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SessionsStubSettings sessionsSettings = sessionsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_sessionsstubsettings_detectintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/versionsstubsettings/getversion/SyncGetVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/versionsstubsettings/getversion/SyncGetVersion.java new file mode 100644 index 000000000000..a43f2881530c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/stub/versionsstubsettings/getversion/SyncGetVersion.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsstubsettings_getversion_sync] +import com.google.cloud.dialogflow.v2.stub.VersionsStubSettings; +import java.time.Duration; + +public class SyncGetVersion { + + public static void main(String[] args) throws Exception { + syncGetVersion(); + } + + public static void syncGetVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VersionsStubSettings.Builder versionsSettingsBuilder = VersionsStubSettings.newBuilder(); + versionsSettingsBuilder + .getVersionSettings() + .setRetrySettings( + versionsSettingsBuilder + .getVersionSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VersionsStubSettings versionsSettings = versionsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_versionsstubsettings_getversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..8d0364390ac0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2.VersionsClient; +import com.google.cloud.dialogflow.v2.VersionsSettings; +import com.google.cloud.dialogflow.v2.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VersionsSettings versionsSettings = + VersionsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + VersionsClient versionsClient = VersionsClient.create(versionsSettings); + } +} +// [END dialogflow_v2_generated_versionsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..9749eb6f5c80 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2.VersionsClient; +import com.google.cloud.dialogflow.v2.VersionsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VersionsSettings versionsSettings = + VersionsSettings.newBuilder() + .setTransportChannelProvider( + VersionsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + VersionsClient versionsClient = VersionsClient.create(versionsSettings); + } +} +// [END dialogflow_v2_generated_versionsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..ffd0036a0aa1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2.VersionsClient; +import com.google.cloud.dialogflow.v2.VersionsSettings; +import com.google.cloud.dialogflow.v2.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VersionsSettings versionsSettings = + VersionsSettings.newBuilder().setEndpoint(myEndpoint).build(); + VersionsClient versionsClient = VersionsClient.create(versionsSettings); + } +} +// [END dialogflow_v2_generated_versionsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/AsyncCreateVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/AsyncCreateVersion.java new file mode 100644 index 000000000000..7f44a1f31c8a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/AsyncCreateVersion.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_createversion_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.CreateVersionRequest; +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class AsyncCreateVersion { + + public static void main(String[] args) throws Exception { + asyncCreateVersion(); + } + + public static void asyncCreateVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + CreateVersionRequest request = + CreateVersionRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setVersion(Version.newBuilder().build()) + .build(); + ApiFuture future = versionsClient.createVersionCallable().futureCall(request); + // Do something. + Version response = future.get(); + } + } +} +// [END dialogflow_v2_generated_versionsclient_createversion_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/SyncCreateVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/SyncCreateVersion.java new file mode 100644 index 000000000000..a98ca1d07eae --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/SyncCreateVersion.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_createversion_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.CreateVersionRequest; +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class SyncCreateVersion { + + public static void main(String[] args) throws Exception { + syncCreateVersion(); + } + + public static void syncCreateVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + CreateVersionRequest request = + CreateVersionRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setVersion(Version.newBuilder().build()) + .build(); + Version response = versionsClient.createVersion(request); + } + } +} +// [END dialogflow_v2_generated_versionsclient_createversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/SyncCreateVersionAgentnameVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/SyncCreateVersionAgentnameVersion.java new file mode 100644 index 000000000000..962b1d14059f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/SyncCreateVersionAgentnameVersion.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_createversion_agentnameversion_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class SyncCreateVersionAgentnameVersion { + + public static void main(String[] args) throws Exception { + syncCreateVersionAgentnameVersion(); + } + + public static void syncCreateVersionAgentnameVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Version version = Version.newBuilder().build(); + Version response = versionsClient.createVersion(parent, version); + } + } +} +// [END dialogflow_v2_generated_versionsclient_createversion_agentnameversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/SyncCreateVersionStringVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/SyncCreateVersionStringVersion.java new file mode 100644 index 000000000000..702d50e07d2d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/createversion/SyncCreateVersionStringVersion.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_createversion_stringversion_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class SyncCreateVersionStringVersion { + + public static void main(String[] args) throws Exception { + syncCreateVersionStringVersion(); + } + + public static void syncCreateVersionStringVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + Version version = Version.newBuilder().build(); + Version response = versionsClient.createVersion(parent, version); + } + } +} +// [END dialogflow_v2_generated_versionsclient_createversion_stringversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/AsyncDeleteVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/AsyncDeleteVersion.java new file mode 100644 index 000000000000..712782967876 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/AsyncDeleteVersion.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_deleteversion_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.DeleteVersionRequest; +import com.google.cloud.dialogflow.v2.VersionName; +import com.google.cloud.dialogflow.v2.VersionsClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteVersion { + + public static void main(String[] args) throws Exception { + asyncDeleteVersion(); + } + + public static void asyncDeleteVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + DeleteVersionRequest request = + DeleteVersionRequest.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .build(); + ApiFuture future = versionsClient.deleteVersionCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2_generated_versionsclient_deleteversion_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/SyncDeleteVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/SyncDeleteVersion.java new file mode 100644 index 000000000000..1ffcd99e2bb2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/SyncDeleteVersion.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_deleteversion_sync] +import com.google.cloud.dialogflow.v2.DeleteVersionRequest; +import com.google.cloud.dialogflow.v2.VersionName; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class SyncDeleteVersion { + + public static void main(String[] args) throws Exception { + syncDeleteVersion(); + } + + public static void syncDeleteVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + DeleteVersionRequest request = + DeleteVersionRequest.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .build(); + versionsClient.deleteVersion(request); + } + } +} +// [END dialogflow_v2_generated_versionsclient_deleteversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/SyncDeleteVersionString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/SyncDeleteVersionString.java new file mode 100644 index 000000000000..862e46d56b37 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/SyncDeleteVersionString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_deleteversion_string_sync] +import com.google.cloud.dialogflow.v2.VersionName; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class SyncDeleteVersionString { + + public static void main(String[] args) throws Exception { + syncDeleteVersionString(); + } + + public static void syncDeleteVersionString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + String name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString(); + versionsClient.deleteVersion(name); + } + } +} +// [END dialogflow_v2_generated_versionsclient_deleteversion_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/SyncDeleteVersionVersionname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/SyncDeleteVersionVersionname.java new file mode 100644 index 000000000000..733080e4e246 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/deleteversion/SyncDeleteVersionVersionname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_deleteversion_versionname_sync] +import com.google.cloud.dialogflow.v2.VersionName; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class SyncDeleteVersionVersionname { + + public static void main(String[] args) throws Exception { + syncDeleteVersionVersionname(); + } + + public static void syncDeleteVersionVersionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]"); + versionsClient.deleteVersion(name); + } + } +} +// [END dialogflow_v2_generated_versionsclient_deleteversion_versionname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/AsyncGetVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/AsyncGetVersion.java new file mode 100644 index 000000000000..41219572b533 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/AsyncGetVersion.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_getversion_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.GetVersionRequest; +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionName; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class AsyncGetVersion { + + public static void main(String[] args) throws Exception { + asyncGetVersion(); + } + + public static void asyncGetVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + GetVersionRequest request = + GetVersionRequest.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .build(); + ApiFuture future = versionsClient.getVersionCallable().futureCall(request); + // Do something. + Version response = future.get(); + } + } +} +// [END dialogflow_v2_generated_versionsclient_getversion_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/SyncGetVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/SyncGetVersion.java new file mode 100644 index 000000000000..54c700c8237e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/SyncGetVersion.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_getversion_sync] +import com.google.cloud.dialogflow.v2.GetVersionRequest; +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionName; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class SyncGetVersion { + + public static void main(String[] args) throws Exception { + syncGetVersion(); + } + + public static void syncGetVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + GetVersionRequest request = + GetVersionRequest.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .build(); + Version response = versionsClient.getVersion(request); + } + } +} +// [END dialogflow_v2_generated_versionsclient_getversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/SyncGetVersionString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/SyncGetVersionString.java new file mode 100644 index 000000000000..6872911d7827 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/SyncGetVersionString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_getversion_string_sync] +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionName; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class SyncGetVersionString { + + public static void main(String[] args) throws Exception { + syncGetVersionString(); + } + + public static void syncGetVersionString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + String name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString(); + Version response = versionsClient.getVersion(name); + } + } +} +// [END dialogflow_v2_generated_versionsclient_getversion_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/SyncGetVersionVersionname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/SyncGetVersionVersionname.java new file mode 100644 index 000000000000..69f5697e8915 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/getversion/SyncGetVersionVersionname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_getversion_versionname_sync] +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionName; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class SyncGetVersionVersionname { + + public static void main(String[] args) throws Exception { + syncGetVersionVersionname(); + } + + public static void syncGetVersionVersionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]"); + Version response = versionsClient.getVersion(name); + } + } +} +// [END dialogflow_v2_generated_versionsclient_getversion_versionname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/AsyncListVersions.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/AsyncListVersions.java new file mode 100644 index 000000000000..077772b023f6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/AsyncListVersions.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_listversions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.ListVersionsRequest; +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class AsyncListVersions { + + public static void main(String[] args) throws Exception { + asyncListVersions(); + } + + public static void asyncListVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + ListVersionsRequest request = + ListVersionsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = versionsClient.listVersionsPagedCallable().futureCall(request); + // Do something. + for (Version element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_versionsclient_listversions_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/AsyncListVersionsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/AsyncListVersionsPaged.java new file mode 100644 index 000000000000..7d4fac4c8268 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/AsyncListVersionsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_listversions_paged_async] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.ListVersionsRequest; +import com.google.cloud.dialogflow.v2.ListVersionsResponse; +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionsClient; +import com.google.common.base.Strings; + +public class AsyncListVersionsPaged { + + public static void main(String[] args) throws Exception { + asyncListVersionsPaged(); + } + + public static void asyncListVersionsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + ListVersionsRequest request = + ListVersionsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListVersionsResponse response = versionsClient.listVersionsCallable().call(request); + for (Version element : response.getVersionsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2_generated_versionsclient_listversions_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/SyncListVersions.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/SyncListVersions.java new file mode 100644 index 000000000000..1d660ea97484 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/SyncListVersions.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_listversions_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.ListVersionsRequest; +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class SyncListVersions { + + public static void main(String[] args) throws Exception { + syncListVersions(); + } + + public static void syncListVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + ListVersionsRequest request = + ListVersionsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Version element : versionsClient.listVersions(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_versionsclient_listversions_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/SyncListVersionsAgentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/SyncListVersionsAgentname.java new file mode 100644 index 000000000000..a83aea6fcc78 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/SyncListVersionsAgentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_listversions_agentname_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class SyncListVersionsAgentname { + + public static void main(String[] args) throws Exception { + syncListVersionsAgentname(); + } + + public static void syncListVersionsAgentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + for (Version element : versionsClient.listVersions(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_versionsclient_listversions_agentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/SyncListVersionsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/SyncListVersionsString.java new file mode 100644 index 000000000000..5732655fc014 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/listversions/SyncListVersionsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_listversions_string_sync] +import com.google.cloud.dialogflow.v2.AgentName; +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionsClient; + +public class SyncListVersionsString { + + public static void main(String[] args) throws Exception { + syncListVersionsString(); + } + + public static void syncListVersionsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + for (Version element : versionsClient.listVersions(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2_generated_versionsclient_listversions_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/updateversion/AsyncUpdateVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/updateversion/AsyncUpdateVersion.java new file mode 100644 index 000000000000..3ca79a402a1d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/updateversion/AsyncUpdateVersion.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_updateversion_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2.UpdateVersionRequest; +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionsClient; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateVersion { + + public static void main(String[] args) throws Exception { + asyncUpdateVersion(); + } + + public static void asyncUpdateVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + UpdateVersionRequest request = + UpdateVersionRequest.newBuilder() + .setVersion(Version.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = versionsClient.updateVersionCallable().futureCall(request); + // Do something. + Version response = future.get(); + } + } +} +// [END dialogflow_v2_generated_versionsclient_updateversion_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/updateversion/SyncUpdateVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/updateversion/SyncUpdateVersion.java new file mode 100644 index 000000000000..43a4b33e814a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/updateversion/SyncUpdateVersion.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_updateversion_sync] +import com.google.cloud.dialogflow.v2.UpdateVersionRequest; +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateVersion { + + public static void main(String[] args) throws Exception { + syncUpdateVersion(); + } + + public static void syncUpdateVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + UpdateVersionRequest request = + UpdateVersionRequest.newBuilder() + .setVersion(Version.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Version response = versionsClient.updateVersion(request); + } + } +} +// [END dialogflow_v2_generated_versionsclient_updateversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/updateversion/SyncUpdateVersionVersionFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/updateversion/SyncUpdateVersionVersionFieldmask.java new file mode 100644 index 000000000000..f459525a687f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionsclient/updateversion/SyncUpdateVersionVersionFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionsclient_updateversion_versionfieldmask_sync] +import com.google.cloud.dialogflow.v2.Version; +import com.google.cloud.dialogflow.v2.VersionsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateVersionVersionFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateVersionVersionFieldmask(); + } + + public static void syncUpdateVersionVersionFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + Version version = Version.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Version response = versionsClient.updateVersion(version, updateMask); + } + } +} +// [END dialogflow_v2_generated_versionsclient_updateversion_versionfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionssettings/getversion/SyncGetVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionssettings/getversion/SyncGetVersion.java new file mode 100644 index 000000000000..8c8f01d3229c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2/versionssettings/getversion/SyncGetVersion.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START dialogflow_v2_generated_versionssettings_getversion_sync] +import com.google.cloud.dialogflow.v2.VersionsSettings; +import java.time.Duration; + +public class SyncGetVersion { + + public static void main(String[] args) throws Exception { + syncGetVersion(); + } + + public static void syncGetVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VersionsSettings.Builder versionsSettingsBuilder = VersionsSettings.newBuilder(); + versionsSettingsBuilder + .getVersionSettings() + .setRetrySettings( + versionsSettingsBuilder + .getVersionSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VersionsSettings versionsSettings = versionsSettingsBuilder.build(); + } +} +// [END dialogflow_v2_generated_versionssettings_getversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..051175d26f1e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.AgentsSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AgentsSettings agentsSettings = + AgentsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + AgentsClient agentsClient = AgentsClient.create(agentsSettings); + } +} +// [END dialogflow_v2beta1_generated_agentsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..7c53b15356b9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.AgentsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AgentsSettings agentsSettings = + AgentsSettings.newBuilder() + .setTransportChannelProvider( + AgentsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + AgentsClient agentsClient = AgentsClient.create(agentsSettings); + } +} +// [END dialogflow_v2beta1_generated_agentsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..070133e9be3e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,37 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.AgentsSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AgentsSettings agentsSettings = AgentsSettings.newBuilder().setEndpoint(myEndpoint).build(); + AgentsClient agentsClient = AgentsClient.create(agentsSettings); + } +} +// [END dialogflow_v2beta1_generated_agentsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/AsyncDeleteAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/AsyncDeleteAgent.java new file mode 100644 index 000000000000..46b738b0f03a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/AsyncDeleteAgent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_deleteagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.DeleteAgentRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.protobuf.Empty; + +public class AsyncDeleteAgent { + + public static void main(String[] args) throws Exception { + asyncDeleteAgent(); + } + + public static void asyncDeleteAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + DeleteAgentRequest request = + DeleteAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + ApiFuture future = agentsClient.deleteAgentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_deleteagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgent.java new file mode 100644 index 000000000000..a331dffd922c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgent.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_deleteagent_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.DeleteAgentRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncDeleteAgent { + + public static void main(String[] args) throws Exception { + syncDeleteAgent(); + } + + public static void syncDeleteAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + DeleteAgentRequest request = + DeleteAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + agentsClient.deleteAgent(request); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_deleteagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgentLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgentLocationname.java new file mode 100644 index 000000000000..e7e4cae0c0cf --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgentLocationname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_deleteagent_locationname_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.LocationName; + +public class SyncDeleteAgentLocationname { + + public static void main(String[] args) throws Exception { + syncDeleteAgentLocationname(); + } + + public static void syncDeleteAgentLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + agentsClient.deleteAgent(parent); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_deleteagent_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgentProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgentProjectname.java new file mode 100644 index 000000000000..5099627e3be2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgentProjectname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_deleteagent_projectname_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncDeleteAgentProjectname { + + public static void main(String[] args) throws Exception { + syncDeleteAgentProjectname(); + } + + public static void syncDeleteAgentProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + agentsClient.deleteAgent(parent); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_deleteagent_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgentString.java new file mode 100644 index 000000000000..7399bf2b146f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/deleteagent/SyncDeleteAgentString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_deleteagent_string_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncDeleteAgentString { + + public static void main(String[] args) throws Exception { + syncDeleteAgentString(); + } + + public static void syncDeleteAgentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + agentsClient.deleteAgent(parent); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_deleteagent_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/AsyncExportAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/AsyncExportAgent.java new file mode 100644 index 000000000000..0b3cb9b35876 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/AsyncExportAgent.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_exportagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ExportAgentRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.longrunning.Operation; + +public class AsyncExportAgent { + + public static void main(String[] args) throws Exception { + asyncExportAgent(); + } + + public static void asyncExportAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ExportAgentRequest request = + ExportAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setAgentUri("agentUri1469149223") + .build(); + ApiFuture future = agentsClient.exportAgentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_exportagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/AsyncExportAgentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/AsyncExportAgentLRO.java new file mode 100644 index 000000000000..f54ea3b5044b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/AsyncExportAgentLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_exportagent_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ExportAgentRequest; +import com.google.cloud.dialogflow.v2beta1.ExportAgentResponse; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.protobuf.Struct; + +public class AsyncExportAgentLRO { + + public static void main(String[] args) throws Exception { + asyncExportAgentLRO(); + } + + public static void asyncExportAgentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ExportAgentRequest request = + ExportAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setAgentUri("agentUri1469149223") + .build(); + OperationFuture future = + agentsClient.exportAgentOperationCallable().futureCall(request); + // Do something. + ExportAgentResponse response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_exportagent_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgent.java new file mode 100644 index 000000000000..4bb5ce8c13ab --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_exportagent_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ExportAgentRequest; +import com.google.cloud.dialogflow.v2beta1.ExportAgentResponse; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncExportAgent { + + public static void main(String[] args) throws Exception { + syncExportAgent(); + } + + public static void syncExportAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ExportAgentRequest request = + ExportAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setAgentUri("agentUri1469149223") + .build(); + ExportAgentResponse response = agentsClient.exportAgentAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_exportagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgentLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgentLocationname.java new file mode 100644 index 000000000000..af6f1853f988 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgentLocationname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_exportagent_locationname_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ExportAgentResponse; +import com.google.cloud.dialogflow.v2beta1.LocationName; + +public class SyncExportAgentLocationname { + + public static void main(String[] args) throws Exception { + syncExportAgentLocationname(); + } + + public static void syncExportAgentLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ExportAgentResponse response = agentsClient.exportAgentAsync(parent).get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_exportagent_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgentProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgentProjectname.java new file mode 100644 index 000000000000..e357a0677ac9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgentProjectname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_exportagent_projectname_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ExportAgentResponse; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncExportAgentProjectname { + + public static void main(String[] args) throws Exception { + syncExportAgentProjectname(); + } + + public static void syncExportAgentProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + ExportAgentResponse response = agentsClient.exportAgentAsync(parent).get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_exportagent_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgentString.java new file mode 100644 index 000000000000..5b6992afdfa5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/exportagent/SyncExportAgentString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_exportagent_string_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ExportAgentResponse; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncExportAgentString { + + public static void main(String[] args) throws Exception { + syncExportAgentString(); + } + + public static void syncExportAgentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + ExportAgentResponse response = agentsClient.exportAgentAsync(parent).get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_exportagent_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/AsyncGetAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/AsyncGetAgent.java new file mode 100644 index 000000000000..cebf8ddf27ab --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/AsyncGetAgent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_getagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.GetAgentRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class AsyncGetAgent { + + public static void main(String[] args) throws Exception { + asyncGetAgent(); + } + + public static void asyncGetAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + GetAgentRequest request = + GetAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + ApiFuture future = agentsClient.getAgentCallable().futureCall(request); + // Do something. + Agent response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_getagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgent.java new file mode 100644 index 000000000000..27081d957fa9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgent.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_getagent_sync] +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.GetAgentRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncGetAgent { + + public static void main(String[] args) throws Exception { + syncGetAgent(); + } + + public static void syncGetAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + GetAgentRequest request = + GetAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + Agent response = agentsClient.getAgent(request); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_getagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgentLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgentLocationname.java new file mode 100644 index 000000000000..7d9668dace33 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgentLocationname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_getagent_locationname_sync] +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.LocationName; + +public class SyncGetAgentLocationname { + + public static void main(String[] args) throws Exception { + syncGetAgentLocationname(); + } + + public static void syncGetAgentLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Agent response = agentsClient.getAgent(parent); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_getagent_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgentProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgentProjectname.java new file mode 100644 index 000000000000..351e93cfc46c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgentProjectname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_getagent_projectname_sync] +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncGetAgentProjectname { + + public static void main(String[] args) throws Exception { + syncGetAgentProjectname(); + } + + public static void syncGetAgentProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + Agent response = agentsClient.getAgent(parent); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_getagent_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgentString.java new file mode 100644 index 000000000000..85e06e221905 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getagent/SyncGetAgentString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_getagent_string_sync] +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncGetAgentString { + + public static void main(String[] args) throws Exception { + syncGetAgentString(); + } + + public static void syncGetAgentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + Agent response = agentsClient.getAgent(parent); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_getagent_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getvalidationresult/AsyncGetValidationResult.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getvalidationresult/AsyncGetValidationResult.java new file mode 100644 index 000000000000..9065c8e74d7f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getvalidationresult/AsyncGetValidationResult.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_getvalidationresult_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.GetValidationResultRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.cloud.dialogflow.v2beta1.ValidationResult; + +public class AsyncGetValidationResult { + + public static void main(String[] args) throws Exception { + asyncGetValidationResult(); + } + + public static void asyncGetValidationResult() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + GetValidationResultRequest request = + GetValidationResultRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .build(); + ApiFuture future = + agentsClient.getValidationResultCallable().futureCall(request); + // Do something. + ValidationResult response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_getvalidationresult_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getvalidationresult/SyncGetValidationResult.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getvalidationresult/SyncGetValidationResult.java new file mode 100644 index 000000000000..6ad4240fd87c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/getvalidationresult/SyncGetValidationResult.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_getvalidationresult_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.GetValidationResultRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.cloud.dialogflow.v2beta1.ValidationResult; + +public class SyncGetValidationResult { + + public static void main(String[] args) throws Exception { + syncGetValidationResult(); + } + + public static void syncGetValidationResult() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + GetValidationResultRequest request = + GetValidationResultRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .build(); + ValidationResult response = agentsClient.getValidationResult(request); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_getvalidationresult_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/importagent/AsyncImportAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/importagent/AsyncImportAgent.java new file mode 100644 index 000000000000..583590775050 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/importagent/AsyncImportAgent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_importagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ImportAgentRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.longrunning.Operation; + +public class AsyncImportAgent { + + public static void main(String[] args) throws Exception { + asyncImportAgent(); + } + + public static void asyncImportAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ImportAgentRequest request = + ImportAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + ApiFuture future = agentsClient.importAgentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_importagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/importagent/AsyncImportAgentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/importagent/AsyncImportAgentLRO.java new file mode 100644 index 000000000000..bea9c3bd418f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/importagent/AsyncImportAgentLRO.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_importagent_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ImportAgentRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; + +public class AsyncImportAgentLRO { + + public static void main(String[] args) throws Exception { + asyncImportAgentLRO(); + } + + public static void asyncImportAgentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ImportAgentRequest request = + ImportAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + OperationFuture future = + agentsClient.importAgentOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_importagent_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/importagent/SyncImportAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/importagent/SyncImportAgent.java new file mode 100644 index 000000000000..eb2855440ebf --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/importagent/SyncImportAgent.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_importagent_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ImportAgentRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncImportAgent { + + public static void main(String[] args) throws Exception { + syncImportAgent(); + } + + public static void syncImportAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ImportAgentRequest request = + ImportAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + agentsClient.importAgentAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_importagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/restoreagent/AsyncRestoreAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/restoreagent/AsyncRestoreAgent.java new file mode 100644 index 000000000000..eb1c1e6ddada --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/restoreagent/AsyncRestoreAgent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_restoreagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.cloud.dialogflow.v2beta1.RestoreAgentRequest; +import com.google.longrunning.Operation; + +public class AsyncRestoreAgent { + + public static void main(String[] args) throws Exception { + asyncRestoreAgent(); + } + + public static void asyncRestoreAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + RestoreAgentRequest request = + RestoreAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .build(); + ApiFuture future = agentsClient.restoreAgentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_restoreagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/restoreagent/AsyncRestoreAgentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/restoreagent/AsyncRestoreAgentLRO.java new file mode 100644 index 000000000000..e7068004a897 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/restoreagent/AsyncRestoreAgentLRO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_restoreagent_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.cloud.dialogflow.v2beta1.RestoreAgentRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; + +public class AsyncRestoreAgentLRO { + + public static void main(String[] args) throws Exception { + asyncRestoreAgentLRO(); + } + + public static void asyncRestoreAgentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + RestoreAgentRequest request = + RestoreAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .build(); + OperationFuture future = + agentsClient.restoreAgentOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_restoreagent_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/restoreagent/SyncRestoreAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/restoreagent/SyncRestoreAgent.java new file mode 100644 index 000000000000..b584bfbdfa4a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/restoreagent/SyncRestoreAgent.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_restoreagent_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.cloud.dialogflow.v2beta1.RestoreAgentRequest; + +public class SyncRestoreAgent { + + public static void main(String[] args) throws Exception { + syncRestoreAgent(); + } + + public static void syncRestoreAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + RestoreAgentRequest request = + RestoreAgentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .build(); + agentsClient.restoreAgentAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_restoreagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/AsyncSearchAgents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/AsyncSearchAgents.java new file mode 100644 index 000000000000..bc0e7e97faa3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/AsyncSearchAgents.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_searchagents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.cloud.dialogflow.v2beta1.SearchAgentsRequest; + +public class AsyncSearchAgents { + + public static void main(String[] args) throws Exception { + asyncSearchAgents(); + } + + public static void asyncSearchAgents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + SearchAgentsRequest request = + SearchAgentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = agentsClient.searchAgentsPagedCallable().futureCall(request); + // Do something. + for (Agent element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_searchagents_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/AsyncSearchAgentsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/AsyncSearchAgentsPaged.java new file mode 100644 index 000000000000..7578e7a84c05 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/AsyncSearchAgentsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_searchagents_paged_async] +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.cloud.dialogflow.v2beta1.SearchAgentsRequest; +import com.google.cloud.dialogflow.v2beta1.SearchAgentsResponse; +import com.google.common.base.Strings; + +public class AsyncSearchAgentsPaged { + + public static void main(String[] args) throws Exception { + asyncSearchAgentsPaged(); + } + + public static void asyncSearchAgentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + SearchAgentsRequest request = + SearchAgentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .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; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_searchagents_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgents.java new file mode 100644 index 000000000000..e1096c60b7f6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgents.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_searchagents_sync] +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.cloud.dialogflow.v2beta1.SearchAgentsRequest; + +public class SyncSearchAgents { + + public static void main(String[] args) throws Exception { + syncSearchAgents(); + } + + public static void syncSearchAgents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + SearchAgentsRequest request = + SearchAgentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Agent element : agentsClient.searchAgents(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_searchagents_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgentsLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgentsLocationname.java new file mode 100644 index 000000000000..a2aed1acfce6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgentsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_searchagents_locationname_sync] +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.LocationName; + +public class SyncSearchAgentsLocationname { + + public static void main(String[] args) throws Exception { + syncSearchAgentsLocationname(); + } + + public static void syncSearchAgentsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Agent element : agentsClient.searchAgents(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_searchagents_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgentsProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgentsProjectname.java new file mode 100644 index 000000000000..0f24b1b29e41 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgentsProjectname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_searchagents_projectname_sync] +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncSearchAgentsProjectname { + + public static void main(String[] args) throws Exception { + syncSearchAgentsProjectname(); + } + + public static void syncSearchAgentsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (Agent element : agentsClient.searchAgents(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_searchagents_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgentsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgentsString.java new file mode 100644 index 000000000000..8e556e725673 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/searchagents/SyncSearchAgentsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_searchagents_string_sync] +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncSearchAgentsString { + + public static void main(String[] args) throws Exception { + syncSearchAgentsString(); + } + + public static void syncSearchAgentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (Agent element : agentsClient.searchAgents(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_searchagents_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/setagent/AsyncSetAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/setagent/AsyncSetAgent.java new file mode 100644 index 000000000000..10c771209fab --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/setagent/AsyncSetAgent.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_setagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.SetAgentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncSetAgent { + + public static void main(String[] args) throws Exception { + asyncSetAgent(); + } + + public static void asyncSetAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + SetAgentRequest request = + SetAgentRequest.newBuilder() + .setAgent(Agent.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = agentsClient.setAgentCallable().futureCall(request); + // Do something. + Agent response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_setagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/setagent/SyncSetAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/setagent/SyncSetAgent.java new file mode 100644 index 000000000000..565d15a90416 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/setagent/SyncSetAgent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_setagent_sync] +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.SetAgentRequest; +import com.google.protobuf.FieldMask; + +public class SyncSetAgent { + + public static void main(String[] args) throws Exception { + syncSetAgent(); + } + + public static void syncSetAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + SetAgentRequest request = + SetAgentRequest.newBuilder() + .setAgent(Agent.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Agent response = agentsClient.setAgent(request); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_setagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/setagent/SyncSetAgentAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/setagent/SyncSetAgentAgent.java new file mode 100644 index 000000000000..1d7df9cacb1c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/setagent/SyncSetAgentAgent.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_setagent_agent_sync] +import com.google.cloud.dialogflow.v2beta1.Agent; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; + +public class SyncSetAgentAgent { + + public static void main(String[] args) throws Exception { + syncSetAgentAgent(); + } + + public static void syncSetAgentAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + Agent agent = Agent.newBuilder().build(); + Agent response = agentsClient.setAgent(agent); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_setagent_agent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/AsyncTrainAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/AsyncTrainAgent.java new file mode 100644 index 000000000000..5d13ea95deba --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/AsyncTrainAgent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_trainagent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.cloud.dialogflow.v2beta1.TrainAgentRequest; +import com.google.longrunning.Operation; + +public class AsyncTrainAgent { + + public static void main(String[] args) throws Exception { + asyncTrainAgent(); + } + + public static void asyncTrainAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + TrainAgentRequest request = + TrainAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + ApiFuture future = agentsClient.trainAgentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_trainagent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/AsyncTrainAgentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/AsyncTrainAgentLRO.java new file mode 100644 index 000000000000..01b0202d4a80 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/AsyncTrainAgentLRO.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_trainagent_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.cloud.dialogflow.v2beta1.TrainAgentRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; + +public class AsyncTrainAgentLRO { + + public static void main(String[] args) throws Exception { + asyncTrainAgentLRO(); + } + + public static void asyncTrainAgentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + TrainAgentRequest request = + TrainAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + OperationFuture future = + agentsClient.trainAgentOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_trainagent_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgent.java new file mode 100644 index 000000000000..63cdce0fc11c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgent.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_trainagent_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.cloud.dialogflow.v2beta1.TrainAgentRequest; + +public class SyncTrainAgent { + + public static void main(String[] args) throws Exception { + syncTrainAgent(); + } + + public static void syncTrainAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + TrainAgentRequest request = + TrainAgentRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).build(); + agentsClient.trainAgentAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_trainagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgentLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgentLocationname.java new file mode 100644 index 000000000000..a51e42ecbc79 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgentLocationname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_trainagent_locationname_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.LocationName; + +public class SyncTrainAgentLocationname { + + public static void main(String[] args) throws Exception { + syncTrainAgentLocationname(); + } + + public static void syncTrainAgentLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + agentsClient.trainAgentAsync(parent).get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_trainagent_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgentProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgentProjectname.java new file mode 100644 index 000000000000..9fed130a6c9a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgentProjectname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_trainagent_projectname_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncTrainAgentProjectname { + + public static void main(String[] args) throws Exception { + syncTrainAgentProjectname(); + } + + public static void syncTrainAgentProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + agentsClient.trainAgentAsync(parent).get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_trainagent_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgentString.java new file mode 100644 index 000000000000..e68fc962aef5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentsclient/trainagent/SyncTrainAgentString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentsclient_trainagent_string_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncTrainAgentString { + + public static void main(String[] args) throws Exception { + syncTrainAgentString(); + } + + public static void syncTrainAgentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AgentsClient agentsClient = AgentsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + agentsClient.trainAgentAsync(parent).get(); + } + } +} +// [END dialogflow_v2beta1_generated_agentsclient_trainagent_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentssettings/getagent/SyncGetAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentssettings/getagent/SyncGetAgent.java new file mode 100644 index 000000000000..f76ff7a068dd --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/agentssettings/getagent/SyncGetAgent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_agentssettings_getagent_sync] +import com.google.cloud.dialogflow.v2beta1.AgentsSettings; +import java.time.Duration; + +public class SyncGetAgent { + + public static void main(String[] args) throws Exception { + syncGetAgent(); + } + + public static void syncGetAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AgentsSettings.Builder agentsSettingsBuilder = AgentsSettings.newBuilder(); + agentsSettingsBuilder + .getAgentSettings() + .setRetrySettings( + agentsSettingsBuilder + .getAgentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + AgentsSettings agentsSettings = agentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_agentssettings_getagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..17163598e19a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AnswerRecordsSettings answerRecordsSettings = + AnswerRecordsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings); + } +} +// [END dialogflow_v2beta1_generated_answerrecordsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..b9b757d57bea --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AnswerRecordsSettings answerRecordsSettings = + AnswerRecordsSettings.newBuilder() + .setTransportChannelProvider( + AnswerRecordsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings); + } +} +// [END dialogflow_v2beta1_generated_answerrecordsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..08b8e05c0727 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AnswerRecordsSettings answerRecordsSettings = + AnswerRecordsSettings.newBuilder().setEndpoint(myEndpoint).build(); + AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings); + } +} +// [END dialogflow_v2beta1_generated_answerrecordsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/getanswerrecord/AsyncGetAnswerRecord.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/getanswerrecord/AsyncGetAnswerRecord.java new file mode 100644 index 000000000000..c46a436c2273 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/getanswerrecord/AsyncGetAnswerRecord.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsclient_getanswerrecord_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AnswerRecord; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2beta1.GetAnswerRecordRequest; + +public class AsyncGetAnswerRecord { + + public static void main(String[] args) throws Exception { + asyncGetAnswerRecord(); + } + + public static void asyncGetAnswerRecord() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + GetAnswerRecordRequest request = + GetAnswerRecordRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + answerRecordsClient.getAnswerRecordCallable().futureCall(request); + // Do something. + AnswerRecord response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_answerrecordsclient_getanswerrecord_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/getanswerrecord/SyncGetAnswerRecord.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/getanswerrecord/SyncGetAnswerRecord.java new file mode 100644 index 000000000000..9eab4f117a36 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/getanswerrecord/SyncGetAnswerRecord.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsclient_getanswerrecord_sync] +import com.google.cloud.dialogflow.v2beta1.AnswerRecord; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2beta1.GetAnswerRecordRequest; + +public class SyncGetAnswerRecord { + + public static void main(String[] args) throws Exception { + syncGetAnswerRecord(); + } + + public static void syncGetAnswerRecord() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + GetAnswerRecordRequest request = + GetAnswerRecordRequest.newBuilder().setName("name3373707").build(); + AnswerRecord response = answerRecordsClient.getAnswerRecord(request); + } + } +} +// [END dialogflow_v2beta1_generated_answerrecordsclient_getanswerrecord_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/AsyncListAnswerRecords.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/AsyncListAnswerRecords.java new file mode 100644 index 000000000000..2a25f0c7d092 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/AsyncListAnswerRecords.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsclient_listanswerrecords_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AnswerRecord; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2beta1.ListAnswerRecordsRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class AsyncListAnswerRecords { + + public static void main(String[] args) throws Exception { + asyncListAnswerRecords(); + } + + public static void asyncListAnswerRecords() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + ListAnswerRecordsRequest request = + ListAnswerRecordsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + answerRecordsClient.listAnswerRecordsPagedCallable().futureCall(request); + // Do something. + for (AnswerRecord element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_answerrecordsclient_listanswerrecords_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/AsyncListAnswerRecordsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/AsyncListAnswerRecordsPaged.java new file mode 100644 index 000000000000..625289f3b892 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/AsyncListAnswerRecordsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsclient_listanswerrecords_paged_async] +import com.google.cloud.dialogflow.v2beta1.AnswerRecord; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2beta1.ListAnswerRecordsRequest; +import com.google.cloud.dialogflow.v2beta1.ListAnswerRecordsResponse; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListAnswerRecordsPaged { + + public static void main(String[] args) throws Exception { + asyncListAnswerRecordsPaged(); + } + + public static void asyncListAnswerRecordsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + ListAnswerRecordsRequest request = + ListAnswerRecordsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListAnswerRecordsResponse response = + answerRecordsClient.listAnswerRecordsCallable().call(request); + for (AnswerRecord element : response.getAnswerRecordsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_answerrecordsclient_listanswerrecords_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecords.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecords.java new file mode 100644 index 000000000000..3de10cf91531 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecords.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsclient_listanswerrecords_sync] +import com.google.cloud.dialogflow.v2beta1.AnswerRecord; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2beta1.ListAnswerRecordsRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncListAnswerRecords { + + public static void main(String[] args) throws Exception { + syncListAnswerRecords(); + } + + public static void syncListAnswerRecords() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + ListAnswerRecordsRequest request = + ListAnswerRecordsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (AnswerRecord element : answerRecordsClient.listAnswerRecords(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_answerrecordsclient_listanswerrecords_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsLocationname.java new file mode 100644 index 000000000000..1c97e65a2a4f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsclient_listanswerrecords_locationname_sync] +import com.google.cloud.dialogflow.v2beta1.AnswerRecord; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2beta1.LocationName; + +public class SyncListAnswerRecordsLocationname { + + public static void main(String[] args) throws Exception { + syncListAnswerRecordsLocationname(); + } + + public static void syncListAnswerRecordsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (AnswerRecord element : answerRecordsClient.listAnswerRecords(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_answerrecordsclient_listanswerrecords_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsProjectname.java new file mode 100644 index 000000000000..3cffd89372dc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsProjectname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsclient_listanswerrecords_projectname_sync] +import com.google.cloud.dialogflow.v2beta1.AnswerRecord; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncListAnswerRecordsProjectname { + + public static void main(String[] args) throws Exception { + syncListAnswerRecordsProjectname(); + } + + public static void syncListAnswerRecordsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (AnswerRecord element : answerRecordsClient.listAnswerRecords(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_answerrecordsclient_listanswerrecords_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsString.java new file mode 100644 index 000000000000..cedd2af618d9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/listanswerrecords/SyncListAnswerRecordsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsclient_listanswerrecords_string_sync] +import com.google.cloud.dialogflow.v2beta1.AnswerRecord; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncListAnswerRecordsString { + + public static void main(String[] args) throws Exception { + syncListAnswerRecordsString(); + } + + public static void syncListAnswerRecordsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (AnswerRecord element : answerRecordsClient.listAnswerRecords(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_answerrecordsclient_listanswerrecords_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/updateanswerrecord/AsyncUpdateAnswerRecord.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/updateanswerrecord/AsyncUpdateAnswerRecord.java new file mode 100644 index 000000000000..c1374cb3b785 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/updateanswerrecord/AsyncUpdateAnswerRecord.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsclient_updateanswerrecord_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AnswerRecord; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateAnswerRecordRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateAnswerRecord { + + public static void main(String[] args) throws Exception { + asyncUpdateAnswerRecord(); + } + + public static void asyncUpdateAnswerRecord() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + UpdateAnswerRecordRequest request = + UpdateAnswerRecordRequest.newBuilder() + .setAnswerRecord(AnswerRecord.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + answerRecordsClient.updateAnswerRecordCallable().futureCall(request); + // Do something. + AnswerRecord response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_answerrecordsclient_updateanswerrecord_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecord.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecord.java new file mode 100644 index 000000000000..404a311ca2d2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecord.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsclient_updateanswerrecord_sync] +import com.google.cloud.dialogflow.v2beta1.AnswerRecord; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateAnswerRecordRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateAnswerRecord { + + public static void main(String[] args) throws Exception { + syncUpdateAnswerRecord(); + } + + public static void syncUpdateAnswerRecord() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + UpdateAnswerRecordRequest request = + UpdateAnswerRecordRequest.newBuilder() + .setAnswerRecord(AnswerRecord.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + AnswerRecord response = answerRecordsClient.updateAnswerRecord(request); + } + } +} +// [END dialogflow_v2beta1_generated_answerrecordsclient_updateanswerrecord_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecordAnswerrecordFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecordAnswerrecordFieldmask.java new file mode 100644 index 000000000000..a491c1c166c5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordsclient/updateanswerrecord/SyncUpdateAnswerRecordAnswerrecordFieldmask.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_answerrecordsclient_updateanswerrecord_answerrecordfieldmask_sync] +import com.google.cloud.dialogflow.v2beta1.AnswerRecord; +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateAnswerRecordAnswerrecordFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateAnswerRecordAnswerrecordFieldmask(); + } + + public static void syncUpdateAnswerRecordAnswerrecordFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create()) { + AnswerRecord answerRecord = AnswerRecord.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + AnswerRecord response = answerRecordsClient.updateAnswerRecord(answerRecord, updateMask); + } + } +} +// [END +// dialogflow_v2beta1_generated_answerrecordsclient_updateanswerrecord_answerrecordfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordssettings/getanswerrecord/SyncGetAnswerRecord.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordssettings/getanswerrecord/SyncGetAnswerRecord.java new file mode 100644 index 000000000000..102d5df2bdd0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/answerrecordssettings/getanswerrecord/SyncGetAnswerRecord.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_answerrecordssettings_getanswerrecord_sync] +import com.google.cloud.dialogflow.v2beta1.AnswerRecordsSettings; +import java.time.Duration; + +public class SyncGetAnswerRecord { + + public static void main(String[] args) throws Exception { + syncGetAnswerRecord(); + } + + public static void syncGetAnswerRecord() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AnswerRecordsSettings.Builder answerRecordsSettingsBuilder = AnswerRecordsSettings.newBuilder(); + answerRecordsSettingsBuilder + .getAnswerRecordSettings() + .setRetrySettings( + answerRecordsSettingsBuilder + .getAnswerRecordSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + AnswerRecordsSettings answerRecordsSettings = answerRecordsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_answerrecordssettings_getanswerrecord_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..c1f5362edd19 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.ContextsSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ContextsSettings contextsSettings = + ContextsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ContextsClient contextsClient = ContextsClient.create(contextsSettings); + } +} +// [END dialogflow_v2beta1_generated_contextsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..e8f881ff575c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.ContextsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ContextsSettings contextsSettings = + ContextsSettings.newBuilder() + .setTransportChannelProvider( + ContextsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ContextsClient contextsClient = ContextsClient.create(contextsSettings); + } +} +// [END dialogflow_v2beta1_generated_contextsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..5965540278c9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.ContextsSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ContextsSettings contextsSettings = + ContextsSettings.newBuilder().setEndpoint(myEndpoint).build(); + ContextsClient contextsClient = ContextsClient.create(contextsSettings); + } +} +// [END dialogflow_v2beta1_generated_contextsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/AsyncCreateContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/AsyncCreateContext.java new file mode 100644 index 000000000000..389cacd2cdf2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/AsyncCreateContext.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_createcontext_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.CreateContextRequest; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class AsyncCreateContext { + + public static void main(String[] args) throws Exception { + asyncCreateContext(); + } + + public static void asyncCreateContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + CreateContextRequest request = + CreateContextRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setContext(Context.newBuilder().build()) + .build(); + ApiFuture future = contextsClient.createContextCallable().futureCall(request); + // Do something. + Context response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_createcontext_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/SyncCreateContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/SyncCreateContext.java new file mode 100644 index 000000000000..e60fcd5d5853 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/SyncCreateContext.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_createcontext_sync] +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.CreateContextRequest; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncCreateContext { + + public static void main(String[] args) throws Exception { + syncCreateContext(); + } + + public static void syncCreateContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + CreateContextRequest request = + CreateContextRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setContext(Context.newBuilder().build()) + .build(); + Context response = contextsClient.createContext(request); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_createcontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/SyncCreateContextSessionnameContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/SyncCreateContextSessionnameContext.java new file mode 100644 index 000000000000..f2033edef500 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/SyncCreateContextSessionnameContext.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_createcontext_sessionnamecontext_sync] +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncCreateContextSessionnameContext { + + public static void main(String[] args) throws Exception { + syncCreateContextSessionnameContext(); + } + + public static void syncCreateContextSessionnameContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + Context context = Context.newBuilder().build(); + Context response = contextsClient.createContext(parent, context); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_createcontext_sessionnamecontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/SyncCreateContextStringContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/SyncCreateContextStringContext.java new file mode 100644 index 000000000000..bef33def353a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/createcontext/SyncCreateContextStringContext.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_createcontext_stringcontext_sync] +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncCreateContextStringContext { + + public static void main(String[] args) throws Exception { + syncCreateContextStringContext(); + } + + public static void syncCreateContextStringContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + String parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString(); + Context context = Context.newBuilder().build(); + Context response = contextsClient.createContext(parent, context); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_createcontext_stringcontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/AsyncDeleteAllContexts.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/AsyncDeleteAllContexts.java new file mode 100644 index 000000000000..0f19d1c09edc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/AsyncDeleteAllContexts.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_deleteallcontexts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.DeleteAllContextsRequest; +import com.google.cloud.dialogflow.v2beta1.SessionName; +import com.google.protobuf.Empty; + +public class AsyncDeleteAllContexts { + + public static void main(String[] args) throws Exception { + asyncDeleteAllContexts(); + } + + public static void asyncDeleteAllContexts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + DeleteAllContextsRequest request = + DeleteAllContextsRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .build(); + ApiFuture future = contextsClient.deleteAllContextsCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_deleteallcontexts_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/SyncDeleteAllContexts.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/SyncDeleteAllContexts.java new file mode 100644 index 000000000000..12dfdb877c34 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/SyncDeleteAllContexts.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_deleteallcontexts_sync] +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.DeleteAllContextsRequest; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncDeleteAllContexts { + + public static void main(String[] args) throws Exception { + syncDeleteAllContexts(); + } + + public static void syncDeleteAllContexts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + DeleteAllContextsRequest request = + DeleteAllContextsRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .build(); + contextsClient.deleteAllContexts(request); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_deleteallcontexts_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/SyncDeleteAllContextsSessionname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/SyncDeleteAllContextsSessionname.java new file mode 100644 index 000000000000..f8b0a95ca6dc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/SyncDeleteAllContextsSessionname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_deleteallcontexts_sessionname_sync] +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncDeleteAllContextsSessionname { + + public static void main(String[] args) throws Exception { + syncDeleteAllContextsSessionname(); + } + + public static void syncDeleteAllContextsSessionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + contextsClient.deleteAllContexts(parent); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_deleteallcontexts_sessionname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/SyncDeleteAllContextsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/SyncDeleteAllContextsString.java new file mode 100644 index 000000000000..82a88be8503d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deleteallcontexts/SyncDeleteAllContextsString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_deleteallcontexts_string_sync] +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncDeleteAllContextsString { + + public static void main(String[] args) throws Exception { + syncDeleteAllContextsString(); + } + + public static void syncDeleteAllContextsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + String parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString(); + contextsClient.deleteAllContexts(parent); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_deleteallcontexts_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/AsyncDeleteContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/AsyncDeleteContext.java new file mode 100644 index 000000000000..ecb1e47c3287 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/AsyncDeleteContext.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_deletecontext_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ContextName; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.DeleteContextRequest; +import com.google.protobuf.Empty; + +public class AsyncDeleteContext { + + public static void main(String[] args) throws Exception { + asyncDeleteContext(); + } + + public static void asyncDeleteContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + DeleteContextRequest request = + DeleteContextRequest.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .build(); + ApiFuture future = contextsClient.deleteContextCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_deletecontext_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/SyncDeleteContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/SyncDeleteContext.java new file mode 100644 index 000000000000..7b85ae54e33c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/SyncDeleteContext.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_deletecontext_sync] +import com.google.cloud.dialogflow.v2beta1.ContextName; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.DeleteContextRequest; + +public class SyncDeleteContext { + + public static void main(String[] args) throws Exception { + syncDeleteContext(); + } + + public static void syncDeleteContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + DeleteContextRequest request = + DeleteContextRequest.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .build(); + contextsClient.deleteContext(request); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_deletecontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/SyncDeleteContextContextname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/SyncDeleteContextContextname.java new file mode 100644 index 000000000000..237e3ca988f8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/SyncDeleteContextContextname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_deletecontext_contextname_sync] +import com.google.cloud.dialogflow.v2beta1.ContextName; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; + +public class SyncDeleteContextContextname { + + public static void main(String[] args) throws Exception { + syncDeleteContextContextname(); + } + + public static void syncDeleteContextContextname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + ContextName name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"); + contextsClient.deleteContext(name); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_deletecontext_contextname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/SyncDeleteContextString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/SyncDeleteContextString.java new file mode 100644 index 000000000000..70b9ea48d05e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/deletecontext/SyncDeleteContextString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_deletecontext_string_sync] +import com.google.cloud.dialogflow.v2beta1.ContextName; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; + +public class SyncDeleteContextString { + + public static void main(String[] args) throws Exception { + syncDeleteContextString(); + } + + public static void syncDeleteContextString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + String name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]").toString(); + contextsClient.deleteContext(name); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_deletecontext_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/AsyncGetContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/AsyncGetContext.java new file mode 100644 index 000000000000..c06162c035aa --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/AsyncGetContext.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_getcontext_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextName; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.GetContextRequest; + +public class AsyncGetContext { + + public static void main(String[] args) throws Exception { + asyncGetContext(); + } + + public static void asyncGetContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + GetContextRequest request = + GetContextRequest.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .build(); + ApiFuture future = contextsClient.getContextCallable().futureCall(request); + // Do something. + Context response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_getcontext_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/SyncGetContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/SyncGetContext.java new file mode 100644 index 000000000000..d04ab8934fca --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/SyncGetContext.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_getcontext_sync] +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextName; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.GetContextRequest; + +public class SyncGetContext { + + public static void main(String[] args) throws Exception { + syncGetContext(); + } + + public static void syncGetContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + GetContextRequest request = + GetContextRequest.newBuilder() + .setName( + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]") + .toString()) + .build(); + Context response = contextsClient.getContext(request); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_getcontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/SyncGetContextContextname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/SyncGetContextContextname.java new file mode 100644 index 000000000000..70cc54b0745e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/SyncGetContextContextname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_getcontext_contextname_sync] +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextName; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; + +public class SyncGetContextContextname { + + public static void main(String[] args) throws Exception { + syncGetContextContextname(); + } + + public static void syncGetContextContextname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + ContextName name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]"); + Context response = contextsClient.getContext(name); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_getcontext_contextname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/SyncGetContextString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/SyncGetContextString.java new file mode 100644 index 000000000000..0c9beee84a6d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/getcontext/SyncGetContextString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_getcontext_string_sync] +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextName; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; + +public class SyncGetContextString { + + public static void main(String[] args) throws Exception { + syncGetContextString(); + } + + public static void syncGetContextString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + String name = + ContextName.ofProjectSessionContextName("[PROJECT]", "[SESSION]", "[CONTEXT]").toString(); + Context response = contextsClient.getContext(name); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_getcontext_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/AsyncListContexts.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/AsyncListContexts.java new file mode 100644 index 000000000000..779d41eae45c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/AsyncListContexts.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_listcontexts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.ListContextsRequest; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class AsyncListContexts { + + public static void main(String[] args) throws Exception { + asyncListContexts(); + } + + public static void asyncListContexts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + ListContextsRequest request = + ListContextsRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = contextsClient.listContextsPagedCallable().futureCall(request); + // Do something. + for (Context element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_listcontexts_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/AsyncListContextsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/AsyncListContextsPaged.java new file mode 100644 index 000000000000..5eda50fbf368 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/AsyncListContextsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_listcontexts_paged_async] +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.ListContextsRequest; +import com.google.cloud.dialogflow.v2beta1.ListContextsResponse; +import com.google.cloud.dialogflow.v2beta1.SessionName; +import com.google.common.base.Strings; + +public class AsyncListContextsPaged { + + public static void main(String[] args) throws Exception { + asyncListContextsPaged(); + } + + public static void asyncListContextsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + ListContextsRequest request = + ListContextsRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .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; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_listcontexts_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/SyncListContexts.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/SyncListContexts.java new file mode 100644 index 000000000000..86dc12cfa737 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/SyncListContexts.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_listcontexts_sync] +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.ListContextsRequest; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncListContexts { + + public static void main(String[] args) throws Exception { + syncListContexts(); + } + + public static void syncListContexts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + ListContextsRequest request = + ListContextsRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Context element : contextsClient.listContexts(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_listcontexts_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/SyncListContextsSessionname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/SyncListContextsSessionname.java new file mode 100644 index 000000000000..a837973ed8b5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/SyncListContextsSessionname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_listcontexts_sessionname_sync] +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncListContextsSessionname { + + public static void main(String[] args) throws Exception { + syncListContextsSessionname(); + } + + public static void syncListContextsSessionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + for (Context element : contextsClient.listContexts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_listcontexts_sessionname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/SyncListContextsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/SyncListContextsString.java new file mode 100644 index 000000000000..3e92a778990f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/listcontexts/SyncListContextsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_listcontexts_string_sync] +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncListContextsString { + + public static void main(String[] args) throws Exception { + syncListContextsString(); + } + + public static void syncListContextsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + String parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString(); + for (Context element : contextsClient.listContexts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_listcontexts_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/AsyncUpdateContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/AsyncUpdateContext.java new file mode 100644 index 000000000000..91ab559c2ff0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/AsyncUpdateContext.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_updatecontext_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateContextRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateContext { + + public static void main(String[] args) throws Exception { + asyncUpdateContext(); + } + + public static void asyncUpdateContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + UpdateContextRequest request = + UpdateContextRequest.newBuilder() + .setContext(Context.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = contextsClient.updateContextCallable().futureCall(request); + // Do something. + Context response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_updatecontext_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/SyncUpdateContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/SyncUpdateContext.java new file mode 100644 index 000000000000..24de663f8338 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/SyncUpdateContext.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_updatecontext_sync] +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateContextRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateContext { + + public static void main(String[] args) throws Exception { + syncUpdateContext(); + } + + public static void syncUpdateContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + UpdateContextRequest request = + UpdateContextRequest.newBuilder() + .setContext(Context.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Context response = contextsClient.updateContext(request); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_updatecontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/SyncUpdateContextContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/SyncUpdateContextContext.java new file mode 100644 index 000000000000..fa585da0e9d9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/SyncUpdateContextContext.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_updatecontext_context_sync] +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; + +public class SyncUpdateContextContext { + + public static void main(String[] args) throws Exception { + syncUpdateContextContext(); + } + + public static void syncUpdateContextContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + Context context = Context.newBuilder().build(); + Context response = contextsClient.updateContext(context); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_updatecontext_context_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/SyncUpdateContextContextFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/SyncUpdateContextContextFieldmask.java new file mode 100644 index 000000000000..be6a57593834 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextsclient/updatecontext/SyncUpdateContextContextFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextsclient_updatecontext_contextfieldmask_sync] +import com.google.cloud.dialogflow.v2beta1.Context; +import com.google.cloud.dialogflow.v2beta1.ContextsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateContextContextFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateContextContextFieldmask(); + } + + public static void syncUpdateContextContextFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ContextsClient contextsClient = ContextsClient.create()) { + Context context = Context.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Context response = contextsClient.updateContext(context, updateMask); + } + } +} +// [END dialogflow_v2beta1_generated_contextsclient_updatecontext_contextfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextssettings/getcontext/SyncGetContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextssettings/getcontext/SyncGetContext.java new file mode 100644 index 000000000000..5446eb56d957 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/contextssettings/getcontext/SyncGetContext.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_contextssettings_getcontext_sync] +import com.google.cloud.dialogflow.v2beta1.ContextsSettings; +import java.time.Duration; + +public class SyncGetContext { + + public static void main(String[] args) throws Exception { + syncGetContext(); + } + + public static void syncGetContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ContextsSettings.Builder contextsSettingsBuilder = ContextsSettings.newBuilder(); + contextsSettingsBuilder + .getContextSettings() + .setRetrySettings( + contextsSettingsBuilder + .getContextSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ContextsSettings contextsSettings = contextsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_contextssettings_getcontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfig.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfig.java new file mode 100644 index 000000000000..11411abe215f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_clearsuggestionfeatureconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ClearSuggestionFeatureConfigRequest; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.longrunning.Operation; + +public class AsyncClearSuggestionFeatureConfig { + + public static void main(String[] args) throws Exception { + asyncClearSuggestionFeatureConfig(); + } + + public static void asyncClearSuggestionFeatureConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ClearSuggestionFeatureConfigRequest request = + ClearSuggestionFeatureConfigRequest.newBuilder() + .setConversationProfile("conversationProfile1691597734") + .build(); + ApiFuture future = + conversationProfilesClient.clearSuggestionFeatureConfigCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_clearsuggestionfeatureconfig_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfigLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfigLRO.java new file mode 100644 index 000000000000..c1e1ba6826e3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/AsyncClearSuggestionFeatureConfigLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_clearsuggestionfeatureconfig_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.ClearSuggestionFeatureConfigOperationMetadata; +import com.google.cloud.dialogflow.v2beta1.ClearSuggestionFeatureConfigRequest; +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; + +public class AsyncClearSuggestionFeatureConfigLRO { + + public static void main(String[] args) throws Exception { + asyncClearSuggestionFeatureConfigLRO(); + } + + public static void asyncClearSuggestionFeatureConfigLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ClearSuggestionFeatureConfigRequest request = + ClearSuggestionFeatureConfigRequest.newBuilder() + .setConversationProfile("conversationProfile1691597734") + .build(); + OperationFuture future = + conversationProfilesClient + .clearSuggestionFeatureConfigOperationCallable() + .futureCall(request); + // Do something. + ConversationProfile response = future.get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_clearsuggestionfeatureconfig_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfig.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfig.java new file mode 100644 index 000000000000..50b93e1f8e66 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_clearsuggestionfeatureconfig_sync] +import com.google.cloud.dialogflow.v2beta1.ClearSuggestionFeatureConfigRequest; +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; + +public class SyncClearSuggestionFeatureConfig { + + public static void main(String[] args) throws Exception { + syncClearSuggestionFeatureConfig(); + } + + public static void syncClearSuggestionFeatureConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ClearSuggestionFeatureConfigRequest request = + ClearSuggestionFeatureConfigRequest.newBuilder() + .setConversationProfile("conversationProfile1691597734") + .build(); + ConversationProfile response = + conversationProfilesClient.clearSuggestionFeatureConfigAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_clearsuggestionfeatureconfig_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfigString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfigString.java new file mode 100644 index 000000000000..f30290edc996 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/clearsuggestionfeatureconfig/SyncClearSuggestionFeatureConfigString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_clearsuggestionfeatureconfig_string_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; + +public class SyncClearSuggestionFeatureConfigString { + + public static void main(String[] args) throws Exception { + syncClearSuggestionFeatureConfigString(); + } + + public static void syncClearSuggestionFeatureConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + String conversationProfile = "conversationProfile1691597734"; + ConversationProfile response = + conversationProfilesClient.clearSuggestionFeatureConfigAsync(conversationProfile).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_clearsuggestionfeatureconfig_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..40f91bfaa6a0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationProfilesSettings conversationProfilesSettings = + ConversationProfilesSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create(conversationProfilesSettings); + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..faed24743c0d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationProfilesSettings conversationProfilesSettings = + ConversationProfilesSettings.newBuilder() + .setTransportChannelProvider( + ConversationProfilesSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create(conversationProfilesSettings); + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..51bfa1923b46 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationProfilesSettings conversationProfilesSettings = + ConversationProfilesSettings.newBuilder().setEndpoint(myEndpoint).build(); + ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create(conversationProfilesSettings); + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/AsyncCreateConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/AsyncCreateConversationProfile.java new file mode 100644 index 000000000000..8b52ddbd685b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/AsyncCreateConversationProfile.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_createconversationprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.CreateConversationProfileRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class AsyncCreateConversationProfile { + + public static void main(String[] args) throws Exception { + asyncCreateConversationProfile(); + } + + public static void asyncCreateConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + CreateConversationProfileRequest request = + CreateConversationProfileRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setConversationProfile(ConversationProfile.newBuilder().build()) + .build(); + ApiFuture future = + conversationProfilesClient.createConversationProfileCallable().futureCall(request); + // Do something. + ConversationProfile response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_createconversationprofile_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfile.java new file mode 100644 index 000000000000..3b556199b9d1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfile.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_createconversationprofile_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.CreateConversationProfileRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncCreateConversationProfile { + + public static void main(String[] args) throws Exception { + syncCreateConversationProfile(); + } + + public static void syncCreateConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + CreateConversationProfileRequest request = + CreateConversationProfileRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setConversationProfile(ConversationProfile.newBuilder().build()) + .build(); + ConversationProfile response = conversationProfilesClient.createConversationProfile(request); + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_createconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileLocationnameConversationprofile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileLocationnameConversationprofile.java new file mode 100644 index 000000000000..94c3d9384418 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileLocationnameConversationprofile.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_createconversationprofile_locationnameconversationprofile_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.LocationName; + +public class SyncCreateConversationProfileLocationnameConversationprofile { + + public static void main(String[] args) throws Exception { + syncCreateConversationProfileLocationnameConversationprofile(); + } + + public static void syncCreateConversationProfileLocationnameConversationprofile() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + ConversationProfile response = + conversationProfilesClient.createConversationProfile(parent, conversationProfile); + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_createconversationprofile_locationnameconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileProjectnameConversationprofile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileProjectnameConversationprofile.java new file mode 100644 index 000000000000..bc2fdcf1d371 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileProjectnameConversationprofile.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_createconversationprofile_projectnameconversationprofile_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncCreateConversationProfileProjectnameConversationprofile { + + public static void main(String[] args) throws Exception { + syncCreateConversationProfileProjectnameConversationprofile(); + } + + public static void syncCreateConversationProfileProjectnameConversationprofile() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + ConversationProfile response = + conversationProfilesClient.createConversationProfile(parent, conversationProfile); + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_createconversationprofile_projectnameconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileStringConversationprofile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileStringConversationprofile.java new file mode 100644 index 000000000000..22bf69918a91 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/createconversationprofile/SyncCreateConversationProfileStringConversationprofile.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_createconversationprofile_stringconversationprofile_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncCreateConversationProfileStringConversationprofile { + + public static void main(String[] args) throws Exception { + syncCreateConversationProfileStringConversationprofile(); + } + + public static void syncCreateConversationProfileStringConversationprofile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + ConversationProfile response = + conversationProfilesClient.createConversationProfile(parent, conversationProfile); + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_createconversationprofile_stringconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/AsyncDeleteConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/AsyncDeleteConversationProfile.java new file mode 100644 index 000000000000..20d5fa471ce2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/AsyncDeleteConversationProfile.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_deleteconversationprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ConversationProfileName; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.DeleteConversationProfileRequest; +import com.google.protobuf.Empty; + +public class AsyncDeleteConversationProfile { + + public static void main(String[] args) throws Exception { + asyncDeleteConversationProfile(); + } + + public static void asyncDeleteConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + DeleteConversationProfileRequest request = + DeleteConversationProfileRequest.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .build(); + ApiFuture future = + conversationProfilesClient.deleteConversationProfileCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_deleteconversationprofile_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfile.java new file mode 100644 index 000000000000..911cf385ff35 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfile.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_deleteconversationprofile_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfileName; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.DeleteConversationProfileRequest; + +public class SyncDeleteConversationProfile { + + public static void main(String[] args) throws Exception { + syncDeleteConversationProfile(); + } + + public static void syncDeleteConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + DeleteConversationProfileRequest request = + DeleteConversationProfileRequest.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .build(); + conversationProfilesClient.deleteConversationProfile(request); + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_deleteconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileConversationprofilename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileConversationprofilename.java new file mode 100644 index 000000000000..37a14832daf0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileConversationprofilename.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_deleteconversationprofile_conversationprofilename_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfileName; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; + +public class SyncDeleteConversationProfileConversationprofilename { + + public static void main(String[] args) throws Exception { + syncDeleteConversationProfileConversationprofilename(); + } + + public static void syncDeleteConversationProfileConversationprofilename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ConversationProfileName name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]"); + conversationProfilesClient.deleteConversationProfile(name); + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_deleteconversationprofile_conversationprofilename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileString.java new file mode 100644 index 000000000000..82136b55358b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/deleteconversationprofile/SyncDeleteConversationProfileString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_deleteconversationprofile_string_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfileName; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; + +public class SyncDeleteConversationProfileString { + + public static void main(String[] args) throws Exception { + syncDeleteConversationProfileString(); + } + + public static void syncDeleteConversationProfileString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + String name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString(); + conversationProfilesClient.deleteConversationProfile(name); + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_deleteconversationprofile_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/AsyncGetConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/AsyncGetConversationProfile.java new file mode 100644 index 000000000000..8763020938e2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/AsyncGetConversationProfile.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_getconversationprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfileName; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.GetConversationProfileRequest; + +public class AsyncGetConversationProfile { + + public static void main(String[] args) throws Exception { + asyncGetConversationProfile(); + } + + public static void asyncGetConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + GetConversationProfileRequest request = + GetConversationProfileRequest.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .build(); + ApiFuture future = + conversationProfilesClient.getConversationProfileCallable().futureCall(request); + // Do something. + ConversationProfile response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_getconversationprofile_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/SyncGetConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/SyncGetConversationProfile.java new file mode 100644 index 000000000000..8350a115b5b3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/SyncGetConversationProfile.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_getconversationprofile_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfileName; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.GetConversationProfileRequest; + +public class SyncGetConversationProfile { + + public static void main(String[] args) throws Exception { + syncGetConversationProfile(); + } + + public static void syncGetConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + GetConversationProfileRequest request = + GetConversationProfileRequest.newBuilder() + .setName( + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString()) + .build(); + ConversationProfile response = conversationProfilesClient.getConversationProfile(request); + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_getconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileConversationprofilename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileConversationprofilename.java new file mode 100644 index 000000000000..1cddc3186ea0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileConversationprofilename.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_getconversationprofile_conversationprofilename_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfileName; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; + +public class SyncGetConversationProfileConversationprofilename { + + public static void main(String[] args) throws Exception { + syncGetConversationProfileConversationprofilename(); + } + + public static void syncGetConversationProfileConversationprofilename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ConversationProfileName name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]"); + ConversationProfile response = conversationProfilesClient.getConversationProfile(name); + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_getconversationprofile_conversationprofilename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileString.java new file mode 100644 index 000000000000..bf8e6e005338 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/getconversationprofile/SyncGetConversationProfileString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_getconversationprofile_string_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfileName; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; + +public class SyncGetConversationProfileString { + + public static void main(String[] args) throws Exception { + syncGetConversationProfileString(); + } + + public static void syncGetConversationProfileString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + String name = + ConversationProfileName.ofProjectConversationProfileName( + "[PROJECT]", "[CONVERSATION_PROFILE]") + .toString(); + ConversationProfile response = conversationProfilesClient.getConversationProfile(name); + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_getconversationprofile_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfiles.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfiles.java new file mode 100644 index 000000000000..db8902d9e76d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfiles.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_listconversationprofiles_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.ListConversationProfilesRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class AsyncListConversationProfiles { + + public static void main(String[] args) throws Exception { + asyncListConversationProfiles(); + } + + public static void asyncListConversationProfiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ListConversationProfilesRequest request = + ListConversationProfilesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + conversationProfilesClient.listConversationProfilesPagedCallable().futureCall(request); + // Do something. + for (ConversationProfile element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_listconversationprofiles_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfilesPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfilesPaged.java new file mode 100644 index 000000000000..f45cada8614f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/AsyncListConversationProfilesPaged.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_listconversationprofiles_paged_async] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.ListConversationProfilesRequest; +import com.google.cloud.dialogflow.v2beta1.ListConversationProfilesResponse; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListConversationProfilesPaged { + + public static void main(String[] args) throws Exception { + asyncListConversationProfilesPaged(); + } + + public static void asyncListConversationProfilesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ListConversationProfilesRequest request = + ListConversationProfilesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListConversationProfilesResponse response = + conversationProfilesClient.listConversationProfilesCallable().call(request); + for (ConversationProfile element : response.getConversationProfilesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_listconversationprofiles_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfiles.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfiles.java new file mode 100644 index 000000000000..fe09b7321852 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfiles.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_listconversationprofiles_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.ListConversationProfilesRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncListConversationProfiles { + + public static void main(String[] args) throws Exception { + syncListConversationProfiles(); + } + + public static void syncListConversationProfiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ListConversationProfilesRequest request = + ListConversationProfilesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (ConversationProfile element : + conversationProfilesClient.listConversationProfiles(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_listconversationprofiles_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesLocationname.java new file mode 100644 index 000000000000..3ec89f48b1ef --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesLocationname.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_listconversationprofiles_locationname_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.LocationName; + +public class SyncListConversationProfilesLocationname { + + public static void main(String[] args) throws Exception { + syncListConversationProfilesLocationname(); + } + + public static void syncListConversationProfilesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (ConversationProfile element : + conversationProfilesClient.listConversationProfiles(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_listconversationprofiles_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesProjectname.java new file mode 100644 index 000000000000..f5c28d87216f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesProjectname.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_listconversationprofiles_projectname_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncListConversationProfilesProjectname { + + public static void main(String[] args) throws Exception { + syncListConversationProfilesProjectname(); + } + + public static void syncListConversationProfilesProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (ConversationProfile element : + conversationProfilesClient.listConversationProfiles(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_listconversationprofiles_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesString.java new file mode 100644 index 000000000000..f56622e9ea68 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/listconversationprofiles/SyncListConversationProfilesString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_listconversationprofiles_string_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncListConversationProfilesString { + + public static void main(String[] args) throws Exception { + syncListConversationProfilesString(); + } + + public static void syncListConversationProfilesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (ConversationProfile element : + conversationProfilesClient.listConversationProfiles(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_listconversationprofiles_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfig.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfig.java new file mode 100644 index 000000000000..f0980c2d7c76 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfig.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_setsuggestionfeatureconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.HumanAgentAssistantConfig; +import com.google.cloud.dialogflow.v2beta1.SetSuggestionFeatureConfigRequest; +import com.google.longrunning.Operation; + +public class AsyncSetSuggestionFeatureConfig { + + public static void main(String[] args) throws Exception { + asyncSetSuggestionFeatureConfig(); + } + + public static void asyncSetSuggestionFeatureConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + SetSuggestionFeatureConfigRequest request = + SetSuggestionFeatureConfigRequest.newBuilder() + .setConversationProfile("conversationProfile1691597734") + .setSuggestionFeatureConfig( + HumanAgentAssistantConfig.SuggestionFeatureConfig.newBuilder().build()) + .build(); + ApiFuture future = + conversationProfilesClient.setSuggestionFeatureConfigCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_setsuggestionfeatureconfig_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfigLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfigLRO.java new file mode 100644 index 000000000000..c7e4dd7348ff --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/AsyncSetSuggestionFeatureConfigLRO.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_setsuggestionfeatureconfig_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.HumanAgentAssistantConfig; +import com.google.cloud.dialogflow.v2beta1.SetSuggestionFeatureConfigOperationMetadata; +import com.google.cloud.dialogflow.v2beta1.SetSuggestionFeatureConfigRequest; + +public class AsyncSetSuggestionFeatureConfigLRO { + + public static void main(String[] args) throws Exception { + asyncSetSuggestionFeatureConfigLRO(); + } + + public static void asyncSetSuggestionFeatureConfigLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + SetSuggestionFeatureConfigRequest request = + SetSuggestionFeatureConfigRequest.newBuilder() + .setConversationProfile("conversationProfile1691597734") + .setSuggestionFeatureConfig( + HumanAgentAssistantConfig.SuggestionFeatureConfig.newBuilder().build()) + .build(); + OperationFuture future = + conversationProfilesClient + .setSuggestionFeatureConfigOperationCallable() + .futureCall(request); + // Do something. + ConversationProfile response = future.get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_setsuggestionfeatureconfig_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfig.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfig.java new file mode 100644 index 000000000000..f4295fa7171b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_setsuggestionfeatureconfig_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.HumanAgentAssistantConfig; +import com.google.cloud.dialogflow.v2beta1.SetSuggestionFeatureConfigRequest; + +public class SyncSetSuggestionFeatureConfig { + + public static void main(String[] args) throws Exception { + syncSetSuggestionFeatureConfig(); + } + + public static void syncSetSuggestionFeatureConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + SetSuggestionFeatureConfigRequest request = + SetSuggestionFeatureConfigRequest.newBuilder() + .setConversationProfile("conversationProfile1691597734") + .setSuggestionFeatureConfig( + HumanAgentAssistantConfig.SuggestionFeatureConfig.newBuilder().build()) + .build(); + ConversationProfile response = + conversationProfilesClient.setSuggestionFeatureConfigAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_setsuggestionfeatureconfig_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfigString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfigString.java new file mode 100644 index 000000000000..b4e72c034dea --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/setsuggestionfeatureconfig/SyncSetSuggestionFeatureConfigString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_setsuggestionfeatureconfig_string_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; + +public class SyncSetSuggestionFeatureConfigString { + + public static void main(String[] args) throws Exception { + syncSetSuggestionFeatureConfigString(); + } + + public static void syncSetSuggestionFeatureConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + String conversationProfile = "conversationProfile1691597734"; + ConversationProfile response = + conversationProfilesClient.setSuggestionFeatureConfigAsync(conversationProfile).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_setsuggestionfeatureconfig_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/updateconversationprofile/AsyncUpdateConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/updateconversationprofile/AsyncUpdateConversationProfile.java new file mode 100644 index 000000000000..e6a413ac500e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/updateconversationprofile/AsyncUpdateConversationProfile.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_updateconversationprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.UpdateConversationProfileRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateConversationProfile { + + public static void main(String[] args) throws Exception { + asyncUpdateConversationProfile(); + } + + public static void asyncUpdateConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + UpdateConversationProfileRequest request = + UpdateConversationProfileRequest.newBuilder() + .setConversationProfile(ConversationProfile.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + conversationProfilesClient.updateConversationProfileCallable().futureCall(request); + // Do something. + ConversationProfile response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_updateconversationprofile_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfile.java new file mode 100644 index 000000000000..b455a246a9f0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfile.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesclient_updateconversationprofile_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.cloud.dialogflow.v2beta1.UpdateConversationProfileRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateConversationProfile { + + public static void main(String[] args) throws Exception { + syncUpdateConversationProfile(); + } + + public static void syncUpdateConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + UpdateConversationProfileRequest request = + UpdateConversationProfileRequest.newBuilder() + .setConversationProfile(ConversationProfile.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ConversationProfile response = conversationProfilesClient.updateConversationProfile(request); + } + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesclient_updateconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfileConversationprofileFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfileConversationprofileFieldmask.java new file mode 100644 index 000000000000..d0c16c88df73 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilesclient/updateconversationprofile/SyncUpdateConversationProfileConversationprofileFieldmask.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationprofilesclient_updateconversationprofile_conversationprofilefieldmask_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfile; +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateConversationProfileConversationprofileFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateConversationProfileConversationprofileFieldmask(); + } + + public static void syncUpdateConversationProfileConversationprofileFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationProfilesClient conversationProfilesClient = + ConversationProfilesClient.create()) { + ConversationProfile conversationProfile = ConversationProfile.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ConversationProfile response = + conversationProfilesClient.updateConversationProfile(conversationProfile, updateMask); + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationprofilesclient_updateconversationprofile_conversationprofilefieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilessettings/getconversationprofile/SyncGetConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilessettings/getconversationprofile/SyncGetConversationProfile.java new file mode 100644 index 000000000000..3a7221e1a28b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationprofilessettings/getconversationprofile/SyncGetConversationProfile.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilessettings_getconversationprofile_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationProfilesSettings; +import java.time.Duration; + +public class SyncGetConversationProfile { + + public static void main(String[] args) throws Exception { + syncGetConversationProfile(); + } + + public static void syncGetConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationProfilesSettings.Builder conversationProfilesSettingsBuilder = + ConversationProfilesSettings.newBuilder(); + conversationProfilesSettingsBuilder + .getConversationProfileSettings() + .setRetrySettings( + conversationProfilesSettingsBuilder + .getConversationProfileSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConversationProfilesSettings conversationProfilesSettings = + conversationProfilesSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_conversationprofilessettings_getconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/AsyncBatchCreateMessages.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/AsyncBatchCreateMessages.java new file mode 100644 index 000000000000..19d8081608ef --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/AsyncBatchCreateMessages.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_batchcreatemessages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.BatchCreateMessagesRequest; +import com.google.cloud.dialogflow.v2beta1.BatchCreateMessagesResponse; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.CreateMessageRequest; +import java.util.ArrayList; + +public class AsyncBatchCreateMessages { + + public static void main(String[] args) throws Exception { + asyncBatchCreateMessages(); + } + + public static void asyncBatchCreateMessages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + BatchCreateMessagesRequest request = + BatchCreateMessagesRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .addAllRequests(new ArrayList()) + .build(); + ApiFuture future = + conversationsClient.batchCreateMessagesCallable().futureCall(request); + // Do something. + BatchCreateMessagesResponse response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_batchcreatemessages_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/SyncBatchCreateMessages.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/SyncBatchCreateMessages.java new file mode 100644 index 000000000000..a4f381a83591 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/SyncBatchCreateMessages.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_batchcreatemessages_sync] +import com.google.cloud.dialogflow.v2beta1.BatchCreateMessagesRequest; +import com.google.cloud.dialogflow.v2beta1.BatchCreateMessagesResponse; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.CreateMessageRequest; +import java.util.ArrayList; + +public class SyncBatchCreateMessages { + + public static void main(String[] args) throws Exception { + syncBatchCreateMessages(); + } + + public static void syncBatchCreateMessages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + BatchCreateMessagesRequest request = + BatchCreateMessagesRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .addAllRequests(new ArrayList()) + .build(); + BatchCreateMessagesResponse response = conversationsClient.batchCreateMessages(request); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_batchcreatemessages_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/SyncBatchCreateMessagesConversationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/SyncBatchCreateMessagesConversationname.java new file mode 100644 index 000000000000..b5cb481494d8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/SyncBatchCreateMessagesConversationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationsclient_batchcreatemessages_conversationname_sync] +import com.google.cloud.dialogflow.v2beta1.BatchCreateMessagesResponse; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; + +public class SyncBatchCreateMessagesConversationname { + + public static void main(String[] args) throws Exception { + syncBatchCreateMessagesConversationname(); + } + + public static void syncBatchCreateMessagesConversationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + BatchCreateMessagesResponse response = conversationsClient.batchCreateMessages(parent); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_batchcreatemessages_conversationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/SyncBatchCreateMessagesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/SyncBatchCreateMessagesString.java new file mode 100644 index 000000000000..ba1a7fd76a40 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/batchcreatemessages/SyncBatchCreateMessagesString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_batchcreatemessages_string_sync] +import com.google.cloud.dialogflow.v2beta1.BatchCreateMessagesResponse; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; + +public class SyncBatchCreateMessagesString { + + public static void main(String[] args) throws Exception { + syncBatchCreateMessagesString(); + } + + public static void syncBatchCreateMessagesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + String parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString(); + BatchCreateMessagesResponse response = conversationsClient.batchCreateMessages(parent); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_batchcreatemessages_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/AsyncCompleteConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/AsyncCompleteConversation.java new file mode 100644 index 000000000000..0a13662631d5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/AsyncCompleteConversation.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_completeconversation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.CompleteConversationRequest; +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; + +public class AsyncCompleteConversation { + + public static void main(String[] args) throws Exception { + asyncCompleteConversation(); + } + + public static void asyncCompleteConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + CompleteConversationRequest request = + CompleteConversationRequest.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .build(); + ApiFuture future = + conversationsClient.completeConversationCallable().futureCall(request); + // Do something. + Conversation response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_completeconversation_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/SyncCompleteConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/SyncCompleteConversation.java new file mode 100644 index 000000000000..127fb4e7fa1b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/SyncCompleteConversation.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_completeconversation_sync] +import com.google.cloud.dialogflow.v2beta1.CompleteConversationRequest; +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; + +public class SyncCompleteConversation { + + public static void main(String[] args) throws Exception { + syncCompleteConversation(); + } + + public static void syncCompleteConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + CompleteConversationRequest request = + CompleteConversationRequest.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .build(); + Conversation response = conversationsClient.completeConversation(request); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_completeconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/SyncCompleteConversationConversationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/SyncCompleteConversationConversationname.java new file mode 100644 index 000000000000..0090f3bb6b55 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/SyncCompleteConversationConversationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationsclient_completeconversation_conversationname_sync] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; + +public class SyncCompleteConversationConversationname { + + public static void main(String[] args) throws Exception { + syncCompleteConversationConversationname(); + } + + public static void syncCompleteConversationConversationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ConversationName name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + Conversation response = conversationsClient.completeConversation(name); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_completeconversation_conversationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/SyncCompleteConversationString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/SyncCompleteConversationString.java new file mode 100644 index 000000000000..81efb1ff6760 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/completeconversation/SyncCompleteConversationString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_completeconversation_string_sync] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; + +public class SyncCompleteConversationString { + + public static void main(String[] args) throws Exception { + syncCompleteConversationString(); + } + + public static void syncCompleteConversationString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + String name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString(); + Conversation response = conversationsClient.completeConversation(name); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_completeconversation_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..3636572cdf86 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.ConversationsSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationsSettings conversationsSettings = + ConversationsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings); + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..63387490dd8c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.ConversationsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationsSettings conversationsSettings = + ConversationsSettings.newBuilder() + .setTransportChannelProvider( + ConversationsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings); + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..f734500692c7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.ConversationsSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationsSettings conversationsSettings = + ConversationsSettings.newBuilder().setEndpoint(myEndpoint).build(); + ConversationsClient conversationsClient = ConversationsClient.create(conversationsSettings); + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/AsyncCreateConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/AsyncCreateConversation.java new file mode 100644 index 000000000000..fc23b99ddef9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/AsyncCreateConversation.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_createconversation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.CreateConversationRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class AsyncCreateConversation { + + public static void main(String[] args) throws Exception { + asyncCreateConversation(); + } + + public static void asyncCreateConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + CreateConversationRequest request = + CreateConversationRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setConversation(Conversation.newBuilder().build()) + .setConversationId("conversationId-1676095234") + .build(); + ApiFuture future = + conversationsClient.createConversationCallable().futureCall(request); + // Do something. + Conversation response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_createconversation_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversation.java new file mode 100644 index 000000000000..9dba653c9ea1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversation.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_createconversation_sync] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.CreateConversationRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncCreateConversation { + + public static void main(String[] args) throws Exception { + syncCreateConversation(); + } + + public static void syncCreateConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + CreateConversationRequest request = + CreateConversationRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setConversation(Conversation.newBuilder().build()) + .setConversationId("conversationId-1676095234") + .build(); + Conversation response = conversationsClient.createConversation(request); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_createconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversationLocationnameConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversationLocationnameConversation.java new file mode 100644 index 000000000000..b07df0f1a1f8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversationLocationnameConversation.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationsclient_createconversation_locationnameconversation_sync] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.LocationName; + +public class SyncCreateConversationLocationnameConversation { + + public static void main(String[] args) throws Exception { + syncCreateConversationLocationnameConversation(); + } + + public static void syncCreateConversationLocationnameConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Conversation conversation = Conversation.newBuilder().build(); + Conversation response = conversationsClient.createConversation(parent, conversation); + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationsclient_createconversation_locationnameconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversationProjectnameConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversationProjectnameConversation.java new file mode 100644 index 000000000000..450ae157b622 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversationProjectnameConversation.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationsclient_createconversation_projectnameconversation_sync] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncCreateConversationProjectnameConversation { + + public static void main(String[] args) throws Exception { + syncCreateConversationProjectnameConversation(); + } + + public static void syncCreateConversationProjectnameConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + Conversation conversation = Conversation.newBuilder().build(); + Conversation response = conversationsClient.createConversation(parent, conversation); + } + } +} +// [END +// dialogflow_v2beta1_generated_conversationsclient_createconversation_projectnameconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversationStringConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversationStringConversation.java new file mode 100644 index 000000000000..56d87e991a7d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/createconversation/SyncCreateConversationStringConversation.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_conversationsclient_createconversation_stringconversation_sync] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncCreateConversationStringConversation { + + public static void main(String[] args) throws Exception { + syncCreateConversationStringConversation(); + } + + public static void syncCreateConversationStringConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + Conversation conversation = Conversation.newBuilder().build(); + Conversation response = conversationsClient.createConversation(parent, conversation); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_createconversation_stringconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/AsyncGetConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/AsyncGetConversation.java new file mode 100644 index 000000000000..34ce68faaf46 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/AsyncGetConversation.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_getconversation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.GetConversationRequest; + +public class AsyncGetConversation { + + public static void main(String[] args) throws Exception { + asyncGetConversation(); + } + + public static void asyncGetConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + GetConversationRequest request = + GetConversationRequest.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .build(); + ApiFuture future = + conversationsClient.getConversationCallable().futureCall(request); + // Do something. + Conversation response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_getconversation_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/SyncGetConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/SyncGetConversation.java new file mode 100644 index 000000000000..26a663334745 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/SyncGetConversation.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_getconversation_sync] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.GetConversationRequest; + +public class SyncGetConversation { + + public static void main(String[] args) throws Exception { + syncGetConversation(); + } + + public static void syncGetConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + GetConversationRequest request = + GetConversationRequest.newBuilder() + .setName( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .build(); + Conversation response = conversationsClient.getConversation(request); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_getconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/SyncGetConversationConversationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/SyncGetConversationConversationname.java new file mode 100644 index 000000000000..559d6d13d472 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/SyncGetConversationConversationname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_getconversation_conversationname_sync] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; + +public class SyncGetConversationConversationname { + + public static void main(String[] args) throws Exception { + syncGetConversationConversationname(); + } + + public static void syncGetConversationConversationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ConversationName name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + Conversation response = conversationsClient.getConversation(name); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_getconversation_conversationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/SyncGetConversationString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/SyncGetConversationString.java new file mode 100644 index 000000000000..9254dc0bec44 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/getconversation/SyncGetConversationString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_getconversation_string_sync] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; + +public class SyncGetConversationString { + + public static void main(String[] args) throws Exception { + syncGetConversationString(); + } + + public static void syncGetConversationString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + String name = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString(); + Conversation response = conversationsClient.getConversation(name); + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_getconversation_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/AsyncListConversations.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/AsyncListConversations.java new file mode 100644 index 000000000000..c26869917dd0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/AsyncListConversations.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_listconversations_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.ListConversationsRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class AsyncListConversations { + + public static void main(String[] args) throws Exception { + asyncListConversations(); + } + + public static void asyncListConversations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ListConversationsRequest request = + ListConversationsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + conversationsClient.listConversationsPagedCallable().futureCall(request); + // Do something. + for (Conversation element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_listconversations_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/AsyncListConversationsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/AsyncListConversationsPaged.java new file mode 100644 index 000000000000..bff4312a4027 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/AsyncListConversationsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_listconversations_paged_async] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.ListConversationsRequest; +import com.google.cloud.dialogflow.v2beta1.ListConversationsResponse; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListConversationsPaged { + + public static void main(String[] args) throws Exception { + asyncListConversationsPaged(); + } + + public static void asyncListConversationsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ListConversationsRequest request = + ListConversationsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListConversationsResponse response = + conversationsClient.listConversationsCallable().call(request); + for (Conversation element : response.getConversationsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_listconversations_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversations.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversations.java new file mode 100644 index 000000000000..064c00fbf652 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversations.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_listconversations_sync] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.ListConversationsRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncListConversations { + + public static void main(String[] args) throws Exception { + syncListConversations(); + } + + public static void syncListConversations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ListConversationsRequest request = + ListConversationsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Conversation element : conversationsClient.listConversations(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_listconversations_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversationsLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversationsLocationname.java new file mode 100644 index 000000000000..f6a0ec2027c5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversationsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_listconversations_locationname_sync] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.LocationName; + +public class SyncListConversationsLocationname { + + public static void main(String[] args) throws Exception { + syncListConversationsLocationname(); + } + + public static void syncListConversationsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_listconversations_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversationsProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversationsProjectname.java new file mode 100644 index 000000000000..c97b50aab950 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversationsProjectname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_listconversations_projectname_sync] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncListConversationsProjectname { + + public static void main(String[] args) throws Exception { + syncListConversationsProjectname(); + } + + public static void syncListConversationsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_listconversations_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversationsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversationsString.java new file mode 100644 index 000000000000..0430639bb515 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listconversations/SyncListConversationsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_listconversations_string_sync] +import com.google.cloud.dialogflow.v2beta1.Conversation; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncListConversationsString { + + public static void main(String[] args) throws Exception { + syncListConversationsString(); + } + + public static void syncListConversationsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (Conversation element : conversationsClient.listConversations(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_listconversations_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/AsyncListMessages.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/AsyncListMessages.java new file mode 100644 index 000000000000..6e9115b25462 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/AsyncListMessages.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_listmessages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.ListMessagesRequest; +import com.google.cloud.dialogflow.v2beta1.Message; + +public class AsyncListMessages { + + public static void main(String[] args) throws Exception { + asyncListMessages(); + } + + public static void asyncListMessages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ListMessagesRequest request = + ListMessagesRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + conversationsClient.listMessagesPagedCallable().futureCall(request); + // Do something. + for (Message element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_listmessages_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/AsyncListMessagesPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/AsyncListMessagesPaged.java new file mode 100644 index 000000000000..1e5cd6b86a41 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/AsyncListMessagesPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_listmessages_paged_async] +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.ListMessagesRequest; +import com.google.cloud.dialogflow.v2beta1.ListMessagesResponse; +import com.google.cloud.dialogflow.v2beta1.Message; +import com.google.common.base.Strings; + +public class AsyncListMessagesPaged { + + public static void main(String[] args) throws Exception { + asyncListMessagesPaged(); + } + + public static void asyncListMessagesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ListMessagesRequest request = + ListMessagesRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListMessagesResponse response = conversationsClient.listMessagesCallable().call(request); + for (Message element : response.getMessagesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_listmessages_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/SyncListMessages.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/SyncListMessages.java new file mode 100644 index 000000000000..b197812d3f73 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/SyncListMessages.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_listmessages_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.ListMessagesRequest; +import com.google.cloud.dialogflow.v2beta1.Message; + +public class SyncListMessages { + + public static void main(String[] args) throws Exception { + syncListMessages(); + } + + public static void syncListMessages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ListMessagesRequest request = + ListMessagesRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Message element : conversationsClient.listMessages(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_listmessages_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/SyncListMessagesConversationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/SyncListMessagesConversationname.java new file mode 100644 index 000000000000..5e7866a30353 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/SyncListMessagesConversationname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_listmessages_conversationname_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.Message; + +public class SyncListMessagesConversationname { + + public static void main(String[] args) throws Exception { + syncListMessagesConversationname(); + } + + public static void syncListMessagesConversationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + for (Message element : conversationsClient.listMessages(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_listmessages_conversationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/SyncListMessagesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/SyncListMessagesString.java new file mode 100644 index 000000000000..f7dedf7c66a7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationsclient/listmessages/SyncListMessagesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationsclient_listmessages_string_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ConversationsClient; +import com.google.cloud.dialogflow.v2beta1.Message; + +public class SyncListMessagesString { + + public static void main(String[] args) throws Exception { + syncListMessagesString(); + } + + public static void syncListMessagesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ConversationsClient conversationsClient = ConversationsClient.create()) { + String parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString(); + for (Message element : conversationsClient.listMessages(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_conversationsclient_listmessages_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationssettings/createconversation/SyncCreateConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationssettings/createconversation/SyncCreateConversation.java new file mode 100644 index 000000000000..e4d3e012dc67 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/conversationssettings/createconversation/SyncCreateConversation.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_conversationssettings_createconversation_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationsSettings; +import java.time.Duration; + +public class SyncCreateConversation { + + public static void main(String[] args) throws Exception { + syncCreateConversation(); + } + + public static void syncCreateConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationsSettings.Builder conversationsSettingsBuilder = ConversationsSettings.newBuilder(); + conversationsSettingsBuilder + .createConversationSettings() + .setRetrySettings( + conversationsSettingsBuilder + .createConversationSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConversationsSettings conversationsSettings = conversationsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_conversationssettings_createconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..c5ee89187a97 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.DocumentsSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentsSettings documentsSettings = + DocumentsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + DocumentsClient documentsClient = DocumentsClient.create(documentsSettings); + } +} +// [END dialogflow_v2beta1_generated_documentsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..3728091cc224 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.DocumentsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentsSettings documentsSettings = + DocumentsSettings.newBuilder() + .setTransportChannelProvider( + DocumentsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + DocumentsClient documentsClient = DocumentsClient.create(documentsSettings); + } +} +// [END dialogflow_v2beta1_generated_documentsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..8d7a66d3bb89 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.DocumentsSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentsSettings documentsSettings = + DocumentsSettings.newBuilder().setEndpoint(myEndpoint).build(); + DocumentsClient documentsClient = DocumentsClient.create(documentsSettings); + } +} +// [END dialogflow_v2beta1_generated_documentsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/AsyncCreateDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/AsyncCreateDocument.java new file mode 100644 index 000000000000..3e2b3b416a9a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/AsyncCreateDocument.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_createdocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.CreateDocumentRequest; +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.longrunning.Operation; + +public class AsyncCreateDocument { + + public static void main(String[] args) throws Exception { + asyncCreateDocument(); + } + + public static void asyncCreateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + CreateDocumentRequest request = + CreateDocumentRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocument(Document.newBuilder().build()) + .setImportGcsCustomMetadata(true) + .build(); + ApiFuture future = documentsClient.createDocumentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_createdocument_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/AsyncCreateDocumentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/AsyncCreateDocumentLRO.java new file mode 100644 index 000000000000..a39f89d4eeaa --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/AsyncCreateDocumentLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_createdocument_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.CreateDocumentRequest; +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2beta1.KnowledgeOperationMetadata; + +public class AsyncCreateDocumentLRO { + + public static void main(String[] args) throws Exception { + asyncCreateDocumentLRO(); + } + + public static void asyncCreateDocumentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + CreateDocumentRequest request = + CreateDocumentRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocument(Document.newBuilder().build()) + .setImportGcsCustomMetadata(true) + .build(); + OperationFuture future = + documentsClient.createDocumentOperationCallable().futureCall(request); + // Do something. + Document response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_createdocument_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/SyncCreateDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/SyncCreateDocument.java new file mode 100644 index 000000000000..bafb97f06308 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/SyncCreateDocument.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_createdocument_sync] +import com.google.cloud.dialogflow.v2beta1.CreateDocumentRequest; +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; + +public class SyncCreateDocument { + + public static void main(String[] args) throws Exception { + syncCreateDocument(); + } + + public static void syncCreateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + CreateDocumentRequest request = + CreateDocumentRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocument(Document.newBuilder().build()) + .setImportGcsCustomMetadata(true) + .build(); + Document response = documentsClient.createDocumentAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_createdocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/SyncCreateDocumentKnowledgebasenameDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/SyncCreateDocumentKnowledgebasenameDocument.java new file mode 100644 index 000000000000..9ce40af747f7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/SyncCreateDocumentKnowledgebasenameDocument.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_documentsclient_createdocument_knowledgebasenamedocument_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; + +public class SyncCreateDocumentKnowledgebasenameDocument { + + public static void main(String[] args) throws Exception { + syncCreateDocumentKnowledgebasenameDocument(); + } + + public static void syncCreateDocumentKnowledgebasenameDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + KnowledgeBaseName parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + Document document = Document.newBuilder().build(); + Document response = documentsClient.createDocumentAsync(parent, document).get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_createdocument_knowledgebasenamedocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/SyncCreateDocumentStringDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/SyncCreateDocumentStringDocument.java new file mode 100644 index 000000000000..66bc88b947de --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/createdocument/SyncCreateDocumentStringDocument.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_createdocument_stringdocument_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; + +public class SyncCreateDocumentStringDocument { + + public static void main(String[] args) throws Exception { + syncCreateDocumentStringDocument(); + } + + public static void syncCreateDocumentStringDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + String parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]").toString(); + Document document = Document.newBuilder().build(); + Document response = documentsClient.createDocumentAsync(parent, document).get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_createdocument_stringdocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/AsyncDeleteDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/AsyncDeleteDocument.java new file mode 100644 index 000000000000..866b6fa9b77f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/AsyncDeleteDocument.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_deletedocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.DeleteDocumentRequest; +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteDocument { + + public static void main(String[] args) throws Exception { + asyncDeleteDocument(); + } + + public static void asyncDeleteDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + DeleteDocumentRequest request = + DeleteDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .build(); + ApiFuture future = documentsClient.deleteDocumentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_deletedocument_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/AsyncDeleteDocumentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/AsyncDeleteDocumentLRO.java new file mode 100644 index 000000000000..379652d678c0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/AsyncDeleteDocumentLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_deletedocument_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.DeleteDocumentRequest; +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeOperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteDocumentLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteDocumentLRO(); + } + + public static void asyncDeleteDocumentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + DeleteDocumentRequest request = + DeleteDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .build(); + OperationFuture future = + documentsClient.deleteDocumentOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_deletedocument_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/SyncDeleteDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/SyncDeleteDocument.java new file mode 100644 index 000000000000..40b33bc5b930 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/SyncDeleteDocument.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_deletedocument_sync] +import com.google.cloud.dialogflow.v2beta1.DeleteDocumentRequest; +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; + +public class SyncDeleteDocument { + + public static void main(String[] args) throws Exception { + syncDeleteDocument(); + } + + public static void syncDeleteDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + DeleteDocumentRequest request = + DeleteDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .build(); + documentsClient.deleteDocumentAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_deletedocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/SyncDeleteDocumentDocumentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/SyncDeleteDocumentDocumentname.java new file mode 100644 index 000000000000..f09826b511ad --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/SyncDeleteDocumentDocumentname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_deletedocument_documentname_sync] +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; + +public class SyncDeleteDocumentDocumentname { + + public static void main(String[] args) throws Exception { + syncDeleteDocumentDocumentname(); + } + + public static void syncDeleteDocumentDocumentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + documentsClient.deleteDocumentAsync(name).get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_deletedocument_documentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/SyncDeleteDocumentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/SyncDeleteDocumentString.java new file mode 100644 index 000000000000..c3670bcf4938 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/deletedocument/SyncDeleteDocumentString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_deletedocument_string_sync] +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; + +public class SyncDeleteDocumentString { + + public static void main(String[] args) throws Exception { + syncDeleteDocumentString(); + } + + public static void syncDeleteDocumentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + String name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString(); + documentsClient.deleteDocumentAsync(name).get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_deletedocument_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/AsyncGetDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/AsyncGetDocument.java new file mode 100644 index 000000000000..850caa9319db --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/AsyncGetDocument.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_getdocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.GetDocumentRequest; + +public class AsyncGetDocument { + + public static void main(String[] args) throws Exception { + asyncGetDocument(); + } + + public static void asyncGetDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + GetDocumentRequest request = + GetDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .build(); + ApiFuture future = documentsClient.getDocumentCallable().futureCall(request); + // Do something. + Document response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_getdocument_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/SyncGetDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/SyncGetDocument.java new file mode 100644 index 000000000000..459b1a8d2297 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/SyncGetDocument.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_getdocument_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.GetDocumentRequest; + +public class SyncGetDocument { + + public static void main(String[] args) throws Exception { + syncGetDocument(); + } + + public static void syncGetDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + GetDocumentRequest request = + GetDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .build(); + Document response = documentsClient.getDocument(request); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_getdocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/SyncGetDocumentDocumentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/SyncGetDocumentDocumentname.java new file mode 100644 index 000000000000..c0a8f1c267cb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/SyncGetDocumentDocumentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_getdocument_documentname_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; + +public class SyncGetDocumentDocumentname { + + public static void main(String[] args) throws Exception { + syncGetDocumentDocumentname(); + } + + public static void syncGetDocumentDocumentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + Document response = documentsClient.getDocument(name); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_getdocument_documentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/SyncGetDocumentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/SyncGetDocumentString.java new file mode 100644 index 000000000000..9d4490618e4d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/getdocument/SyncGetDocumentString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_getdocument_string_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; + +public class SyncGetDocumentString { + + public static void main(String[] args) throws Exception { + syncGetDocumentString(); + } + + public static void syncGetDocumentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + String name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString(); + Document response = documentsClient.getDocument(name); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_getdocument_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/importdocuments/AsyncImportDocuments.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/importdocuments/AsyncImportDocuments.java new file mode 100644 index 000000000000..770dcf911ed8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/importdocuments/AsyncImportDocuments.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_importdocuments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.ImportDocumentTemplate; +import com.google.cloud.dialogflow.v2beta1.ImportDocumentsRequest; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.longrunning.Operation; + +public class AsyncImportDocuments { + + public static void main(String[] args) throws Exception { + asyncImportDocuments(); + } + + public static void asyncImportDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ImportDocumentsRequest request = + ImportDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocumentTemplate(ImportDocumentTemplate.newBuilder().build()) + .setImportGcsCustomMetadata(true) + .build(); + ApiFuture future = documentsClient.importDocumentsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_importdocuments_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/importdocuments/AsyncImportDocumentsLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/importdocuments/AsyncImportDocumentsLRO.java new file mode 100644 index 000000000000..34e1cf03c5ba --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/importdocuments/AsyncImportDocumentsLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_importdocuments_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.ImportDocumentTemplate; +import com.google.cloud.dialogflow.v2beta1.ImportDocumentsRequest; +import com.google.cloud.dialogflow.v2beta1.ImportDocumentsResponse; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2beta1.KnowledgeOperationMetadata; + +public class AsyncImportDocumentsLRO { + + public static void main(String[] args) throws Exception { + asyncImportDocumentsLRO(); + } + + public static void asyncImportDocumentsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ImportDocumentsRequest request = + ImportDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocumentTemplate(ImportDocumentTemplate.newBuilder().build()) + .setImportGcsCustomMetadata(true) + .build(); + OperationFuture future = + documentsClient.importDocumentsOperationCallable().futureCall(request); + // Do something. + ImportDocumentsResponse response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_importdocuments_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/importdocuments/SyncImportDocuments.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/importdocuments/SyncImportDocuments.java new file mode 100644 index 000000000000..49b2aca8b0e5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/importdocuments/SyncImportDocuments.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_importdocuments_sync] +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.ImportDocumentTemplate; +import com.google.cloud.dialogflow.v2beta1.ImportDocumentsRequest; +import com.google.cloud.dialogflow.v2beta1.ImportDocumentsResponse; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; + +public class SyncImportDocuments { + + public static void main(String[] args) throws Exception { + syncImportDocuments(); + } + + public static void syncImportDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ImportDocumentsRequest request = + ImportDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setDocumentTemplate(ImportDocumentTemplate.newBuilder().build()) + .setImportGcsCustomMetadata(true) + .build(); + ImportDocumentsResponse response = documentsClient.importDocumentsAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_importdocuments_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/AsyncListDocuments.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/AsyncListDocuments.java new file mode 100644 index 000000000000..a58d456f6eec --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/AsyncListDocuments.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_listdocuments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2beta1.ListDocumentsRequest; + +public class AsyncListDocuments { + + public static void main(String[] args) throws Exception { + asyncListDocuments(); + } + + public static void asyncListDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ListDocumentsRequest request = + ListDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = documentsClient.listDocumentsPagedCallable().futureCall(request); + // Do something. + for (Document element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_listdocuments_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/AsyncListDocumentsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/AsyncListDocumentsPaged.java new file mode 100644 index 000000000000..2d329f78adb4 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/AsyncListDocumentsPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_listdocuments_paged_async] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2beta1.ListDocumentsRequest; +import com.google.cloud.dialogflow.v2beta1.ListDocumentsResponse; +import com.google.common.base.Strings; + +public class AsyncListDocumentsPaged { + + public static void main(String[] args) throws Exception { + asyncListDocumentsPaged(); + } + + public static void asyncListDocumentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ListDocumentsRequest request = + ListDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListDocumentsResponse response = documentsClient.listDocumentsCallable().call(request); + for (Document element : response.getDocumentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_listdocuments_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/SyncListDocuments.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/SyncListDocuments.java new file mode 100644 index 000000000000..6bba9b390f78 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/SyncListDocuments.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_listdocuments_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2beta1.ListDocumentsRequest; + +public class SyncListDocuments { + + public static void main(String[] args) throws Exception { + syncListDocuments(); + } + + public static void syncListDocuments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ListDocumentsRequest request = + ListDocumentsRequest.newBuilder() + .setParent( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Document element : documentsClient.listDocuments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_listdocuments_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/SyncListDocumentsKnowledgebasename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/SyncListDocumentsKnowledgebasename.java new file mode 100644 index 000000000000..9d430c8ecc27 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/SyncListDocumentsKnowledgebasename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_listdocuments_knowledgebasename_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; + +public class SyncListDocumentsKnowledgebasename { + + public static void main(String[] args) throws Exception { + syncListDocumentsKnowledgebasename(); + } + + public static void syncListDocumentsKnowledgebasename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + KnowledgeBaseName parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + for (Document element : documentsClient.listDocuments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_listdocuments_knowledgebasename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/SyncListDocumentsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/SyncListDocumentsString.java new file mode 100644 index 000000000000..c2abfb697a61 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/listdocuments/SyncListDocumentsString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_listdocuments_string_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; + +public class SyncListDocumentsString { + + public static void main(String[] args) throws Exception { + syncListDocumentsString(); + } + + public static void syncListDocumentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + String parent = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]").toString(); + for (Document element : documentsClient.listDocuments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_listdocuments_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/AsyncReloadDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/AsyncReloadDocument.java new file mode 100644 index 000000000000..ddf427bb5c02 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/AsyncReloadDocument.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_reloaddocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.ReloadDocumentRequest; +import com.google.longrunning.Operation; + +public class AsyncReloadDocument { + + public static void main(String[] args) throws Exception { + asyncReloadDocument(); + } + + public static void asyncReloadDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ReloadDocumentRequest request = + ReloadDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setImportGcsCustomMetadata(true) + .build(); + ApiFuture future = documentsClient.reloadDocumentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_reloaddocument_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/AsyncReloadDocumentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/AsyncReloadDocumentLRO.java new file mode 100644 index 000000000000..3b17a7039434 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/AsyncReloadDocumentLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_reloaddocument_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeOperationMetadata; +import com.google.cloud.dialogflow.v2beta1.ReloadDocumentRequest; + +public class AsyncReloadDocumentLRO { + + public static void main(String[] args) throws Exception { + asyncReloadDocumentLRO(); + } + + public static void asyncReloadDocumentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ReloadDocumentRequest request = + ReloadDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setImportGcsCustomMetadata(true) + .build(); + OperationFuture future = + documentsClient.reloadDocumentOperationCallable().futureCall(request); + // Do something. + Document response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_reloaddocument_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/SyncReloadDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/SyncReloadDocument.java new file mode 100644 index 000000000000..75236d7faa14 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/SyncReloadDocument.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_reloaddocument_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.ReloadDocumentRequest; + +public class SyncReloadDocument { + + public static void main(String[] args) throws Exception { + syncReloadDocument(); + } + + public static void syncReloadDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + ReloadDocumentRequest request = + ReloadDocumentRequest.newBuilder() + .setName( + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString()) + .setImportGcsCustomMetadata(true) + .build(); + Document response = documentsClient.reloadDocumentAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_reloaddocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/SyncReloadDocumentDocumentnameGcssource.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/SyncReloadDocumentDocumentnameGcssource.java new file mode 100644 index 000000000000..7a9d699d3a75 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/SyncReloadDocumentDocumentnameGcssource.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_reloaddocument_documentnamegcssource_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.GcsSource; + +public class SyncReloadDocumentDocumentnameGcssource { + + public static void main(String[] args) throws Exception { + syncReloadDocumentDocumentnameGcssource(); + } + + public static void syncReloadDocumentDocumentnameGcssource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + DocumentName name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]"); + GcsSource gcsSource = GcsSource.newBuilder().build(); + Document response = documentsClient.reloadDocumentAsync(name, gcsSource).get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_reloaddocument_documentnamegcssource_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/SyncReloadDocumentStringGcssource.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/SyncReloadDocumentStringGcssource.java new file mode 100644 index 000000000000..4548332b1780 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/reloaddocument/SyncReloadDocumentStringGcssource.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_reloaddocument_stringgcssource_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentName; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.GcsSource; + +public class SyncReloadDocumentStringGcssource { + + public static void main(String[] args) throws Exception { + syncReloadDocumentStringGcssource(); + } + + public static void syncReloadDocumentStringGcssource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + String name = + DocumentName.ofProjectKnowledgeBaseDocumentName( + "[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]") + .toString(); + GcsSource gcsSource = GcsSource.newBuilder().build(); + Document response = documentsClient.reloadDocumentAsync(name, gcsSource).get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_reloaddocument_stringgcssource_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/AsyncUpdateDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/AsyncUpdateDocument.java new file mode 100644 index 000000000000..8b26acc98064 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/AsyncUpdateDocument.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_updatedocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateDocumentRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateDocument { + + public static void main(String[] args) throws Exception { + asyncUpdateDocument(); + } + + public static void asyncUpdateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + UpdateDocumentRequest request = + UpdateDocumentRequest.newBuilder() + .setDocument(Document.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = documentsClient.updateDocumentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_updatedocument_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/AsyncUpdateDocumentLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/AsyncUpdateDocumentLRO.java new file mode 100644 index 000000000000..4a4f54176e7e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/AsyncUpdateDocumentLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_updatedocument_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeOperationMetadata; +import com.google.cloud.dialogflow.v2beta1.UpdateDocumentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateDocumentLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateDocumentLRO(); + } + + public static void asyncUpdateDocumentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + UpdateDocumentRequest request = + UpdateDocumentRequest.newBuilder() + .setDocument(Document.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + documentsClient.updateDocumentOperationCallable().futureCall(request); + // Do something. + Document response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_updatedocument_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/SyncUpdateDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/SyncUpdateDocument.java new file mode 100644 index 000000000000..7ff8b383ddf2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/SyncUpdateDocument.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_updatedocument_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateDocumentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateDocument { + + public static void main(String[] args) throws Exception { + syncUpdateDocument(); + } + + public static void syncUpdateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + UpdateDocumentRequest request = + UpdateDocumentRequest.newBuilder() + .setDocument(Document.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Document response = documentsClient.updateDocumentAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_updatedocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/SyncUpdateDocumentDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/SyncUpdateDocumentDocument.java new file mode 100644 index 000000000000..23941f0d4112 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/SyncUpdateDocumentDocument.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_updatedocument_document_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; + +public class SyncUpdateDocumentDocument { + + public static void main(String[] args) throws Exception { + syncUpdateDocumentDocument(); + } + + public static void syncUpdateDocumentDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + Document document = Document.newBuilder().build(); + Document response = documentsClient.updateDocumentAsync(document).get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_updatedocument_document_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/SyncUpdateDocumentDocumentFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/SyncUpdateDocumentDocumentFieldmask.java new file mode 100644 index 000000000000..1316d7988eb8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentsclient/updatedocument/SyncUpdateDocumentDocumentFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentsclient_updatedocument_documentfieldmask_sync] +import com.google.cloud.dialogflow.v2beta1.Document; +import com.google.cloud.dialogflow.v2beta1.DocumentsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateDocumentDocumentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateDocumentDocumentFieldmask(); + } + + public static void syncUpdateDocumentDocumentFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DocumentsClient documentsClient = DocumentsClient.create()) { + Document document = Document.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Document response = documentsClient.updateDocumentAsync(document, updateMask).get(); + } + } +} +// [END dialogflow_v2beta1_generated_documentsclient_updatedocument_documentfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentssettings/getdocument/SyncGetDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentssettings/getdocument/SyncGetDocument.java new file mode 100644 index 000000000000..fbb36b1beaaa --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/documentssettings/getdocument/SyncGetDocument.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_documentssettings_getdocument_sync] +import com.google.cloud.dialogflow.v2beta1.DocumentsSettings; +import java.time.Duration; + +public class SyncGetDocument { + + public static void main(String[] args) throws Exception { + syncGetDocument(); + } + + public static void syncGetDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentsSettings.Builder documentsSettingsBuilder = DocumentsSettings.newBuilder(); + documentsSettingsBuilder + .getDocumentSettings() + .setRetrySettings( + documentsSettingsBuilder + .getDocumentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DocumentsSettings documentsSettings = documentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_documentssettings_getdocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/AsyncBatchCreateEntities.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/AsyncBatchCreateEntities.java new file mode 100644 index 000000000000..eed4a6b24b6b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/AsyncBatchCreateEntities.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.BatchCreateEntitiesRequest; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncBatchCreateEntities { + + public static void main(String[] args) throws Exception { + asyncBatchCreateEntities(); + } + + public static void asyncBatchCreateEntities() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchCreateEntitiesRequest request = + BatchCreateEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntities(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + ApiFuture future = + entityTypesClient.batchCreateEntitiesCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/AsyncBatchCreateEntitiesLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/AsyncBatchCreateEntitiesLRO.java new file mode 100644 index 000000000000..dd65e1b33f92 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/AsyncBatchCreateEntitiesLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.BatchCreateEntitiesRequest; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.util.ArrayList; + +public class AsyncBatchCreateEntitiesLRO { + + public static void main(String[] args) throws Exception { + asyncBatchCreateEntitiesLRO(); + } + + public static void asyncBatchCreateEntitiesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchCreateEntitiesRequest request = + BatchCreateEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntities(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + OperationFuture future = + entityTypesClient.batchCreateEntitiesOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntities.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntities.java new file mode 100644 index 000000000000..a2e4b218a464 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntities.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_sync] +import com.google.cloud.dialogflow.v2beta1.BatchCreateEntitiesRequest; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; + +public class SyncBatchCreateEntities { + + public static void main(String[] args) throws Exception { + syncBatchCreateEntities(); + } + + public static void syncBatchCreateEntities() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchCreateEntitiesRequest request = + BatchCreateEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntities(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + entityTypesClient.batchCreateEntitiesAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentity.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentity.java new file mode 100644 index 000000000000..19f18488ed4d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentity.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_entitytypenamelistentitytypeentity_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchCreateEntitiesEntitytypenameListentitytypeentity { + + public static void main(String[] args) throws Exception { + syncBatchCreateEntitiesEntitytypenameListentitytypeentity(); + } + + public static void syncBatchCreateEntitiesEntitytypenameListentitytypeentity() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + entityTypesClient.batchCreateEntitiesAsync(parent, entities).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_entitytypenamelistentitytypeentity_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentityString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentityString.java new file mode 100644 index 000000000000..e32d47f1e12a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesEntitytypenameListentitytypeentityString.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_entitytypenamelistentitytypeentitystring_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchCreateEntitiesEntitytypenameListentitytypeentityString { + + public static void main(String[] args) throws Exception { + syncBatchCreateEntitiesEntitytypenameListentitytypeentityString(); + } + + public static void syncBatchCreateEntitiesEntitytypenameListentitytypeentityString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + entityTypesClient.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_entitytypenamelistentitytypeentitystring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentity.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentity.java new file mode 100644 index 000000000000..7c8e3c3dd23f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentity.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_stringlistentitytypeentity_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchCreateEntitiesStringListentitytypeentity { + + public static void main(String[] args) throws Exception { + syncBatchCreateEntitiesStringListentitytypeentity(); + } + + public static void syncBatchCreateEntitiesStringListentitytypeentity() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + List entities = new ArrayList<>(); + entityTypesClient.batchCreateEntitiesAsync(parent, entities).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_stringlistentitytypeentity_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentityString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentityString.java new file mode 100644 index 000000000000..4e670bd3d673 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchcreateentities/SyncBatchCreateEntitiesStringListentitytypeentityString.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_stringlistentitytypeentitystring_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchCreateEntitiesStringListentitytypeentityString { + + public static void main(String[] args) throws Exception { + syncBatchCreateEntitiesStringListentitytypeentityString(); + } + + public static void syncBatchCreateEntitiesStringListentitytypeentityString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + entityTypesClient.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_batchcreateentities_stringlistentitytypeentitystring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntities.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntities.java new file mode 100644 index 000000000000..621ab0483e37 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntities.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.BatchDeleteEntitiesRequest; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncBatchDeleteEntities { + + public static void main(String[] args) throws Exception { + asyncBatchDeleteEntities(); + } + + public static void asyncBatchDeleteEntities() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchDeleteEntitiesRequest request = + BatchDeleteEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntityValues(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + ApiFuture future = + entityTypesClient.batchDeleteEntitiesCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntitiesLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntitiesLRO.java new file mode 100644 index 000000000000..2f64ebdf68a6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/AsyncBatchDeleteEntitiesLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.BatchDeleteEntitiesRequest; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.util.ArrayList; + +public class AsyncBatchDeleteEntitiesLRO { + + public static void main(String[] args) throws Exception { + asyncBatchDeleteEntitiesLRO(); + } + + public static void asyncBatchDeleteEntitiesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchDeleteEntitiesRequest request = + BatchDeleteEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntityValues(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + OperationFuture future = + entityTypesClient.batchDeleteEntitiesOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntities.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntities.java new file mode 100644 index 000000000000..53c54979a8fc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntities.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_sync] +import com.google.cloud.dialogflow.v2beta1.BatchDeleteEntitiesRequest; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; + +public class SyncBatchDeleteEntities { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntities(); + } + + public static void syncBatchDeleteEntities() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchDeleteEntitiesRequest request = + BatchDeleteEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntityValues(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .build(); + entityTypesClient.batchDeleteEntitiesAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstring.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstring.java new file mode 100644 index 000000000000..cf8d97cf2c10 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstring.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_entitytypenameliststring_sync] +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteEntitiesEntitytypenameListstring { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntitiesEntitytypenameListstring(); + } + + public static void syncBatchDeleteEntitiesEntitytypenameListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + entityTypesClient.batchDeleteEntitiesAsync(parent, entityValues).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_entitytypenameliststring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstringString.java new file mode 100644 index 000000000000..1c242252fb38 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesEntitytypenameListstringString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_entitytypenameliststringstring_sync] +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteEntitiesEntitytypenameListstringString { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntitiesEntitytypenameListstringString(); + } + + public static void syncBatchDeleteEntitiesEntitytypenameListstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + entityTypesClient.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_entitytypenameliststringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstring.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstring.java new file mode 100644 index 000000000000..e1db536aa8a1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstring.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_stringliststring_sync] +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteEntitiesStringListstring { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntitiesStringListstring(); + } + + public static void syncBatchDeleteEntitiesStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + List entityValues = new ArrayList<>(); + entityTypesClient.batchDeleteEntitiesAsync(parent, entityValues).get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_stringliststring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstringString.java new file mode 100644 index 000000000000..780ddd9db303 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentities/SyncBatchDeleteEntitiesStringListstringString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_stringliststringstring_sync] +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteEntitiesStringListstringString { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntitiesStringListstringString(); + } + + public static void syncBatchDeleteEntitiesStringListstringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + entityTypesClient.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentities_stringliststringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypes.java new file mode 100644 index 000000000000..aa1998d25043 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypes.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentitytypes_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchDeleteEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncBatchDeleteEntityTypes { + + public static void main(String[] args) throws Exception { + asyncBatchDeleteEntityTypes(); + } + + public static void asyncBatchDeleteEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchDeleteEntityTypesRequest request = + BatchDeleteEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .addAllEntityTypeNames(new ArrayList()) + .build(); + ApiFuture future = + entityTypesClient.batchDeleteEntityTypesCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentitytypes_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypesLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypesLRO.java new file mode 100644 index 000000000000..c247d0d60eb3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/AsyncBatchDeleteEntityTypesLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentitytypes_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchDeleteEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.util.ArrayList; + +public class AsyncBatchDeleteEntityTypesLRO { + + public static void main(String[] args) throws Exception { + asyncBatchDeleteEntityTypesLRO(); + } + + public static void asyncBatchDeleteEntityTypesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchDeleteEntityTypesRequest request = + BatchDeleteEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .addAllEntityTypeNames(new ArrayList()) + .build(); + OperationFuture future = + entityTypesClient.batchDeleteEntityTypesOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentitytypes_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypes.java new file mode 100644 index 000000000000..a77e19843984 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypes.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentitytypes_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchDeleteEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; + +public class SyncBatchDeleteEntityTypes { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntityTypes(); + } + + public static void syncBatchDeleteEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchDeleteEntityTypesRequest request = + BatchDeleteEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .addAllEntityTypeNames(new ArrayList()) + .build(); + entityTypesClient.batchDeleteEntityTypesAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentitytypes_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesAgentnameListstring.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesAgentnameListstring.java new file mode 100644 index 000000000000..0ed01f9f4e91 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesAgentnameListstring.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentitytypes_agentnameliststring_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteEntityTypesAgentnameListstring { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntityTypesAgentnameListstring(); + } + + public static void syncBatchDeleteEntityTypesAgentnameListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + List entityTypeNames = new ArrayList<>(); + entityTypesClient.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentitytypes_agentnameliststring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesStringListstring.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesStringListstring.java new file mode 100644 index 000000000000..bbf4c607d4fc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchdeleteentitytypes/SyncBatchDeleteEntityTypesStringListstring.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentitytypes_stringliststring_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteEntityTypesStringListstring { + + public static void main(String[] args) throws Exception { + syncBatchDeleteEntityTypesStringListstring(); + } + + public static void syncBatchDeleteEntityTypesStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + List entityTypeNames = new ArrayList<>(); + entityTypesClient.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchdeleteentitytypes_stringliststring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntities.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntities.java new file mode 100644 index 000000000000..1903b38b5d69 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntities.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateEntitiesRequest; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; +import java.util.ArrayList; + +public class AsyncBatchUpdateEntities { + + public static void main(String[] args) throws Exception { + asyncBatchUpdateEntities(); + } + + public static void asyncBatchUpdateEntities() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchUpdateEntitiesRequest request = + BatchUpdateEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntities(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + entityTypesClient.batchUpdateEntitiesCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntitiesLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntitiesLRO.java new file mode 100644 index 000000000000..5541b9a60ae3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/AsyncBatchUpdateEntitiesLRO.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateEntitiesRequest; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Struct; +import java.util.ArrayList; + +public class AsyncBatchUpdateEntitiesLRO { + + public static void main(String[] args) throws Exception { + asyncBatchUpdateEntitiesLRO(); + } + + public static void asyncBatchUpdateEntitiesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchUpdateEntitiesRequest request = + BatchUpdateEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntities(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + entityTypesClient.batchUpdateEntitiesOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntities.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntities.java new file mode 100644 index 000000000000..cd4d707e12e7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntities.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_sync] +import com.google.cloud.dialogflow.v2beta1.BatchUpdateEntitiesRequest; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.protobuf.FieldMask; +import java.util.ArrayList; + +public class SyncBatchUpdateEntities { + + public static void main(String[] args) throws Exception { + syncBatchUpdateEntities(); + } + + public static void syncBatchUpdateEntities() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchUpdateEntitiesRequest request = + BatchUpdateEntitiesRequest.newBuilder() + .setParent( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .addAllEntities(new ArrayList()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + entityTypesClient.batchUpdateEntitiesAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentity.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentity.java new file mode 100644 index 000000000000..3a07010cefca --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentity.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_entitytypenamelistentitytypeentity_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchUpdateEntitiesEntitytypenameListentitytypeentity { + + public static void main(String[] args) throws Exception { + syncBatchUpdateEntitiesEntitytypenameListentitytypeentity(); + } + + public static void syncBatchUpdateEntitiesEntitytypenameListentitytypeentity() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + entityTypesClient.batchUpdateEntitiesAsync(parent, entities).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_entitytypenamelistentitytypeentity_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentityString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentityString.java new file mode 100644 index 000000000000..8b4fe65bc21f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesEntitytypenameListentitytypeentityString.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_entitytypenamelistentitytypeentitystring_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchUpdateEntitiesEntitytypenameListentitytypeentityString { + + public static void main(String[] args) throws Exception { + syncBatchUpdateEntitiesEntitytypenameListentitytypeentityString(); + } + + public static void syncBatchUpdateEntitiesEntitytypenameListentitytypeentityString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName parent = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + entityTypesClient.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_entitytypenamelistentitytypeentitystring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentity.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentity.java new file mode 100644 index 000000000000..ebabbff07bda --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentity.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_stringlistentitytypeentity_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchUpdateEntitiesStringListentitytypeentity { + + public static void main(String[] args) throws Exception { + syncBatchUpdateEntitiesStringListentitytypeentity(); + } + + public static void syncBatchUpdateEntitiesStringListentitytypeentity() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + List entities = new ArrayList<>(); + entityTypesClient.batchUpdateEntitiesAsync(parent, entities).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_stringlistentitytypeentity_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentityString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentityString.java new file mode 100644 index 000000000000..ebadd1c6deb6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentities/SyncBatchUpdateEntitiesStringListentitytypeentityString.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_stringlistentitytypeentitystring_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchUpdateEntitiesStringListentitytypeentityString { + + public static void main(String[] args) throws Exception { + syncBatchUpdateEntitiesStringListentitytypeentityString(); + } + + public static void syncBatchUpdateEntitiesStringListentitytypeentityString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + List entities = new ArrayList<>(); + String languageCode = "languageCode-2092349083"; + entityTypesClient.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_batchupdateentities_stringlistentitytypeentitystring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypes.java new file mode 100644 index 000000000000..3a1fb742a297 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypes.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchupdateentitytypes_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncBatchUpdateEntityTypes { + + public static void main(String[] args) throws Exception { + asyncBatchUpdateEntityTypes(); + } + + public static void asyncBatchUpdateEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchUpdateEntityTypesRequest request = + BatchUpdateEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + entityTypesClient.batchUpdateEntityTypesCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchupdateentitytypes_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypesLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypesLRO.java new file mode 100644 index 000000000000..4af338972fc1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentitytypes/AsyncBatchUpdateEntityTypesLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchupdateentitytypes_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateEntityTypesResponse; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Struct; + +public class AsyncBatchUpdateEntityTypesLRO { + + public static void main(String[] args) throws Exception { + asyncBatchUpdateEntityTypesLRO(); + } + + public static void asyncBatchUpdateEntityTypesLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchUpdateEntityTypesRequest request = + BatchUpdateEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + entityTypesClient.batchUpdateEntityTypesOperationCallable().futureCall(request); + // Do something. + BatchUpdateEntityTypesResponse response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchupdateentitytypes_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentitytypes/SyncBatchUpdateEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentitytypes/SyncBatchUpdateEntityTypes.java new file mode 100644 index 000000000000..d7084537b3f2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/batchupdateentitytypes/SyncBatchUpdateEntityTypes.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_batchupdateentitytypes_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateEntityTypesResponse; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.protobuf.FieldMask; + +public class SyncBatchUpdateEntityTypes { + + public static void main(String[] args) throws Exception { + syncBatchUpdateEntityTypes(); + } + + public static void syncBatchUpdateEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + BatchUpdateEntityTypesRequest request = + BatchUpdateEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + BatchUpdateEntityTypesResponse response = + entityTypesClient.batchUpdateEntityTypesAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_batchupdateentitytypes_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..f2f5409a1c19 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.EntityTypesSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EntityTypesSettings entityTypesSettings = + EntityTypesSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + EntityTypesClient entityTypesClient = EntityTypesClient.create(entityTypesSettings); + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..8322acae6973 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.EntityTypesSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EntityTypesSettings entityTypesSettings = + EntityTypesSettings.newBuilder() + .setTransportChannelProvider( + EntityTypesSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + EntityTypesClient entityTypesClient = EntityTypesClient.create(entityTypesSettings); + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..080cdf8464e2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.EntityTypesSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EntityTypesSettings entityTypesSettings = + EntityTypesSettings.newBuilder().setEndpoint(myEndpoint).build(); + EntityTypesClient entityTypesClient = EntityTypesClient.create(entityTypesSettings); + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/AsyncCreateEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/AsyncCreateEntityType.java new file mode 100644 index 000000000000..74ac896fe1ce --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/AsyncCreateEntityType.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_createentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.CreateEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class AsyncCreateEntityType { + + public static void main(String[] args) throws Exception { + asyncCreateEntityType(); + } + + public static void asyncCreateEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + CreateEntityTypeRequest request = + CreateEntityTypeRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setEntityType(EntityType.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .build(); + ApiFuture future = + entityTypesClient.createEntityTypeCallable().futureCall(request); + // Do something. + EntityType response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_createentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityType.java new file mode 100644 index 000000000000..0c774a0827a1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityType.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_createentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.CreateEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncCreateEntityType { + + public static void main(String[] args) throws Exception { + syncCreateEntityType(); + } + + public static void syncCreateEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + CreateEntityTypeRequest request = + CreateEntityTypeRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setEntityType(EntityType.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .build(); + EntityType response = entityTypesClient.createEntityType(request); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_createentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytype.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytype.java new file mode 100644 index 000000000000..7eac54c8a605 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytype.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_createentitytype_agentnameentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncCreateEntityTypeAgentnameEntitytype { + + public static void main(String[] args) throws Exception { + syncCreateEntityTypeAgentnameEntitytype(); + } + + public static void syncCreateEntityTypeAgentnameEntitytype() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + EntityType response = entityTypesClient.createEntityType(parent, entityType); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_createentitytype_agentnameentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytypeString.java new file mode 100644 index 000000000000..b72c61f1bdc9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeAgentnameEntitytypeString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_createentitytype_agentnameentitytypestring_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncCreateEntityTypeAgentnameEntitytypeString { + + public static void main(String[] args) throws Exception { + syncCreateEntityTypeAgentnameEntitytypeString(); + } + + public static void syncCreateEntityTypeAgentnameEntitytypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + EntityType response = entityTypesClient.createEntityType(parent, entityType, languageCode); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_createentitytype_agentnameentitytypestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytype.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytype.java new file mode 100644 index 000000000000..b4df1fc125ea --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytype.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_createentitytype_stringentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncCreateEntityTypeStringEntitytype { + + public static void main(String[] args) throws Exception { + syncCreateEntityTypeStringEntitytype(); + } + + public static void syncCreateEntityTypeStringEntitytype() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + EntityType entityType = EntityType.newBuilder().build(); + EntityType response = entityTypesClient.createEntityType(parent, entityType); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_createentitytype_stringentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytypeString.java new file mode 100644 index 000000000000..fff58ee7e2f7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/createentitytype/SyncCreateEntityTypeStringEntitytypeString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_createentitytype_stringentitytypestring_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncCreateEntityTypeStringEntitytypeString { + + public static void main(String[] args) throws Exception { + syncCreateEntityTypeStringEntitytypeString(); + } + + public static void syncCreateEntityTypeStringEntitytypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + EntityType response = entityTypesClient.createEntityType(parent, entityType, languageCode); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_createentitytype_stringentitytypestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/AsyncDeleteEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/AsyncDeleteEntityType.java new file mode 100644 index 000000000000..fc49e73a8322 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/AsyncDeleteEntityType.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_deleteentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.DeleteEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteEntityType { + + public static void main(String[] args) throws Exception { + asyncDeleteEntityType(); + } + + public static void asyncDeleteEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + DeleteEntityTypeRequest request = + DeleteEntityTypeRequest.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .build(); + ApiFuture future = entityTypesClient.deleteEntityTypeCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_deleteentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/SyncDeleteEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/SyncDeleteEntityType.java new file mode 100644 index 000000000000..c2fce3d5ddcb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/SyncDeleteEntityType.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_deleteentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.DeleteEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncDeleteEntityType { + + public static void main(String[] args) throws Exception { + syncDeleteEntityType(); + } + + public static void syncDeleteEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + DeleteEntityTypeRequest request = + DeleteEntityTypeRequest.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .build(); + entityTypesClient.deleteEntityType(request); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_deleteentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeEntitytypename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeEntitytypename.java new file mode 100644 index 000000000000..7bb3e86ce499 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeEntitytypename.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_deleteentitytype_entitytypename_sync] +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncDeleteEntityTypeEntitytypename { + + public static void main(String[] args) throws Exception { + syncDeleteEntityTypeEntitytypename(); + } + + public static void syncDeleteEntityTypeEntitytypename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + entityTypesClient.deleteEntityType(name); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_deleteentitytype_entitytypename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeString.java new file mode 100644 index 000000000000..a7a8d44efa4b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/deleteentitytype/SyncDeleteEntityTypeString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_deleteentitytype_string_sync] +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncDeleteEntityTypeString { + + public static void main(String[] args) throws Exception { + syncDeleteEntityTypeString(); + } + + public static void syncDeleteEntityTypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + entityTypesClient.deleteEntityType(name); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_deleteentitytype_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/AsyncGetEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/AsyncGetEntityType.java new file mode 100644 index 000000000000..9885b5a97d6c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/AsyncGetEntityType.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_getentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.GetEntityTypeRequest; + +public class AsyncGetEntityType { + + public static void main(String[] args) throws Exception { + asyncGetEntityType(); + } + + public static void asyncGetEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + GetEntityTypeRequest request = + GetEntityTypeRequest.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setLanguageCode("languageCode-2092349083") + .build(); + ApiFuture future = entityTypesClient.getEntityTypeCallable().futureCall(request); + // Do something. + EntityType response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_getentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityType.java new file mode 100644 index 000000000000..29fc341dd6ac --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityType.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_getentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.GetEntityTypeRequest; + +public class SyncGetEntityType { + + public static void main(String[] args) throws Exception { + syncGetEntityType(); + } + + public static void syncGetEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + GetEntityTypeRequest request = + GetEntityTypeRequest.newBuilder() + .setName( + EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString()) + .setLanguageCode("languageCode-2092349083") + .build(); + EntityType response = entityTypesClient.getEntityType(request); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_getentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypename.java new file mode 100644 index 000000000000..3780fe9553b2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypename.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_getentitytype_entitytypename_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncGetEntityTypeEntitytypename { + + public static void main(String[] args) throws Exception { + syncGetEntityTypeEntitytypename(); + } + + public static void syncGetEntityTypeEntitytypename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + EntityType response = entityTypesClient.getEntityType(name); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_getentitytype_entitytypename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypenameString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypenameString.java new file mode 100644 index 000000000000..b656f861e97d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeEntitytypenameString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_getentitytype_entitytypenamestring_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncGetEntityTypeEntitytypenameString { + + public static void main(String[] args) throws Exception { + syncGetEntityTypeEntitytypenameString(); + } + + public static void syncGetEntityTypeEntitytypenameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityTypeName name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]"); + String languageCode = "languageCode-2092349083"; + EntityType response = entityTypesClient.getEntityType(name, languageCode); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_getentitytype_entitytypenamestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeString.java new file mode 100644 index 000000000000..5431d88d38e8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_getentitytype_string_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncGetEntityTypeString { + + public static void main(String[] args) throws Exception { + syncGetEntityTypeString(); + } + + public static void syncGetEntityTypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + EntityType response = entityTypesClient.getEntityType(name); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_getentitytype_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeStringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeStringString.java new file mode 100644 index 000000000000..fe633e0049f4 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/getentitytype/SyncGetEntityTypeStringString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_getentitytype_stringstring_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypeName; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncGetEntityTypeStringString { + + public static void main(String[] args) throws Exception { + syncGetEntityTypeStringString(); + } + + public static void syncGetEntityTypeStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String name = EntityTypeName.ofProjectEntityTypeName("[PROJECT]", "[ENTITY_TYPE]").toString(); + String languageCode = "languageCode-2092349083"; + EntityType response = entityTypesClient.getEntityType(name, languageCode); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_getentitytype_stringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/AsyncListEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/AsyncListEntityTypes.java new file mode 100644 index 000000000000..e7308bb604ff --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/AsyncListEntityTypes.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.ListEntityTypesRequest; + +public class AsyncListEntityTypes { + + public static void main(String[] args) throws Exception { + asyncListEntityTypes(); + } + + public static void asyncListEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + ListEntityTypesRequest request = + ListEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + entityTypesClient.listEntityTypesPagedCallable().futureCall(request); + // Do something. + for (EntityType element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/AsyncListEntityTypesPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/AsyncListEntityTypesPaged.java new file mode 100644 index 000000000000..92c74e7489a6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/AsyncListEntityTypesPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_paged_async] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.ListEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.ListEntityTypesResponse; +import com.google.common.base.Strings; + +public class AsyncListEntityTypesPaged { + + public static void main(String[] args) throws Exception { + asyncListEntityTypesPaged(); + } + + public static void asyncListEntityTypesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + ListEntityTypesRequest request = + ListEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .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; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypes.java new file mode 100644 index 000000000000..618508efb5f5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypes.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.ListEntityTypesRequest; + +public class SyncListEntityTypes { + + public static void main(String[] args) throws Exception { + syncListEntityTypes(); + } + + public static void syncListEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + ListEntityTypesRequest request = + ListEntityTypesRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (EntityType element : entityTypesClient.listEntityTypes(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesAgentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesAgentname.java new file mode 100644 index 000000000000..91082857565a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesAgentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_agentname_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncListEntityTypesAgentname { + + public static void main(String[] args) throws Exception { + syncListEntityTypesAgentname(); + } + + public static void syncListEntityTypesAgentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + for (EntityType element : entityTypesClient.listEntityTypes(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_agentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesAgentnameString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesAgentnameString.java new file mode 100644 index 000000000000..ed30e068c037 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesAgentnameString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_agentnamestring_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncListEntityTypesAgentnameString { + + public static void main(String[] args) throws Exception { + syncListEntityTypesAgentnameString(); + } + + public static void syncListEntityTypesAgentnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String languageCode = "languageCode-2092349083"; + for (EntityType element : + entityTypesClient.listEntityTypes(parent, languageCode).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_agentnamestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesString.java new file mode 100644 index 000000000000..cf089574bbe1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_string_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncListEntityTypesString { + + public static void main(String[] args) throws Exception { + syncListEntityTypesString(); + } + + public static void syncListEntityTypesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + for (EntityType element : entityTypesClient.listEntityTypes(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesStringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesStringString.java new file mode 100644 index 000000000000..3618b4943fbd --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/listentitytypes/SyncListEntityTypesStringString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_stringstring_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncListEntityTypesStringString { + + public static void main(String[] args) throws Exception { + syncListEntityTypesStringString(); + } + + public static void syncListEntityTypesStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + String languageCode = "languageCode-2092349083"; + for (EntityType element : + entityTypesClient.listEntityTypes(parent, languageCode).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_listentitytypes_stringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/AsyncUpdateEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/AsyncUpdateEntityType.java new file mode 100644 index 000000000000..fbfa060b4258 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/AsyncUpdateEntityType.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_updateentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.UpdateEntityTypeRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateEntityType { + + public static void main(String[] args) throws Exception { + asyncUpdateEntityType(); + } + + public static void asyncUpdateEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + UpdateEntityTypeRequest request = + UpdateEntityTypeRequest.newBuilder() + .setEntityType(EntityType.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + entityTypesClient.updateEntityTypeCallable().futureCall(request); + // Do something. + EntityType response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_updateentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityType.java new file mode 100644 index 000000000000..6178d113a127 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityType.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_updateentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.UpdateEntityTypeRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateEntityType { + + public static void main(String[] args) throws Exception { + syncUpdateEntityType(); + } + + public static void syncUpdateEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + UpdateEntityTypeRequest request = + UpdateEntityTypeRequest.newBuilder() + .setEntityType(EntityType.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + EntityType response = entityTypesClient.updateEntityType(request); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_updateentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytype.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytype.java new file mode 100644 index 000000000000..f9fca8ea83f7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytype.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_updateentitytype_entitytype_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncUpdateEntityTypeEntitytype { + + public static void main(String[] args) throws Exception { + syncUpdateEntityTypeEntitytype(); + } + + public static void syncUpdateEntityTypeEntitytype() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityType entityType = EntityType.newBuilder().build(); + EntityType response = entityTypesClient.updateEntityType(entityType); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_updateentitytype_entitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytypeString.java new file mode 100644 index 000000000000..48c4d5b34e1c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytypeString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypesclient_updateentitytype_entitytypestring_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; + +public class SyncUpdateEntityTypeEntitytypeString { + + public static void main(String[] args) throws Exception { + syncUpdateEntityTypeEntitytypeString(); + } + + public static void syncUpdateEntityTypeEntitytypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + EntityType response = entityTypesClient.updateEntityType(entityType, languageCode); + } + } +} +// [END dialogflow_v2beta1_generated_entitytypesclient_updateentitytype_entitytypestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytypeStringFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytypeStringFieldmask.java new file mode 100644 index 000000000000..9d75d743e35a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypesclient/updateentitytype/SyncUpdateEntityTypeEntitytypeStringFieldmask.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_entitytypesclient_updateentitytype_entitytypestringfieldmask_sync] +import com.google.cloud.dialogflow.v2beta1.EntityType; +import com.google.cloud.dialogflow.v2beta1.EntityTypesClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateEntityTypeEntitytypeStringFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateEntityTypeEntitytypeStringFieldmask(); + } + + public static void syncUpdateEntityTypeEntitytypeStringFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) { + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + FieldMask updateMask = FieldMask.newBuilder().build(); + EntityType response = + entityTypesClient.updateEntityType(entityType, languageCode, updateMask); + } + } +} +// [END +// dialogflow_v2beta1_generated_entitytypesclient_updateentitytype_entitytypestringfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypessettings/getentitytype/SyncGetEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypessettings/getentitytype/SyncGetEntityType.java new file mode 100644 index 000000000000..5f1d877a3c81 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/entitytypessettings/getentitytype/SyncGetEntityType.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_entitytypessettings_getentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.EntityTypesSettings; +import java.time.Duration; + +public class SyncGetEntityType { + + public static void main(String[] args) throws Exception { + syncGetEntityType(); + } + + public static void syncGetEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EntityTypesSettings.Builder entityTypesSettingsBuilder = EntityTypesSettings.newBuilder(); + entityTypesSettingsBuilder + .getEntityTypeSettings() + .setRetrySettings( + entityTypesSettingsBuilder + .getEntityTypeSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + EntityTypesSettings entityTypesSettings = entityTypesSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_entitytypessettings_getentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..9f755c7aa981 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsSettings environmentsSettings = + EnvironmentsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..26146f837732 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsSettings environmentsSettings = + EnvironmentsSettings.newBuilder() + .setTransportChannelProvider( + EnvironmentsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..4f55cc030ce9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsSettings environmentsSettings = + EnvironmentsSettings.newBuilder().setEndpoint(myEndpoint).build(); + EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/createenvironment/AsyncCreateEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/createenvironment/AsyncCreateEnvironment.java new file mode 100644 index 000000000000..33f05603bc31 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/createenvironment/AsyncCreateEnvironment.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_createenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.CreateEnvironmentRequest; +import com.google.cloud.dialogflow.v2beta1.Environment; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; + +public class AsyncCreateEnvironment { + + public static void main(String[] args) throws Exception { + asyncCreateEnvironment(); + } + + public static void asyncCreateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setEnvironment(Environment.newBuilder().build()) + .setEnvironmentId("environmentId-950205810") + .build(); + ApiFuture future = + environmentsClient.createEnvironmentCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_createenvironment_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/createenvironment/SyncCreateEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/createenvironment/SyncCreateEnvironment.java new file mode 100644 index 000000000000..21c5652322e0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/createenvironment/SyncCreateEnvironment.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_createenvironment_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.CreateEnvironmentRequest; +import com.google.cloud.dialogflow.v2beta1.Environment; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; + +public class SyncCreateEnvironment { + + public static void main(String[] args) throws Exception { + syncCreateEnvironment(); + } + + public static void syncCreateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setEnvironment(Environment.newBuilder().build()) + .setEnvironmentId("environmentId-950205810") + .build(); + Environment response = environmentsClient.createEnvironment(request); + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_createenvironment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.java new file mode 100644 index 000000000000..8507855f3ad1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_deleteenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.DeleteEnvironmentRequest; +import com.google.cloud.dialogflow.v2beta1.EnvironmentName; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteEnvironment { + + public static void main(String[] args) throws Exception { + asyncDeleteEnvironment(); + } + + public static void asyncDeleteEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + ApiFuture future = environmentsClient.deleteEnvironmentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_deleteenvironment_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/deleteenvironment/SyncDeleteEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/deleteenvironment/SyncDeleteEnvironment.java new file mode 100644 index 000000000000..ddcee414a2c5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/deleteenvironment/SyncDeleteEnvironment.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_deleteenvironment_sync] +import com.google.cloud.dialogflow.v2beta1.DeleteEnvironmentRequest; +import com.google.cloud.dialogflow.v2beta1.EnvironmentName; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; + +public class SyncDeleteEnvironment { + + public static void main(String[] args) throws Exception { + syncDeleteEnvironment(); + } + + public static void syncDeleteEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + environmentsClient.deleteEnvironment(request); + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_deleteenvironment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironment/AsyncGetEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironment/AsyncGetEnvironment.java new file mode 100644 index 000000000000..bee90c7211a5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironment/AsyncGetEnvironment.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_getenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Environment; +import com.google.cloud.dialogflow.v2beta1.EnvironmentName; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.cloud.dialogflow.v2beta1.GetEnvironmentRequest; + +public class AsyncGetEnvironment { + + public static void main(String[] args) throws Exception { + asyncGetEnvironment(); + } + + public static void asyncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + ApiFuture future = + environmentsClient.getEnvironmentCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_getenvironment_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironment/SyncGetEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironment/SyncGetEnvironment.java new file mode 100644 index 000000000000..136d93817b24 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironment/SyncGetEnvironment.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_getenvironment_sync] +import com.google.cloud.dialogflow.v2beta1.Environment; +import com.google.cloud.dialogflow.v2beta1.EnvironmentName; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.cloud.dialogflow.v2beta1.GetEnvironmentRequest; + +public class SyncGetEnvironment { + + public static void main(String[] args) throws Exception { + syncGetEnvironment(); + } + + public static void syncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder() + .setName( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .build(); + Environment response = environmentsClient.getEnvironment(request); + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_getenvironment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistory.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistory.java new file mode 100644 index 000000000000..4861589ec788 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistory.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_getenvironmenthistory_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.EnvironmentHistory; +import com.google.cloud.dialogflow.v2beta1.EnvironmentName; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.cloud.dialogflow.v2beta1.GetEnvironmentHistoryRequest; + +public class AsyncGetEnvironmentHistory { + + public static void main(String[] args) throws Exception { + asyncGetEnvironmentHistory(); + } + + public static void asyncGetEnvironmentHistory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentHistoryRequest request = + GetEnvironmentHistoryRequest.newBuilder() + .setParent( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + environmentsClient.getEnvironmentHistoryPagedCallable().futureCall(request); + // Do something. + for (EnvironmentHistory.Entry element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_getenvironmenthistory_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistoryPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistoryPaged.java new file mode 100644 index 000000000000..e5983717bde6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironmenthistory/AsyncGetEnvironmentHistoryPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_getenvironmenthistory_paged_async] +import com.google.cloud.dialogflow.v2beta1.EnvironmentHistory; +import com.google.cloud.dialogflow.v2beta1.EnvironmentName; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.cloud.dialogflow.v2beta1.GetEnvironmentHistoryRequest; +import com.google.common.base.Strings; + +public class AsyncGetEnvironmentHistoryPaged { + + public static void main(String[] args) throws Exception { + asyncGetEnvironmentHistoryPaged(); + } + + public static void asyncGetEnvironmentHistoryPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentHistoryRequest request = + GetEnvironmentHistoryRequest.newBuilder() + .setParent( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + EnvironmentHistory response = + environmentsClient.getEnvironmentHistoryCallable().call(request); + for (EnvironmentHistory.Entry element : response.getEntriesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_getenvironmenthistory_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironmenthistory/SyncGetEnvironmentHistory.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironmenthistory/SyncGetEnvironmentHistory.java new file mode 100644 index 000000000000..f30691cad008 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/getenvironmenthistory/SyncGetEnvironmentHistory.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_getenvironmenthistory_sync] +import com.google.cloud.dialogflow.v2beta1.EnvironmentHistory; +import com.google.cloud.dialogflow.v2beta1.EnvironmentName; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.cloud.dialogflow.v2beta1.GetEnvironmentHistoryRequest; + +public class SyncGetEnvironmentHistory { + + public static void main(String[] args) throws Exception { + syncGetEnvironmentHistory(); + } + + public static void syncGetEnvironmentHistory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentHistoryRequest request = + GetEnvironmentHistoryRequest.newBuilder() + .setParent( + EnvironmentName.ofProjectEnvironmentName("[PROJECT]", "[ENVIRONMENT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (EnvironmentHistory.Entry element : + environmentsClient.getEnvironmentHistory(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_getenvironmenthistory_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/AsyncListEnvironments.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/AsyncListEnvironments.java new file mode 100644 index 000000000000..234ee5b50526 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/AsyncListEnvironments.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_listenvironments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Environment; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.cloud.dialogflow.v2beta1.ListEnvironmentsRequest; + +public class AsyncListEnvironments { + + public static void main(String[] args) throws Exception { + asyncListEnvironments(); + } + + public static void asyncListEnvironments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + ListEnvironmentsRequest request = + ListEnvironmentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + environmentsClient.listEnvironmentsPagedCallable().futureCall(request); + // Do something. + for (Environment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_listenvironments_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.java new file mode 100644 index 000000000000..fc138b3074a4 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_listenvironments_paged_async] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Environment; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.cloud.dialogflow.v2beta1.ListEnvironmentsRequest; +import com.google.cloud.dialogflow.v2beta1.ListEnvironmentsResponse; +import com.google.common.base.Strings; + +public class AsyncListEnvironmentsPaged { + + public static void main(String[] args) throws Exception { + asyncListEnvironmentsPaged(); + } + + public static void asyncListEnvironmentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + ListEnvironmentsRequest request = + ListEnvironmentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListEnvironmentsResponse response = + environmentsClient.listEnvironmentsCallable().call(request); + for (Environment element : response.getEnvironmentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_listenvironments_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/SyncListEnvironments.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/SyncListEnvironments.java new file mode 100644 index 000000000000..90332bcd5c13 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/SyncListEnvironments.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_listenvironments_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Environment; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.cloud.dialogflow.v2beta1.ListEnvironmentsRequest; + +public class SyncListEnvironments { + + public static void main(String[] args) throws Exception { + syncListEnvironments(); + } + + public static void syncListEnvironments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + ListEnvironmentsRequest request = + ListEnvironmentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Environment element : environmentsClient.listEnvironments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_listenvironments_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/SyncListEnvironmentsAgentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/SyncListEnvironmentsAgentname.java new file mode 100644 index 000000000000..7619d3bb39da --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/SyncListEnvironmentsAgentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_listenvironments_agentname_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Environment; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; + +public class SyncListEnvironmentsAgentname { + + public static void main(String[] args) throws Exception { + syncListEnvironmentsAgentname(); + } + + public static void syncListEnvironmentsAgentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + for (Environment element : environmentsClient.listEnvironments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_listenvironments_agentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/SyncListEnvironmentsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/SyncListEnvironmentsString.java new file mode 100644 index 000000000000..bf4441316f3e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/listenvironments/SyncListEnvironmentsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_listenvironments_string_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Environment; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; + +public class SyncListEnvironmentsString { + + public static void main(String[] args) throws Exception { + syncListEnvironmentsString(); + } + + public static void syncListEnvironmentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + for (Environment element : environmentsClient.listEnvironments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_listenvironments_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/updateenvironment/AsyncUpdateEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/updateenvironment/AsyncUpdateEnvironment.java new file mode 100644 index 000000000000..122d2b024c1a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/updateenvironment/AsyncUpdateEnvironment.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_updateenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Environment; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateEnvironmentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateEnvironment { + + public static void main(String[] args) throws Exception { + asyncUpdateEnvironment(); + } + + public static void asyncUpdateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setEnvironment(Environment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowLoadToDraftAndDiscardChanges(true) + .build(); + ApiFuture future = + environmentsClient.updateEnvironmentCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_updateenvironment_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/updateenvironment/SyncUpdateEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/updateenvironment/SyncUpdateEnvironment.java new file mode 100644 index 000000000000..cc82df00e32b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentsclient/updateenvironment/SyncUpdateEnvironment.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentsclient_updateenvironment_sync] +import com.google.cloud.dialogflow.v2beta1.Environment; +import com.google.cloud.dialogflow.v2beta1.EnvironmentsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateEnvironmentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateEnvironment { + + public static void main(String[] args) throws Exception { + syncUpdateEnvironment(); + } + + public static void syncUpdateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setEnvironment(Environment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setAllowLoadToDraftAndDiscardChanges(true) + .build(); + Environment response = environmentsClient.updateEnvironment(request); + } + } +} +// [END dialogflow_v2beta1_generated_environmentsclient_updateenvironment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentssettings/getenvironment/SyncGetEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentssettings/getenvironment/SyncGetEnvironment.java new file mode 100644 index 000000000000..6321fdf93523 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/environmentssettings/getenvironment/SyncGetEnvironment.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_environmentssettings_getenvironment_sync] +import com.google.cloud.dialogflow.v2beta1.EnvironmentsSettings; +import java.time.Duration; + +public class SyncGetEnvironment { + + public static void main(String[] args) throws Exception { + syncGetEnvironment(); + } + + public static void syncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsSettings.Builder environmentsSettingsBuilder = EnvironmentsSettings.newBuilder(); + environmentsSettingsBuilder + .getEnvironmentSettings() + .setRetrySettings( + environmentsSettingsBuilder + .getEnvironmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + EnvironmentsSettings environmentsSettings = environmentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_environmentssettings_getenvironment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..f94b02ce022a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_fulfillmentsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.FulfillmentsClient; +import com.google.cloud.dialogflow.v2beta1.FulfillmentsSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + FulfillmentsSettings fulfillmentsSettings = + FulfillmentsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create(fulfillmentsSettings); + } +} +// [END dialogflow_v2beta1_generated_fulfillmentsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..c4ed7f63ae07 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_fulfillmentsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.FulfillmentsClient; +import com.google.cloud.dialogflow.v2beta1.FulfillmentsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + FulfillmentsSettings fulfillmentsSettings = + FulfillmentsSettings.newBuilder() + .setTransportChannelProvider( + FulfillmentsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create(fulfillmentsSettings); + } +} +// [END dialogflow_v2beta1_generated_fulfillmentsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..4f112d0c75b8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_fulfillmentsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.FulfillmentsClient; +import com.google.cloud.dialogflow.v2beta1.FulfillmentsSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + FulfillmentsSettings fulfillmentsSettings = + FulfillmentsSettings.newBuilder().setEndpoint(myEndpoint).build(); + FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create(fulfillmentsSettings); + } +} +// [END dialogflow_v2beta1_generated_fulfillmentsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/AsyncGetFulfillment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/AsyncGetFulfillment.java new file mode 100644 index 000000000000..1121799384ad --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/AsyncGetFulfillment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_fulfillmentsclient_getfulfillment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Fulfillment; +import com.google.cloud.dialogflow.v2beta1.FulfillmentName; +import com.google.cloud.dialogflow.v2beta1.FulfillmentsClient; +import com.google.cloud.dialogflow.v2beta1.GetFulfillmentRequest; + +public class AsyncGetFulfillment { + + public static void main(String[] args) throws Exception { + asyncGetFulfillment(); + } + + public static void asyncGetFulfillment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + GetFulfillmentRequest request = + GetFulfillmentRequest.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .build(); + ApiFuture future = + fulfillmentsClient.getFulfillmentCallable().futureCall(request); + // Do something. + Fulfillment response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_fulfillmentsclient_getfulfillment_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/SyncGetFulfillment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/SyncGetFulfillment.java new file mode 100644 index 000000000000..e56e3d53c869 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/SyncGetFulfillment.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_fulfillmentsclient_getfulfillment_sync] +import com.google.cloud.dialogflow.v2beta1.Fulfillment; +import com.google.cloud.dialogflow.v2beta1.FulfillmentName; +import com.google.cloud.dialogflow.v2beta1.FulfillmentsClient; +import com.google.cloud.dialogflow.v2beta1.GetFulfillmentRequest; + +public class SyncGetFulfillment { + + public static void main(String[] args) throws Exception { + syncGetFulfillment(); + } + + public static void syncGetFulfillment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + GetFulfillmentRequest request = + GetFulfillmentRequest.newBuilder() + .setName(FulfillmentName.ofProjectName("[PROJECT]").toString()) + .build(); + Fulfillment response = fulfillmentsClient.getFulfillment(request); + } + } +} +// [END dialogflow_v2beta1_generated_fulfillmentsclient_getfulfillment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/SyncGetFulfillmentFulfillmentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/SyncGetFulfillmentFulfillmentname.java new file mode 100644 index 000000000000..dd104b201951 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/SyncGetFulfillmentFulfillmentname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_fulfillmentsclient_getfulfillment_fulfillmentname_sync] +import com.google.cloud.dialogflow.v2beta1.Fulfillment; +import com.google.cloud.dialogflow.v2beta1.FulfillmentName; +import com.google.cloud.dialogflow.v2beta1.FulfillmentsClient; + +public class SyncGetFulfillmentFulfillmentname { + + public static void main(String[] args) throws Exception { + syncGetFulfillmentFulfillmentname(); + } + + public static void syncGetFulfillmentFulfillmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + FulfillmentName name = FulfillmentName.ofProjectName("[PROJECT]"); + Fulfillment response = fulfillmentsClient.getFulfillment(name); + } + } +} +// [END dialogflow_v2beta1_generated_fulfillmentsclient_getfulfillment_fulfillmentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/SyncGetFulfillmentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/SyncGetFulfillmentString.java new file mode 100644 index 000000000000..042a00cd0992 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/getfulfillment/SyncGetFulfillmentString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_fulfillmentsclient_getfulfillment_string_sync] +import com.google.cloud.dialogflow.v2beta1.Fulfillment; +import com.google.cloud.dialogflow.v2beta1.FulfillmentName; +import com.google.cloud.dialogflow.v2beta1.FulfillmentsClient; + +public class SyncGetFulfillmentString { + + public static void main(String[] args) throws Exception { + syncGetFulfillmentString(); + } + + public static void syncGetFulfillmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + String name = FulfillmentName.ofProjectName("[PROJECT]").toString(); + Fulfillment response = fulfillmentsClient.getFulfillment(name); + } + } +} +// [END dialogflow_v2beta1_generated_fulfillmentsclient_getfulfillment_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/updatefulfillment/AsyncUpdateFulfillment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/updatefulfillment/AsyncUpdateFulfillment.java new file mode 100644 index 000000000000..8e61254e6ec0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/updatefulfillment/AsyncUpdateFulfillment.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_fulfillmentsclient_updatefulfillment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Fulfillment; +import com.google.cloud.dialogflow.v2beta1.FulfillmentsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateFulfillmentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateFulfillment { + + public static void main(String[] args) throws Exception { + asyncUpdateFulfillment(); + } + + public static void asyncUpdateFulfillment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + UpdateFulfillmentRequest request = + UpdateFulfillmentRequest.newBuilder() + .setFulfillment(Fulfillment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + fulfillmentsClient.updateFulfillmentCallable().futureCall(request); + // Do something. + Fulfillment response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_fulfillmentsclient_updatefulfillment_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillment.java new file mode 100644 index 000000000000..35a2352b2e20 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillment.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_fulfillmentsclient_updatefulfillment_sync] +import com.google.cloud.dialogflow.v2beta1.Fulfillment; +import com.google.cloud.dialogflow.v2beta1.FulfillmentsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateFulfillmentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateFulfillment { + + public static void main(String[] args) throws Exception { + syncUpdateFulfillment(); + } + + public static void syncUpdateFulfillment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + UpdateFulfillmentRequest request = + UpdateFulfillmentRequest.newBuilder() + .setFulfillment(Fulfillment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Fulfillment response = fulfillmentsClient.updateFulfillment(request); + } + } +} +// [END dialogflow_v2beta1_generated_fulfillmentsclient_updatefulfillment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillmentFulfillmentFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillmentFulfillmentFieldmask.java new file mode 100644 index 000000000000..71ddee0616c0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentsclient/updatefulfillment/SyncUpdateFulfillmentFulfillmentFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_fulfillmentsclient_updatefulfillment_fulfillmentfieldmask_sync] +import com.google.cloud.dialogflow.v2beta1.Fulfillment; +import com.google.cloud.dialogflow.v2beta1.FulfillmentsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateFulfillmentFulfillmentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateFulfillmentFulfillmentFieldmask(); + } + + public static void syncUpdateFulfillmentFulfillmentFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FulfillmentsClient fulfillmentsClient = FulfillmentsClient.create()) { + Fulfillment fulfillment = Fulfillment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Fulfillment response = fulfillmentsClient.updateFulfillment(fulfillment, updateMask); + } + } +} +// [END dialogflow_v2beta1_generated_fulfillmentsclient_updatefulfillment_fulfillmentfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentssettings/getfulfillment/SyncGetFulfillment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentssettings/getfulfillment/SyncGetFulfillment.java new file mode 100644 index 000000000000..131c31e8fbdd --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/fulfillmentssettings/getfulfillment/SyncGetFulfillment.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_fulfillmentssettings_getfulfillment_sync] +import com.google.cloud.dialogflow.v2beta1.FulfillmentsSettings; +import java.time.Duration; + +public class SyncGetFulfillment { + + public static void main(String[] args) throws Exception { + syncGetFulfillment(); + } + + public static void syncGetFulfillment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + FulfillmentsSettings.Builder fulfillmentsSettingsBuilder = FulfillmentsSettings.newBuilder(); + fulfillmentsSettingsBuilder + .getFulfillmentSettings() + .setRetrySettings( + fulfillmentsSettingsBuilder + .getFulfillmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + FulfillmentsSettings fulfillmentsSettings = fulfillmentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_fulfillmentssettings_getfulfillment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/AsyncBatchDeleteIntents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/AsyncBatchDeleteIntents.java new file mode 100644 index 000000000000..1559b99ca421 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/AsyncBatchDeleteIntents.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_batchdeleteintents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchDeleteIntentsRequest; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncBatchDeleteIntents { + + public static void main(String[] args) throws Exception { + asyncBatchDeleteIntents(); + } + + public static void asyncBatchDeleteIntents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + BatchDeleteIntentsRequest request = + BatchDeleteIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .addAllIntents(new ArrayList()) + .build(); + ApiFuture future = intentsClient.batchDeleteIntentsCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_batchdeleteintents_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/AsyncBatchDeleteIntentsLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/AsyncBatchDeleteIntentsLRO.java new file mode 100644 index 000000000000..b7c599a0cbfa --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/AsyncBatchDeleteIntentsLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_batchdeleteintents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchDeleteIntentsRequest; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.util.ArrayList; + +public class AsyncBatchDeleteIntentsLRO { + + public static void main(String[] args) throws Exception { + asyncBatchDeleteIntentsLRO(); + } + + public static void asyncBatchDeleteIntentsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + BatchDeleteIntentsRequest request = + BatchDeleteIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .addAllIntents(new ArrayList()) + .build(); + OperationFuture future = + intentsClient.batchDeleteIntentsOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_batchdeleteintents_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/SyncBatchDeleteIntents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/SyncBatchDeleteIntents.java new file mode 100644 index 000000000000..be82f9a22009 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/SyncBatchDeleteIntents.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_batchdeleteintents_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchDeleteIntentsRequest; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import java.util.ArrayList; + +public class SyncBatchDeleteIntents { + + public static void main(String[] args) throws Exception { + syncBatchDeleteIntents(); + } + + public static void syncBatchDeleteIntents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + BatchDeleteIntentsRequest request = + BatchDeleteIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .addAllIntents(new ArrayList()) + .build(); + intentsClient.batchDeleteIntentsAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_batchdeleteintents_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsAgentnameListintent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsAgentnameListintent.java new file mode 100644 index 000000000000..fcdd7f9bf2b1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsAgentnameListintent.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_batchdeleteintents_agentnamelistintent_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteIntentsAgentnameListintent { + + public static void main(String[] args) throws Exception { + syncBatchDeleteIntentsAgentnameListintent(); + } + + public static void syncBatchDeleteIntentsAgentnameListintent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + List intents = new ArrayList<>(); + intentsClient.batchDeleteIntentsAsync(parent, intents).get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_batchdeleteintents_agentnamelistintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsStringListintent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsStringListintent.java new file mode 100644 index 000000000000..7b8c8e3340c8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchdeleteintents/SyncBatchDeleteIntentsStringListintent.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_batchdeleteintents_stringlistintent_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncBatchDeleteIntentsStringListintent { + + public static void main(String[] args) throws Exception { + syncBatchDeleteIntentsStringListintent(); + } + + public static void syncBatchDeleteIntentsStringListintent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + List intents = new ArrayList<>(); + intentsClient.batchDeleteIntentsAsync(parent, intents).get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_batchdeleteintents_stringlistintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/AsyncBatchUpdateIntents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/AsyncBatchUpdateIntents.java new file mode 100644 index 000000000000..14616686bad7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/AsyncBatchUpdateIntents.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_batchupdateintents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsRequest; +import com.google.cloud.dialogflow.v2beta1.IntentView; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncBatchUpdateIntents { + + public static void main(String[] args) throws Exception { + asyncBatchUpdateIntents(); + } + + public static void asyncBatchUpdateIntents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + BatchUpdateIntentsRequest request = + BatchUpdateIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .setIntentView(IntentView.forNumber(0)) + .build(); + ApiFuture future = intentsClient.batchUpdateIntentsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_batchupdateintents_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/AsyncBatchUpdateIntentsLRO.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/AsyncBatchUpdateIntentsLRO.java new file mode 100644 index 000000000000..afd663e8bafb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/AsyncBatchUpdateIntentsLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_batchupdateintents_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsRequest; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2beta1.IntentView; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Struct; + +public class AsyncBatchUpdateIntentsLRO { + + public static void main(String[] args) throws Exception { + asyncBatchUpdateIntentsLRO(); + } + + public static void asyncBatchUpdateIntentsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + BatchUpdateIntentsRequest request = + BatchUpdateIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .setIntentView(IntentView.forNumber(0)) + .build(); + OperationFuture future = + intentsClient.batchUpdateIntentsOperationCallable().futureCall(request); + // Do something. + BatchUpdateIntentsResponse response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_batchupdateintents_lro_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntents.java new file mode 100644 index 000000000000..0269154748a0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntents.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_batchupdateintents_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsRequest; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2beta1.IntentView; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.protobuf.FieldMask; + +public class SyncBatchUpdateIntents { + + public static void main(String[] args) throws Exception { + syncBatchUpdateIntents(); + } + + public static void syncBatchUpdateIntents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + BatchUpdateIntentsRequest request = + BatchUpdateIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .setIntentView(IntentView.forNumber(0)) + .build(); + BatchUpdateIntentsResponse response = intentsClient.batchUpdateIntentsAsync(request).get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_batchupdateintents_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameIntentbatch.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameIntentbatch.java new file mode 100644 index 000000000000..d19e701c0c67 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameIntentbatch.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_batchupdateintents_agentnameintentbatch_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2beta1.IntentBatch; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncBatchUpdateIntentsAgentnameIntentbatch { + + public static void main(String[] args) throws Exception { + syncBatchUpdateIntentsAgentnameIntentbatch(); + } + + public static void syncBatchUpdateIntentsAgentnameIntentbatch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + IntentBatch intentBatchInline = IntentBatch.newBuilder().build(); + BatchUpdateIntentsResponse response = + intentsClient.batchUpdateIntentsAsync(parent, intentBatchInline).get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_batchupdateintents_agentnameintentbatch_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameString.java new file mode 100644 index 000000000000..dec46e587905 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsAgentnameString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_batchupdateintents_agentnamestring_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncBatchUpdateIntentsAgentnameString { + + public static void main(String[] args) throws Exception { + syncBatchUpdateIntentsAgentnameString(); + } + + public static void syncBatchUpdateIntentsAgentnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String intentBatchUri = "intentBatchUri544125582"; + BatchUpdateIntentsResponse response = + intentsClient.batchUpdateIntentsAsync(parent, intentBatchUri).get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_batchupdateintents_agentnamestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringIntentbatch.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringIntentbatch.java new file mode 100644 index 000000000000..a4f15d6ec24d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringIntentbatch.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_batchupdateintents_stringintentbatch_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2beta1.IntentBatch; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncBatchUpdateIntentsStringIntentbatch { + + public static void main(String[] args) throws Exception { + syncBatchUpdateIntentsStringIntentbatch(); + } + + public static void syncBatchUpdateIntentsStringIntentbatch() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + IntentBatch intentBatchInline = IntentBatch.newBuilder().build(); + BatchUpdateIntentsResponse response = + intentsClient.batchUpdateIntentsAsync(parent, intentBatchInline).get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_batchupdateintents_stringintentbatch_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringString.java new file mode 100644 index 000000000000..c1e34b5c8f8a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/batchupdateintents/SyncBatchUpdateIntentsStringString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_batchupdateintents_stringstring_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncBatchUpdateIntentsStringString { + + public static void main(String[] args) throws Exception { + syncBatchUpdateIntentsStringString(); + } + + public static void syncBatchUpdateIntentsStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + String intentBatchUri = "intentBatchUri544125582"; + BatchUpdateIntentsResponse response = + intentsClient.batchUpdateIntentsAsync(parent, intentBatchUri).get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_batchupdateintents_stringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..d5af1e3a12fc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.cloud.dialogflow.v2beta1.IntentsSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + IntentsSettings intentsSettings = + IntentsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + IntentsClient intentsClient = IntentsClient.create(intentsSettings); + } +} +// [END dialogflow_v2beta1_generated_intentsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..5ee1bb19f839 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.cloud.dialogflow.v2beta1.IntentsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + IntentsSettings intentsSettings = + IntentsSettings.newBuilder() + .setTransportChannelProvider( + IntentsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + IntentsClient intentsClient = IntentsClient.create(intentsSettings); + } +} +// [END dialogflow_v2beta1_generated_intentsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..7e970775363f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,37 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.cloud.dialogflow.v2beta1.IntentsSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + IntentsSettings intentsSettings = IntentsSettings.newBuilder().setEndpoint(myEndpoint).build(); + IntentsClient intentsClient = IntentsClient.create(intentsSettings); + } +} +// [END dialogflow_v2beta1_generated_intentsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/AsyncCreateIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/AsyncCreateIntent.java new file mode 100644 index 000000000000..3d8b9af25764 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/AsyncCreateIntent.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_createintent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.CreateIntentRequest; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentView; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class AsyncCreateIntent { + + public static void main(String[] args) throws Exception { + asyncCreateIntent(); + } + + public static void asyncCreateIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + CreateIntentRequest request = + CreateIntentRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setIntent(Intent.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .build(); + ApiFuture future = intentsClient.createIntentCallable().futureCall(request); + // Do something. + Intent response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_createintent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntent.java new file mode 100644 index 000000000000..127e38c44cd1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntent.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_createintent_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.CreateIntentRequest; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentView; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncCreateIntent { + + public static void main(String[] args) throws Exception { + syncCreateIntent(); + } + + public static void syncCreateIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + CreateIntentRequest request = + CreateIntentRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setIntent(Intent.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .build(); + Intent response = intentsClient.createIntent(request); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_createintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentAgentnameIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentAgentnameIntent.java new file mode 100644 index 000000000000..e0a1ba273946 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentAgentnameIntent.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_createintent_agentnameintent_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncCreateIntentAgentnameIntent { + + public static void main(String[] args) throws Exception { + syncCreateIntentAgentnameIntent(); + } + + public static void syncCreateIntentAgentnameIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + Intent response = intentsClient.createIntent(parent, intent); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_createintent_agentnameintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentAgentnameIntentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentAgentnameIntentString.java new file mode 100644 index 000000000000..ddda011729ee --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentAgentnameIntentString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_createintent_agentnameintentstring_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncCreateIntentAgentnameIntentString { + + public static void main(String[] args) throws Exception { + syncCreateIntentAgentnameIntentString(); + } + + public static void syncCreateIntentAgentnameIntentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + Intent response = intentsClient.createIntent(parent, intent, languageCode); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_createintent_agentnameintentstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentStringIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentStringIntent.java new file mode 100644 index 000000000000..0e4bee2eaf1f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentStringIntent.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_createintent_stringintent_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncCreateIntentStringIntent { + + public static void main(String[] args) throws Exception { + syncCreateIntentStringIntent(); + } + + public static void syncCreateIntentStringIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + Intent intent = Intent.newBuilder().build(); + Intent response = intentsClient.createIntent(parent, intent); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_createintent_stringintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentStringIntentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentStringIntentString.java new file mode 100644 index 000000000000..3b2eda639270 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/createintent/SyncCreateIntentStringIntentString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_createintent_stringintentstring_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncCreateIntentStringIntentString { + + public static void main(String[] args) throws Exception { + syncCreateIntentStringIntentString(); + } + + public static void syncCreateIntentStringIntentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + Intent response = intentsClient.createIntent(parent, intent, languageCode); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_createintent_stringintentstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/AsyncDeleteIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/AsyncDeleteIntent.java new file mode 100644 index 000000000000..bc8ec8e25da0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/AsyncDeleteIntent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_deleteintent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.DeleteIntentRequest; +import com.google.cloud.dialogflow.v2beta1.IntentName; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteIntent { + + public static void main(String[] args) throws Exception { + asyncDeleteIntent(); + } + + public static void asyncDeleteIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + DeleteIntentRequest request = + DeleteIntentRequest.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .build(); + ApiFuture future = intentsClient.deleteIntentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_deleteintent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/SyncDeleteIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/SyncDeleteIntent.java new file mode 100644 index 000000000000..720fdf6c29aa --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/SyncDeleteIntent.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_deleteintent_sync] +import com.google.cloud.dialogflow.v2beta1.DeleteIntentRequest; +import com.google.cloud.dialogflow.v2beta1.IntentName; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncDeleteIntent { + + public static void main(String[] args) throws Exception { + syncDeleteIntent(); + } + + public static void syncDeleteIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + DeleteIntentRequest request = + DeleteIntentRequest.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .build(); + intentsClient.deleteIntent(request); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_deleteintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/SyncDeleteIntentIntentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/SyncDeleteIntentIntentname.java new file mode 100644 index 000000000000..95c4610ea387 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/SyncDeleteIntentIntentname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_deleteintent_intentname_sync] +import com.google.cloud.dialogflow.v2beta1.IntentName; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncDeleteIntentIntentname { + + public static void main(String[] args) throws Exception { + syncDeleteIntentIntentname(); + } + + public static void syncDeleteIntentIntentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + intentsClient.deleteIntent(name); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_deleteintent_intentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/SyncDeleteIntentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/SyncDeleteIntentString.java new file mode 100644 index 000000000000..eb46494f36e9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/deleteintent/SyncDeleteIntentString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_deleteintent_string_sync] +import com.google.cloud.dialogflow.v2beta1.IntentName; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncDeleteIntentString { + + public static void main(String[] args) throws Exception { + syncDeleteIntentString(); + } + + public static void syncDeleteIntentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString(); + intentsClient.deleteIntent(name); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_deleteintent_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/AsyncGetIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/AsyncGetIntent.java new file mode 100644 index 000000000000..a303fff86f3b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/AsyncGetIntent.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_getintent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.GetIntentRequest; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentName; +import com.google.cloud.dialogflow.v2beta1.IntentView; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class AsyncGetIntent { + + public static void main(String[] args) throws Exception { + asyncGetIntent(); + } + + public static void asyncGetIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + GetIntentRequest request = + GetIntentRequest.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .build(); + ApiFuture future = intentsClient.getIntentCallable().futureCall(request); + // Do something. + Intent response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_getintent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntent.java new file mode 100644 index 000000000000..f295e89a09f7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_getintent_sync] +import com.google.cloud.dialogflow.v2beta1.GetIntentRequest; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentName; +import com.google.cloud.dialogflow.v2beta1.IntentView; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncGetIntent { + + public static void main(String[] args) throws Exception { + syncGetIntent(); + } + + public static void syncGetIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + GetIntentRequest request = + GetIntentRequest.newBuilder() + .setName(IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .build(); + Intent response = intentsClient.getIntent(request); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_getintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentIntentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentIntentname.java new file mode 100644 index 000000000000..5012d546fec0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentIntentname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_getintent_intentname_sync] +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentName; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncGetIntentIntentname { + + public static void main(String[] args) throws Exception { + syncGetIntentIntentname(); + } + + public static void syncGetIntentIntentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + Intent response = intentsClient.getIntent(name); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_getintent_intentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentIntentnameString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentIntentnameString.java new file mode 100644 index 000000000000..183334397ec4 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentIntentnameString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_getintent_intentnamestring_sync] +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentName; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncGetIntentIntentnameString { + + public static void main(String[] args) throws Exception { + syncGetIntentIntentnameString(); + } + + public static void syncGetIntentIntentnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + IntentName name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]"); + String languageCode = "languageCode-2092349083"; + Intent response = intentsClient.getIntent(name, languageCode); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_getintent_intentnamestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentString.java new file mode 100644 index 000000000000..ff1fc50f1113 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_getintent_string_sync] +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentName; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncGetIntentString { + + public static void main(String[] args) throws Exception { + syncGetIntentString(); + } + + public static void syncGetIntentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString(); + Intent response = intentsClient.getIntent(name); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_getintent_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentStringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentStringString.java new file mode 100644 index 000000000000..b9455809ac77 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/getintent/SyncGetIntentStringString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_getintent_stringstring_sync] +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentName; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncGetIntentStringString { + + public static void main(String[] args) throws Exception { + syncGetIntentStringString(); + } + + public static void syncGetIntentStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String name = IntentName.ofProjectIntentName("[PROJECT]", "[INTENT]").toString(); + String languageCode = "languageCode-2092349083"; + Intent response = intentsClient.getIntent(name, languageCode); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_getintent_stringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/AsyncListIntents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/AsyncListIntents.java new file mode 100644 index 000000000000..8e62af794ebd --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/AsyncListIntents.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_listintents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentView; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.cloud.dialogflow.v2beta1.ListIntentsRequest; + +public class AsyncListIntents { + + public static void main(String[] args) throws Exception { + asyncListIntents(); + } + + public static void asyncListIntents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + ListIntentsRequest request = + ListIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = intentsClient.listIntentsPagedCallable().futureCall(request); + // Do something. + for (Intent element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_listintents_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/AsyncListIntentsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/AsyncListIntentsPaged.java new file mode 100644 index 000000000000..357dc6c938ce --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/AsyncListIntentsPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_listintents_paged_async] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentView; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.cloud.dialogflow.v2beta1.ListIntentsRequest; +import com.google.cloud.dialogflow.v2beta1.ListIntentsResponse; +import com.google.common.base.Strings; + +public class AsyncListIntentsPaged { + + public static void main(String[] args) throws Exception { + asyncListIntentsPaged(); + } + + public static void asyncListIntentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + ListIntentsRequest request = + ListIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .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; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_listintents_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntents.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntents.java new file mode 100644 index 000000000000..398351c6516e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntents.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_listintents_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentView; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.cloud.dialogflow.v2beta1.ListIntentsRequest; + +public class SyncListIntents { + + public static void main(String[] args) throws Exception { + syncListIntents(); + } + + public static void syncListIntents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + ListIntentsRequest request = + ListIntentsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setLanguageCode("languageCode-2092349083") + .setIntentView(IntentView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Intent element : intentsClient.listIntents(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_listintents_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsAgentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsAgentname.java new file mode 100644 index 000000000000..9a530b311c59 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsAgentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_listintents_agentname_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncListIntentsAgentname { + + public static void main(String[] args) throws Exception { + syncListIntentsAgentname(); + } + + public static void syncListIntentsAgentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + for (Intent element : intentsClient.listIntents(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_listintents_agentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsAgentnameString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsAgentnameString.java new file mode 100644 index 000000000000..48785d4629e8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsAgentnameString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_listintents_agentnamestring_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncListIntentsAgentnameString { + + public static void main(String[] args) throws Exception { + syncListIntentsAgentnameString(); + } + + public static void syncListIntentsAgentnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + String languageCode = "languageCode-2092349083"; + for (Intent element : intentsClient.listIntents(parent, languageCode).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_listintents_agentnamestring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsString.java new file mode 100644 index 000000000000..af61398e220f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_listintents_string_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncListIntentsString { + + public static void main(String[] args) throws Exception { + syncListIntentsString(); + } + + public static void syncListIntentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + for (Intent element : intentsClient.listIntents(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_listintents_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsStringString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsStringString.java new file mode 100644 index 000000000000..1e07147df888 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/listintents/SyncListIntentsStringString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_listintents_stringstring_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncListIntentsStringString { + + public static void main(String[] args) throws Exception { + syncListIntentsStringString(); + } + + public static void syncListIntentsStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + String languageCode = "languageCode-2092349083"; + for (Intent element : intentsClient.listIntents(parent, languageCode).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_listintents_stringstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/AsyncUpdateIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/AsyncUpdateIntent.java new file mode 100644 index 000000000000..bbda4c9e0156 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/AsyncUpdateIntent.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_updateintent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentView; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateIntentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateIntent { + + public static void main(String[] args) throws Exception { + asyncUpdateIntent(); + } + + public static void asyncUpdateIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + UpdateIntentRequest request = + UpdateIntentRequest.newBuilder() + .setIntent(Intent.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .setIntentView(IntentView.forNumber(0)) + .build(); + ApiFuture future = intentsClient.updateIntentCallable().futureCall(request); + // Do something. + Intent response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_updateintent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntent.java new file mode 100644 index 000000000000..48ab4d96176e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntent.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_updateintent_sync] +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentView; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateIntentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateIntent { + + public static void main(String[] args) throws Exception { + syncUpdateIntent(); + } + + public static void syncUpdateIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + UpdateIntentRequest request = + UpdateIntentRequest.newBuilder() + .setIntent(Intent.newBuilder().build()) + .setLanguageCode("languageCode-2092349083") + .setUpdateMask(FieldMask.newBuilder().build()) + .setIntentView(IntentView.forNumber(0)) + .build(); + Intent response = intentsClient.updateIntent(request); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_updateintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntent.java new file mode 100644 index 000000000000..5313e0e5aded --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntent.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_updateintent_intent_sync] +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncUpdateIntentIntent { + + public static void main(String[] args) throws Exception { + syncUpdateIntentIntent(); + } + + public static void syncUpdateIntentIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + Intent intent = Intent.newBuilder().build(); + Intent response = intentsClient.updateIntent(intent); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_updateintent_intent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntentFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntentFieldmask.java new file mode 100644 index 000000000000..7e57cfdfd7a9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntentFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_updateintent_intentfieldmask_sync] +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateIntentIntentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateIntentIntentFieldmask(); + } + + public static void syncUpdateIntentIntentFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + Intent intent = Intent.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Intent response = intentsClient.updateIntent(intent, updateMask); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_updateintent_intentfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntentString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntentString.java new file mode 100644 index 000000000000..9105a01048e0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntentString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_updateintent_intentstring_sync] +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; + +public class SyncUpdateIntentIntentString { + + public static void main(String[] args) throws Exception { + syncUpdateIntentIntentString(); + } + + public static void syncUpdateIntentIntentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + Intent response = intentsClient.updateIntent(intent, languageCode); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_updateintent_intentstring_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntentStringFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntentStringFieldmask.java new file mode 100644 index 000000000000..749bab01ee7c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentsclient/updateintent/SyncUpdateIntentIntentStringFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentsclient_updateintent_intentstringfieldmask_sync] +import com.google.cloud.dialogflow.v2beta1.Intent; +import com.google.cloud.dialogflow.v2beta1.IntentsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateIntentIntentStringFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateIntentIntentStringFieldmask(); + } + + public static void syncUpdateIntentIntentStringFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (IntentsClient intentsClient = IntentsClient.create()) { + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-2092349083"; + FieldMask updateMask = FieldMask.newBuilder().build(); + Intent response = intentsClient.updateIntent(intent, languageCode, updateMask); + } + } +} +// [END dialogflow_v2beta1_generated_intentsclient_updateintent_intentstringfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentssettings/getintent/SyncGetIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentssettings/getintent/SyncGetIntent.java new file mode 100644 index 000000000000..80ec7aa16689 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/intentssettings/getintent/SyncGetIntent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_intentssettings_getintent_sync] +import com.google.cloud.dialogflow.v2beta1.IntentsSettings; +import java.time.Duration; + +public class SyncGetIntent { + + public static void main(String[] args) throws Exception { + syncGetIntent(); + } + + public static void syncGetIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + IntentsSettings.Builder intentsSettingsBuilder = IntentsSettings.newBuilder(); + intentsSettingsBuilder + .getIntentSettings() + .setRetrySettings( + intentsSettingsBuilder + .getIntentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + IntentsSettings intentsSettings = intentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_intentssettings_getintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..c43f36d26a10 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + KnowledgeBasesSettings knowledgeBasesSettings = + KnowledgeBasesSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create(knowledgeBasesSettings); + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..689a95227ff0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + KnowledgeBasesSettings knowledgeBasesSettings = + KnowledgeBasesSettings.newBuilder() + .setTransportChannelProvider( + KnowledgeBasesSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create(knowledgeBasesSettings); + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..eac7888f8b0d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + KnowledgeBasesSettings knowledgeBasesSettings = + KnowledgeBasesSettings.newBuilder().setEndpoint(myEndpoint).build(); + KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create(knowledgeBasesSettings); + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/AsyncCreateKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/AsyncCreateKnowledgeBase.java new file mode 100644 index 000000000000..2b8a44cab164 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/AsyncCreateKnowledgeBase.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_createknowledgebase_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.CreateKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class AsyncCreateKnowledgeBase { + + public static void main(String[] args) throws Exception { + asyncCreateKnowledgeBase(); + } + + public static void asyncCreateKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + CreateKnowledgeBaseRequest request = + CreateKnowledgeBaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setKnowledgeBase(KnowledgeBase.newBuilder().build()) + .build(); + ApiFuture future = + knowledgeBasesClient.createKnowledgeBaseCallable().futureCall(request); + // Do something. + KnowledgeBase response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_createknowledgebase_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBase.java new file mode 100644 index 000000000000..2c2607c9fbcb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBase.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_createknowledgebase_sync] +import com.google.cloud.dialogflow.v2beta1.CreateKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncCreateKnowledgeBase { + + public static void main(String[] args) throws Exception { + syncCreateKnowledgeBase(); + } + + public static void syncCreateKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + CreateKnowledgeBaseRequest request = + CreateKnowledgeBaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setKnowledgeBase(KnowledgeBase.newBuilder().build()) + .build(); + KnowledgeBase response = knowledgeBasesClient.createKnowledgeBase(request); + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_createknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseLocationnameKnowledgebase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseLocationnameKnowledgebase.java new file mode 100644 index 000000000000..1f4bc9366d3c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseLocationnameKnowledgebase.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_knowledgebasesclient_createknowledgebase_locationnameknowledgebase_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.LocationName; + +public class SyncCreateKnowledgeBaseLocationnameKnowledgebase { + + public static void main(String[] args) throws Exception { + syncCreateKnowledgeBaseLocationnameKnowledgebase(); + } + + public static void syncCreateKnowledgeBaseLocationnameKnowledgebase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + KnowledgeBase response = knowledgeBasesClient.createKnowledgeBase(parent, knowledgeBase); + } + } +} +// [END +// dialogflow_v2beta1_generated_knowledgebasesclient_createknowledgebase_locationnameknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseProjectnameKnowledgebase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseProjectnameKnowledgebase.java new file mode 100644 index 000000000000..b06043fa9175 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseProjectnameKnowledgebase.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_knowledgebasesclient_createknowledgebase_projectnameknowledgebase_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncCreateKnowledgeBaseProjectnameKnowledgebase { + + public static void main(String[] args) throws Exception { + syncCreateKnowledgeBaseProjectnameKnowledgebase(); + } + + public static void syncCreateKnowledgeBaseProjectnameKnowledgebase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + KnowledgeBase response = knowledgeBasesClient.createKnowledgeBase(parent, knowledgeBase); + } + } +} +// [END +// dialogflow_v2beta1_generated_knowledgebasesclient_createknowledgebase_projectnameknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseStringKnowledgebase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseStringKnowledgebase.java new file mode 100644 index 000000000000..84731c06b3e2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/createknowledgebase/SyncCreateKnowledgeBaseStringKnowledgebase.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_knowledgebasesclient_createknowledgebase_stringknowledgebase_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncCreateKnowledgeBaseStringKnowledgebase { + + public static void main(String[] args) throws Exception { + syncCreateKnowledgeBaseStringKnowledgebase(); + } + + public static void syncCreateKnowledgeBaseStringKnowledgebase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + KnowledgeBase response = knowledgeBasesClient.createKnowledgeBase(parent, knowledgeBase); + } + } +} +// [END +// dialogflow_v2beta1_generated_knowledgebasesclient_createknowledgebase_stringknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/AsyncDeleteKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/AsyncDeleteKnowledgeBase.java new file mode 100644 index 000000000000..de219834594d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/AsyncDeleteKnowledgeBase.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_deleteknowledgebase_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.DeleteKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteKnowledgeBase { + + public static void main(String[] args) throws Exception { + asyncDeleteKnowledgeBase(); + } + + public static void asyncDeleteKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + DeleteKnowledgeBaseRequest request = + DeleteKnowledgeBaseRequest.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setForce(true) + .build(); + ApiFuture future = + knowledgeBasesClient.deleteKnowledgeBaseCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_deleteknowledgebase_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBase.java new file mode 100644 index 000000000000..cd9ed95cfbe8 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBase.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_deleteknowledgebase_sync] +import com.google.cloud.dialogflow.v2beta1.DeleteKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; + +public class SyncDeleteKnowledgeBase { + + public static void main(String[] args) throws Exception { + syncDeleteKnowledgeBase(); + } + + public static void syncDeleteKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + DeleteKnowledgeBaseRequest request = + DeleteKnowledgeBaseRequest.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .setForce(true) + .build(); + knowledgeBasesClient.deleteKnowledgeBase(request); + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_deleteknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseKnowledgebasename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseKnowledgebasename.java new file mode 100644 index 000000000000..c5415a7c6931 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseKnowledgebasename.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_knowledgebasesclient_deleteknowledgebase_knowledgebasename_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; + +public class SyncDeleteKnowledgeBaseKnowledgebasename { + + public static void main(String[] args) throws Exception { + syncDeleteKnowledgeBaseKnowledgebasename(); + } + + public static void syncDeleteKnowledgeBaseKnowledgebasename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + KnowledgeBaseName name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + knowledgeBasesClient.deleteKnowledgeBase(name); + } + } +} +// [END +// dialogflow_v2beta1_generated_knowledgebasesclient_deleteknowledgebase_knowledgebasename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseString.java new file mode 100644 index 000000000000..72771d499314 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/deleteknowledgebase/SyncDeleteKnowledgeBaseString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_deleteknowledgebase_string_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; + +public class SyncDeleteKnowledgeBaseString { + + public static void main(String[] args) throws Exception { + syncDeleteKnowledgeBaseString(); + } + + public static void syncDeleteKnowledgeBaseString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + String name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]").toString(); + knowledgeBasesClient.deleteKnowledgeBase(name); + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_deleteknowledgebase_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/AsyncGetKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/AsyncGetKnowledgeBase.java new file mode 100644 index 000000000000..dcd4bff55fcc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/AsyncGetKnowledgeBase.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_getknowledgebase_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.GetKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; + +public class AsyncGetKnowledgeBase { + + public static void main(String[] args) throws Exception { + asyncGetKnowledgeBase(); + } + + public static void asyncGetKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + GetKnowledgeBaseRequest request = + GetKnowledgeBaseRequest.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .build(); + ApiFuture future = + knowledgeBasesClient.getKnowledgeBaseCallable().futureCall(request); + // Do something. + KnowledgeBase response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_getknowledgebase_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBase.java new file mode 100644 index 000000000000..4b3a1b0dee41 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBase.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_getknowledgebase_sync] +import com.google.cloud.dialogflow.v2beta1.GetKnowledgeBaseRequest; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; + +public class SyncGetKnowledgeBase { + + public static void main(String[] args) throws Exception { + syncGetKnowledgeBase(); + } + + public static void syncGetKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + GetKnowledgeBaseRequest request = + GetKnowledgeBaseRequest.newBuilder() + .setName( + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]") + .toString()) + .build(); + KnowledgeBase response = knowledgeBasesClient.getKnowledgeBase(request); + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_getknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseKnowledgebasename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseKnowledgebasename.java new file mode 100644 index 000000000000..a73f03c074d0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseKnowledgebasename.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_getknowledgebase_knowledgebasename_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; + +public class SyncGetKnowledgeBaseKnowledgebasename { + + public static void main(String[] args) throws Exception { + syncGetKnowledgeBaseKnowledgebasename(); + } + + public static void syncGetKnowledgeBaseKnowledgebasename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + KnowledgeBaseName name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]"); + KnowledgeBase response = knowledgeBasesClient.getKnowledgeBase(name); + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_getknowledgebase_knowledgebasename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseString.java new file mode 100644 index 000000000000..81d346b21288 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/getknowledgebase/SyncGetKnowledgeBaseString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_getknowledgebase_string_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBaseName; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; + +public class SyncGetKnowledgeBaseString { + + public static void main(String[] args) throws Exception { + syncGetKnowledgeBaseString(); + } + + public static void syncGetKnowledgeBaseString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + String name = + KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]").toString(); + KnowledgeBase response = knowledgeBasesClient.getKnowledgeBase(name); + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_getknowledgebase_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBases.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBases.java new file mode 100644 index 000000000000..920103d7a88c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBases.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_listknowledgebases_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.ListKnowledgeBasesRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class AsyncListKnowledgeBases { + + public static void main(String[] args) throws Exception { + asyncListKnowledgeBases(); + } + + public static void asyncListKnowledgeBases() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + ListKnowledgeBasesRequest request = + ListKnowledgeBasesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + knowledgeBasesClient.listKnowledgeBasesPagedCallable().futureCall(request); + // Do something. + for (KnowledgeBase element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_listknowledgebases_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBasesPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBasesPaged.java new file mode 100644 index 000000000000..c64b68b867c7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/AsyncListKnowledgeBasesPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_listknowledgebases_paged_async] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.ListKnowledgeBasesRequest; +import com.google.cloud.dialogflow.v2beta1.ListKnowledgeBasesResponse; +import com.google.cloud.dialogflow.v2beta1.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListKnowledgeBasesPaged { + + public static void main(String[] args) throws Exception { + asyncListKnowledgeBasesPaged(); + } + + public static void asyncListKnowledgeBasesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + ListKnowledgeBasesRequest request = + ListKnowledgeBasesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListKnowledgeBasesResponse response = + knowledgeBasesClient.listKnowledgeBasesCallable().call(request); + for (KnowledgeBase element : response.getKnowledgeBasesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_listknowledgebases_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBases.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBases.java new file mode 100644 index 000000000000..1c81815b2172 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBases.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_listknowledgebases_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.ListKnowledgeBasesRequest; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncListKnowledgeBases { + + public static void main(String[] args) throws Exception { + syncListKnowledgeBases(); + } + + public static void syncListKnowledgeBases() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + ListKnowledgeBasesRequest request = + ListKnowledgeBasesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (KnowledgeBase element : knowledgeBasesClient.listKnowledgeBases(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_listknowledgebases_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesLocationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesLocationname.java new file mode 100644 index 000000000000..0b202d670e15 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_listknowledgebases_locationname_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.LocationName; + +public class SyncListKnowledgeBasesLocationname { + + public static void main(String[] args) throws Exception { + syncListKnowledgeBasesLocationname(); + } + + public static void syncListKnowledgeBasesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (KnowledgeBase element : knowledgeBasesClient.listKnowledgeBases(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_listknowledgebases_locationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesProjectname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesProjectname.java new file mode 100644 index 000000000000..01ce8d02efe3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesProjectname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_listknowledgebases_projectname_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncListKnowledgeBasesProjectname { + + public static void main(String[] args) throws Exception { + syncListKnowledgeBasesProjectname(); + } + + public static void syncListKnowledgeBasesProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (KnowledgeBase element : knowledgeBasesClient.listKnowledgeBases(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_listknowledgebases_projectname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesString.java new file mode 100644 index 000000000000..77eb5a320c18 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/listknowledgebases/SyncListKnowledgeBasesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_listknowledgebases_string_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.ProjectName; + +public class SyncListKnowledgeBasesString { + + public static void main(String[] args) throws Exception { + syncListKnowledgeBasesString(); + } + + public static void syncListKnowledgeBasesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (KnowledgeBase element : knowledgeBasesClient.listKnowledgeBases(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_listknowledgebases_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/AsyncUpdateKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/AsyncUpdateKnowledgeBase.java new file mode 100644 index 000000000000..4e8ebc1d0a93 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/AsyncUpdateKnowledgeBase.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_updateknowledgebase_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.UpdateKnowledgeBaseRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateKnowledgeBase { + + public static void main(String[] args) throws Exception { + asyncUpdateKnowledgeBase(); + } + + public static void asyncUpdateKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + UpdateKnowledgeBaseRequest request = + UpdateKnowledgeBaseRequest.newBuilder() + .setKnowledgeBase(KnowledgeBase.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + knowledgeBasesClient.updateKnowledgeBaseCallable().futureCall(request); + // Do something. + KnowledgeBase response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_updateknowledgebase_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBase.java new file mode 100644 index 000000000000..6a25f8976316 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBase.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_updateknowledgebase_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.cloud.dialogflow.v2beta1.UpdateKnowledgeBaseRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateKnowledgeBase { + + public static void main(String[] args) throws Exception { + syncUpdateKnowledgeBase(); + } + + public static void syncUpdateKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + UpdateKnowledgeBaseRequest request = + UpdateKnowledgeBaseRequest.newBuilder() + .setKnowledgeBase(KnowledgeBase.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + KnowledgeBase response = knowledgeBasesClient.updateKnowledgeBase(request); + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_updateknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBaseKnowledgebase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBaseKnowledgebase.java new file mode 100644 index 000000000000..472ff6663bcb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBaseKnowledgebase.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesclient_updateknowledgebase_knowledgebase_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; + +public class SyncUpdateKnowledgeBaseKnowledgebase { + + public static void main(String[] args) throws Exception { + syncUpdateKnowledgeBaseKnowledgebase(); + } + + public static void syncUpdateKnowledgeBaseKnowledgebase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + KnowledgeBase response = knowledgeBasesClient.updateKnowledgeBase(knowledgeBase); + } + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesclient_updateknowledgebase_knowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBaseKnowledgebaseFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBaseKnowledgebaseFieldmask.java new file mode 100644 index 000000000000..fb3265cc2e18 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasesclient/updateknowledgebase/SyncUpdateKnowledgeBaseKnowledgebaseFieldmask.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_knowledgebasesclient_updateknowledgebase_knowledgebasefieldmask_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBase; +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateKnowledgeBaseKnowledgebaseFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateKnowledgeBaseKnowledgebaseFieldmask(); + } + + public static void syncUpdateKnowledgeBaseKnowledgebaseFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) { + KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + KnowledgeBase response = knowledgeBasesClient.updateKnowledgeBase(knowledgeBase, updateMask); + } + } +} +// [END +// dialogflow_v2beta1_generated_knowledgebasesclient_updateknowledgebase_knowledgebasefieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasessettings/getknowledgebase/SyncGetKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasessettings/getknowledgebase/SyncGetKnowledgeBase.java new file mode 100644 index 000000000000..7d82927248fa --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/knowledgebasessettings/getknowledgebase/SyncGetKnowledgeBase.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasessettings_getknowledgebase_sync] +import com.google.cloud.dialogflow.v2beta1.KnowledgeBasesSettings; +import java.time.Duration; + +public class SyncGetKnowledgeBase { + + public static void main(String[] args) throws Exception { + syncGetKnowledgeBase(); + } + + public static void syncGetKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + KnowledgeBasesSettings.Builder knowledgeBasesSettingsBuilder = + KnowledgeBasesSettings.newBuilder(); + knowledgeBasesSettingsBuilder + .getKnowledgeBaseSettings() + .setRetrySettings( + knowledgeBasesSettingsBuilder + .getKnowledgeBaseSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + KnowledgeBasesSettings knowledgeBasesSettings = knowledgeBasesSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_knowledgebasessettings_getknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/AsyncAnalyzeContent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/AsyncAnalyzeContent.java new file mode 100644 index 000000000000..75942815a170 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/AsyncAnalyzeContent.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_analyzecontent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AnalyzeContentRequest; +import com.google.cloud.dialogflow.v2beta1.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2beta1.AssistQueryParameters; +import com.google.cloud.dialogflow.v2beta1.OutputAudioConfig; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.QueryParameters; +import com.google.protobuf.Struct; +import com.google.protobuf.Timestamp; + +public class AsyncAnalyzeContent { + + public static void main(String[] args) throws Exception { + asyncAnalyzeContent(); + } + + public static void asyncAnalyzeContent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + AnalyzeContentRequest request = + AnalyzeContentRequest.newBuilder() + .setParticipant( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setReplyAudioConfig(OutputAudioConfig.newBuilder().build()) + .setQueryParams(QueryParameters.newBuilder().build()) + .setAssistQueryParams(AssistQueryParameters.newBuilder().build()) + .setCxParameters(Struct.newBuilder().build()) + .setMessageSendTime(Timestamp.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + participantsClient.analyzeContentCallable().futureCall(request); + // Do something. + AnalyzeContentResponse response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_analyzecontent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContent.java new file mode 100644 index 000000000000..9dd6f2c0f436 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContent.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_analyzecontent_sync] +import com.google.cloud.dialogflow.v2beta1.AnalyzeContentRequest; +import com.google.cloud.dialogflow.v2beta1.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2beta1.AssistQueryParameters; +import com.google.cloud.dialogflow.v2beta1.OutputAudioConfig; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.QueryParameters; +import com.google.protobuf.Struct; +import com.google.protobuf.Timestamp; + +public class SyncAnalyzeContent { + + public static void main(String[] args) throws Exception { + syncAnalyzeContent(); + } + + public static void syncAnalyzeContent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + AnalyzeContentRequest request = + AnalyzeContentRequest.newBuilder() + .setParticipant( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setReplyAudioConfig(OutputAudioConfig.newBuilder().build()) + .setQueryParams(QueryParameters.newBuilder().build()) + .setAssistQueryParams(AssistQueryParameters.newBuilder().build()) + .setCxParameters(Struct.newBuilder().build()) + .setMessageSendTime(Timestamp.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + AnalyzeContentResponse response = participantsClient.analyzeContent(request); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_analyzecontent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameEventinput.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameEventinput.java new file mode 100644 index 000000000000..315d4adf7c11 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameEventinput.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_participantsclient_analyzecontent_participantnameeventinput_sync] +import com.google.cloud.dialogflow.v2beta1.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2beta1.EventInput; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class SyncAnalyzeContentParticipantnameEventinput { + + public static void main(String[] args) throws Exception { + syncAnalyzeContentParticipantnameEventinput(); + } + + public static void syncAnalyzeContentParticipantnameEventinput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ParticipantName participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + EventInput eventInput = EventInput.newBuilder().build(); + AnalyzeContentResponse response = participantsClient.analyzeContent(participant, eventInput); + } + } +} +// [END +// dialogflow_v2beta1_generated_participantsclient_analyzecontent_participantnameeventinput_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameTextinput.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameTextinput.java new file mode 100644 index 000000000000..00b8b5bea0a5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentParticipantnameTextinput.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_participantsclient_analyzecontent_participantnametextinput_sync] +import com.google.cloud.dialogflow.v2beta1.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.TextInput; + +public class SyncAnalyzeContentParticipantnameTextinput { + + public static void main(String[] args) throws Exception { + syncAnalyzeContentParticipantnameTextinput(); + } + + public static void syncAnalyzeContentParticipantnameTextinput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ParticipantName participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + TextInput textInput = TextInput.newBuilder().build(); + AnalyzeContentResponse response = participantsClient.analyzeContent(participant, textInput); + } + } +} +// [END +// dialogflow_v2beta1_generated_participantsclient_analyzecontent_participantnametextinput_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentStringEventinput.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentStringEventinput.java new file mode 100644 index 000000000000..ac0285357186 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentStringEventinput.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_analyzecontent_stringeventinput_sync] +import com.google.cloud.dialogflow.v2beta1.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2beta1.EventInput; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class SyncAnalyzeContentStringEventinput { + + public static void main(String[] args) throws Exception { + syncAnalyzeContentStringEventinput(); + } + + public static void syncAnalyzeContentStringEventinput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString(); + EventInput eventInput = EventInput.newBuilder().build(); + AnalyzeContentResponse response = participantsClient.analyzeContent(participant, eventInput); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_analyzecontent_stringeventinput_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentStringTextinput.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentStringTextinput.java new file mode 100644 index 000000000000..38d0e15f33bc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/analyzecontent/SyncAnalyzeContentStringTextinput.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_analyzecontent_stringtextinput_sync] +import com.google.cloud.dialogflow.v2beta1.AnalyzeContentResponse; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.TextInput; + +public class SyncAnalyzeContentStringTextinput { + + public static void main(String[] args) throws Exception { + syncAnalyzeContentStringTextinput(); + } + + public static void syncAnalyzeContentStringTextinput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String participant = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString(); + TextInput textInput = TextInput.newBuilder().build(); + AnalyzeContentResponse response = participantsClient.analyzeContent(participant, textInput); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_analyzecontent_stringtextinput_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/compilesuggestion/AsyncCompileSuggestion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/compilesuggestion/AsyncCompileSuggestion.java new file mode 100644 index 000000000000..73c09e1f1100 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/compilesuggestion/AsyncCompileSuggestion.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_compilesuggestion_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.CompileSuggestionRequest; +import com.google.cloud.dialogflow.v2beta1.CompileSuggestionResponse; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class AsyncCompileSuggestion { + + public static void main(String[] args) throws Exception { + asyncCompileSuggestion(); + } + + public static void asyncCompileSuggestion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + CompileSuggestionRequest request = + CompileSuggestionRequest.newBuilder() + .setParent("parent-995424086") + .setLatestMessage("latestMessage-1424305536") + .setContextSize(1116903569) + .build(); + ApiFuture future = + participantsClient.compileSuggestionCallable().futureCall(request); + // Do something. + CompileSuggestionResponse response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_compilesuggestion_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/compilesuggestion/SyncCompileSuggestion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/compilesuggestion/SyncCompileSuggestion.java new file mode 100644 index 000000000000..5e547ef48cf4 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/compilesuggestion/SyncCompileSuggestion.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_compilesuggestion_sync] +import com.google.cloud.dialogflow.v2beta1.CompileSuggestionRequest; +import com.google.cloud.dialogflow.v2beta1.CompileSuggestionResponse; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class SyncCompileSuggestion { + + public static void main(String[] args) throws Exception { + syncCompileSuggestion(); + } + + public static void syncCompileSuggestion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + CompileSuggestionRequest request = + CompileSuggestionRequest.newBuilder() + .setParent("parent-995424086") + .setLatestMessage("latestMessage-1424305536") + .setContextSize(1116903569) + .build(); + CompileSuggestionResponse response = participantsClient.compileSuggestion(request); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_compilesuggestion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..c2bc63f9e56b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.ParticipantsSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ParticipantsSettings participantsSettings = + ParticipantsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ParticipantsClient participantsClient = ParticipantsClient.create(participantsSettings); + } +} +// [END dialogflow_v2beta1_generated_participantsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..92a05876f4c2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.ParticipantsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ParticipantsSettings participantsSettings = + ParticipantsSettings.newBuilder() + .setTransportChannelProvider( + ParticipantsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ParticipantsClient participantsClient = ParticipantsClient.create(participantsSettings); + } +} +// [END dialogflow_v2beta1_generated_participantsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..b77fb484880c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.ParticipantsSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ParticipantsSettings participantsSettings = + ParticipantsSettings.newBuilder().setEndpoint(myEndpoint).build(); + ParticipantsClient participantsClient = ParticipantsClient.create(participantsSettings); + } +} +// [END dialogflow_v2beta1_generated_participantsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/AsyncCreateParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/AsyncCreateParticipant.java new file mode 100644 index 000000000000..e1b10fa123e6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/AsyncCreateParticipant.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_createparticipant_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.CreateParticipantRequest; +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class AsyncCreateParticipant { + + public static void main(String[] args) throws Exception { + asyncCreateParticipant(); + } + + public static void asyncCreateParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + CreateParticipantRequest request = + CreateParticipantRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setParticipant(Participant.newBuilder().build()) + .build(); + ApiFuture future = + participantsClient.createParticipantCallable().futureCall(request); + // Do something. + Participant response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_createparticipant_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/SyncCreateParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/SyncCreateParticipant.java new file mode 100644 index 000000000000..3c3e2ecf7d43 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/SyncCreateParticipant.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_createparticipant_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.CreateParticipantRequest; +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class SyncCreateParticipant { + + public static void main(String[] args) throws Exception { + syncCreateParticipant(); + } + + public static void syncCreateParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + CreateParticipantRequest request = + CreateParticipantRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setParticipant(Participant.newBuilder().build()) + .build(); + Participant response = participantsClient.createParticipant(request); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_createparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/SyncCreateParticipantConversationnameParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/SyncCreateParticipantConversationnameParticipant.java new file mode 100644 index 000000000000..593320204157 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/SyncCreateParticipantConversationnameParticipant.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_participantsclient_createparticipant_conversationnameparticipant_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class SyncCreateParticipantConversationnameParticipant { + + public static void main(String[] args) throws Exception { + syncCreateParticipantConversationnameParticipant(); + } + + public static void syncCreateParticipantConversationnameParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + Participant participant = Participant.newBuilder().build(); + Participant response = participantsClient.createParticipant(parent, participant); + } + } +} +// [END +// dialogflow_v2beta1_generated_participantsclient_createparticipant_conversationnameparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/SyncCreateParticipantStringParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/SyncCreateParticipantStringParticipant.java new file mode 100644 index 000000000000..7d4fb64e6caa --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/createparticipant/SyncCreateParticipantStringParticipant.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_createparticipant_stringparticipant_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class SyncCreateParticipantStringParticipant { + + public static void main(String[] args) throws Exception { + syncCreateParticipantStringParticipant(); + } + + public static void syncCreateParticipantStringParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString(); + Participant participant = Participant.newBuilder().build(); + Participant response = participantsClient.createParticipant(parent, participant); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_createparticipant_stringparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/AsyncGetParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/AsyncGetParticipant.java new file mode 100644 index 000000000000..3f1463ea348a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/AsyncGetParticipant.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_getparticipant_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.GetParticipantRequest; +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class AsyncGetParticipant { + + public static void main(String[] args) throws Exception { + asyncGetParticipant(); + } + + public static void asyncGetParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + GetParticipantRequest request = + GetParticipantRequest.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .build(); + ApiFuture future = + participantsClient.getParticipantCallable().futureCall(request); + // Do something. + Participant response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_getparticipant_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/SyncGetParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/SyncGetParticipant.java new file mode 100644 index 000000000000..e29541c7567b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/SyncGetParticipant.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_getparticipant_sync] +import com.google.cloud.dialogflow.v2beta1.GetParticipantRequest; +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class SyncGetParticipant { + + public static void main(String[] args) throws Exception { + syncGetParticipant(); + } + + public static void syncGetParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + GetParticipantRequest request = + GetParticipantRequest.newBuilder() + .setName( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .build(); + Participant response = participantsClient.getParticipant(request); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_getparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/SyncGetParticipantParticipantname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/SyncGetParticipantParticipantname.java new file mode 100644 index 000000000000..d48763b84868 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/SyncGetParticipantParticipantname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_getparticipant_participantname_sync] +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class SyncGetParticipantParticipantname { + + public static void main(String[] args) throws Exception { + syncGetParticipantParticipantname(); + } + + public static void syncGetParticipantParticipantname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ParticipantName name = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + Participant response = participantsClient.getParticipant(name); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_getparticipant_participantname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/SyncGetParticipantString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/SyncGetParticipantString.java new file mode 100644 index 000000000000..4185127ffd0a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/getparticipant/SyncGetParticipantString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_getparticipant_string_sync] +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class SyncGetParticipantString { + + public static void main(String[] args) throws Exception { + syncGetParticipantString(); + } + + public static void syncGetParticipantString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String name = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString(); + Participant response = participantsClient.getParticipant(name); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_getparticipant_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/AsyncListParticipants.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/AsyncListParticipants.java new file mode 100644 index 000000000000..9f1d7b777a46 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/AsyncListParticipants.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_listparticipants_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ListParticipantsRequest; +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class AsyncListParticipants { + + public static void main(String[] args) throws Exception { + asyncListParticipants(); + } + + public static void asyncListParticipants() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ListParticipantsRequest request = + ListParticipantsRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + participantsClient.listParticipantsPagedCallable().futureCall(request); + // Do something. + for (Participant element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_listparticipants_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/AsyncListParticipantsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/AsyncListParticipantsPaged.java new file mode 100644 index 000000000000..da82e0ac103b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/AsyncListParticipantsPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_listparticipants_paged_async] +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ListParticipantsRequest; +import com.google.cloud.dialogflow.v2beta1.ListParticipantsResponse; +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.common.base.Strings; + +public class AsyncListParticipantsPaged { + + public static void main(String[] args) throws Exception { + asyncListParticipantsPaged(); + } + + public static void asyncListParticipantsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ListParticipantsRequest request = + ListParticipantsRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListParticipantsResponse response = + participantsClient.listParticipantsCallable().call(request); + for (Participant element : response.getParticipantsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_listparticipants_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/SyncListParticipants.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/SyncListParticipants.java new file mode 100644 index 000000000000..cb73d26c6d8e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/SyncListParticipants.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_listparticipants_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.ListParticipantsRequest; +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class SyncListParticipants { + + public static void main(String[] args) throws Exception { + syncListParticipants(); + } + + public static void syncListParticipants() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ListParticipantsRequest request = + ListParticipantsRequest.newBuilder() + .setParent( + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Participant element : participantsClient.listParticipants(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_listparticipants_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/SyncListParticipantsConversationname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/SyncListParticipantsConversationname.java new file mode 100644 index 000000000000..40944bdd8d7c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/SyncListParticipantsConversationname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_listparticipants_conversationname_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class SyncListParticipantsConversationname { + + public static void main(String[] args) throws Exception { + syncListParticipantsConversationname(); + } + + public static void syncListParticipantsConversationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ConversationName parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]"); + for (Participant element : participantsClient.listParticipants(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_listparticipants_conversationname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/SyncListParticipantsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/SyncListParticipantsString.java new file mode 100644 index 000000000000..4d3d6dcaded4 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listparticipants/SyncListParticipantsString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_listparticipants_string_sync] +import com.google.cloud.dialogflow.v2beta1.ConversationName; +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; + +public class SyncListParticipantsString { + + public static void main(String[] args) throws Exception { + syncListParticipantsString(); + } + + public static void syncListParticipantsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String parent = + ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]").toString(); + for (Participant element : participantsClient.listParticipants(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_listparticipants_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listsuggestions/AsyncListSuggestions.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listsuggestions/AsyncListSuggestions.java new file mode 100644 index 000000000000..d51af95a6038 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listsuggestions/AsyncListSuggestions.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_listsuggestions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ListSuggestionsRequest; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.Suggestion; + +public class AsyncListSuggestions { + + public static void main(String[] args) throws Exception { + asyncListSuggestions(); + } + + public static void asyncListSuggestions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ListSuggestionsRequest request = + ListSuggestionsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + participantsClient.listSuggestionsPagedCallable().futureCall(request); + // Do something. + for (Suggestion element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_listsuggestions_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listsuggestions/AsyncListSuggestionsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listsuggestions/AsyncListSuggestionsPaged.java new file mode 100644 index 000000000000..57591e2bcbce --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listsuggestions/AsyncListSuggestionsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_listsuggestions_paged_async] +import com.google.cloud.dialogflow.v2beta1.ListSuggestionsRequest; +import com.google.cloud.dialogflow.v2beta1.ListSuggestionsResponse; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.Suggestion; +import com.google.common.base.Strings; + +public class AsyncListSuggestionsPaged { + + public static void main(String[] args) throws Exception { + asyncListSuggestionsPaged(); + } + + public static void asyncListSuggestionsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ListSuggestionsRequest request = + ListSuggestionsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListSuggestionsResponse response = + participantsClient.listSuggestionsCallable().call(request); + for (Suggestion element : response.getSuggestionsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_listsuggestions_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listsuggestions/SyncListSuggestions.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listsuggestions/SyncListSuggestions.java new file mode 100644 index 000000000000..237761af7a8a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/listsuggestions/SyncListSuggestions.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_listsuggestions_sync] +import com.google.cloud.dialogflow.v2beta1.ListSuggestionsRequest; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.Suggestion; + +public class SyncListSuggestions { + + public static void main(String[] args) throws Exception { + syncListSuggestions(); + } + + public static void syncListSuggestions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ListSuggestionsRequest request = + ListSuggestionsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Suggestion element : participantsClient.listSuggestions(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_listsuggestions_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/streaminganalyzecontent/AsyncStreamingAnalyzeContent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/streaminganalyzecontent/AsyncStreamingAnalyzeContent.java new file mode 100644 index 000000000000..ac4deea3ecc5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/streaminganalyzecontent/AsyncStreamingAnalyzeContent.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_streaminganalyzecontent_async] +import com.google.api.gax.rpc.BidiStream; +import com.google.cloud.dialogflow.v2beta1.AssistQueryParameters; +import com.google.cloud.dialogflow.v2beta1.OutputAudioConfig; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.QueryParameters; +import com.google.cloud.dialogflow.v2beta1.StreamingAnalyzeContentRequest; +import com.google.cloud.dialogflow.v2beta1.StreamingAnalyzeContentResponse; +import com.google.protobuf.Struct; + +public class AsyncStreamingAnalyzeContent { + + public static void main(String[] args) throws Exception { + asyncStreamingAnalyzeContent(); + } + + public static void asyncStreamingAnalyzeContent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + BidiStream bidiStream = + participantsClient.streamingAnalyzeContentCallable().call(); + StreamingAnalyzeContentRequest request = + StreamingAnalyzeContentRequest.newBuilder() + .setParticipant( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setReplyAudioConfig(OutputAudioConfig.newBuilder().build()) + .setQueryParams(QueryParameters.newBuilder().build()) + .setAssistQueryParams(AssistQueryParameters.newBuilder().build()) + .setCxParameters(Struct.newBuilder().build()) + .setEnablePartialAutomatedAgentReply(true) + .build(); + bidiStream.send(request); + for (StreamingAnalyzeContentResponse response : bidiStream) { + // Do something when a response is received. + } + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_streaminganalyzecontent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/AsyncSuggestArticles.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/AsyncSuggestArticles.java new file mode 100644 index 000000000000..2781b0fbdcb3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/AsyncSuggestArticles.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_suggestarticles_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AssistQueryParameters; +import com.google.cloud.dialogflow.v2beta1.MessageName; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.SuggestArticlesRequest; +import com.google.cloud.dialogflow.v2beta1.SuggestArticlesResponse; + +public class AsyncSuggestArticles { + + public static void main(String[] args) throws Exception { + asyncSuggestArticles(); + } + + public static void asyncSuggestArticles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + SuggestArticlesRequest request = + SuggestArticlesRequest.newBuilder() + .setParent( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .setAssistQueryParams(AssistQueryParameters.newBuilder().build()) + .build(); + ApiFuture future = + participantsClient.suggestArticlesCallable().futureCall(request); + // Do something. + SuggestArticlesResponse response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_suggestarticles_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/SyncSuggestArticles.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/SyncSuggestArticles.java new file mode 100644 index 000000000000..d0e1cc37bf20 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/SyncSuggestArticles.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_suggestarticles_sync] +import com.google.cloud.dialogflow.v2beta1.AssistQueryParameters; +import com.google.cloud.dialogflow.v2beta1.MessageName; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.SuggestArticlesRequest; +import com.google.cloud.dialogflow.v2beta1.SuggestArticlesResponse; + +public class SyncSuggestArticles { + + public static void main(String[] args) throws Exception { + syncSuggestArticles(); + } + + public static void syncSuggestArticles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + SuggestArticlesRequest request = + SuggestArticlesRequest.newBuilder() + .setParent( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .setAssistQueryParams(AssistQueryParameters.newBuilder().build()) + .build(); + SuggestArticlesResponse response = participantsClient.suggestArticles(request); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_suggestarticles_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/SyncSuggestArticlesParticipantname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/SyncSuggestArticlesParticipantname.java new file mode 100644 index 000000000000..352cc783ba5b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/SyncSuggestArticlesParticipantname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_suggestarticles_participantname_sync] +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.SuggestArticlesResponse; + +public class SyncSuggestArticlesParticipantname { + + public static void main(String[] args) throws Exception { + syncSuggestArticlesParticipantname(); + } + + public static void syncSuggestArticlesParticipantname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + SuggestArticlesResponse response = participantsClient.suggestArticles(parent); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_suggestarticles_participantname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/SyncSuggestArticlesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/SyncSuggestArticlesString.java new file mode 100644 index 000000000000..b90f3ddbd5b0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestarticles/SyncSuggestArticlesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_suggestarticles_string_sync] +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.SuggestArticlesResponse; + +public class SyncSuggestArticlesString { + + public static void main(String[] args) throws Exception { + syncSuggestArticlesString(); + } + + public static void syncSuggestArticlesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString(); + SuggestArticlesResponse response = participantsClient.suggestArticles(parent); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_suggestarticles_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/AsyncSuggestFaqAnswers.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/AsyncSuggestFaqAnswers.java new file mode 100644 index 000000000000..950f3fb4c34c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/AsyncSuggestFaqAnswers.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_suggestfaqanswers_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AssistQueryParameters; +import com.google.cloud.dialogflow.v2beta1.MessageName; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.SuggestFaqAnswersRequest; +import com.google.cloud.dialogflow.v2beta1.SuggestFaqAnswersResponse; + +public class AsyncSuggestFaqAnswers { + + public static void main(String[] args) throws Exception { + asyncSuggestFaqAnswers(); + } + + public static void asyncSuggestFaqAnswers() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + SuggestFaqAnswersRequest request = + SuggestFaqAnswersRequest.newBuilder() + .setParent( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .setAssistQueryParams(AssistQueryParameters.newBuilder().build()) + .build(); + ApiFuture future = + participantsClient.suggestFaqAnswersCallable().futureCall(request); + // Do something. + SuggestFaqAnswersResponse response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_suggestfaqanswers_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswers.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswers.java new file mode 100644 index 000000000000..2b6a0dbfef44 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswers.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_suggestfaqanswers_sync] +import com.google.cloud.dialogflow.v2beta1.AssistQueryParameters; +import com.google.cloud.dialogflow.v2beta1.MessageName; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.SuggestFaqAnswersRequest; +import com.google.cloud.dialogflow.v2beta1.SuggestFaqAnswersResponse; + +public class SyncSuggestFaqAnswers { + + public static void main(String[] args) throws Exception { + syncSuggestFaqAnswers(); + } + + public static void syncSuggestFaqAnswers() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + SuggestFaqAnswersRequest request = + SuggestFaqAnswersRequest.newBuilder() + .setParent( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .setAssistQueryParams(AssistQueryParameters.newBuilder().build()) + .build(); + SuggestFaqAnswersResponse response = participantsClient.suggestFaqAnswers(request); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_suggestfaqanswers_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersParticipantname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersParticipantname.java new file mode 100644 index 000000000000..f8cb23706c4a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersParticipantname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_suggestfaqanswers_participantname_sync] +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.SuggestFaqAnswersResponse; + +public class SyncSuggestFaqAnswersParticipantname { + + public static void main(String[] args) throws Exception { + syncSuggestFaqAnswersParticipantname(); + } + + public static void syncSuggestFaqAnswersParticipantname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + SuggestFaqAnswersResponse response = participantsClient.suggestFaqAnswers(parent); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_suggestfaqanswers_participantname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersString.java new file mode 100644 index 000000000000..14b4329ed79a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestfaqanswers/SyncSuggestFaqAnswersString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_suggestfaqanswers_string_sync] +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.SuggestFaqAnswersResponse; + +public class SyncSuggestFaqAnswersString { + + public static void main(String[] args) throws Exception { + syncSuggestFaqAnswersString(); + } + + public static void syncSuggestFaqAnswersString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString(); + SuggestFaqAnswersResponse response = participantsClient.suggestFaqAnswers(parent); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_suggestfaqanswers_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/AsyncSuggestSmartReplies.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/AsyncSuggestSmartReplies.java new file mode 100644 index 000000000000..07455f43dc9f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/AsyncSuggestSmartReplies.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_suggestsmartreplies_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.MessageName; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.SuggestSmartRepliesRequest; +import com.google.cloud.dialogflow.v2beta1.SuggestSmartRepliesResponse; +import com.google.cloud.dialogflow.v2beta1.TextInput; + +public class AsyncSuggestSmartReplies { + + public static void main(String[] args) throws Exception { + asyncSuggestSmartReplies(); + } + + public static void asyncSuggestSmartReplies() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + SuggestSmartRepliesRequest request = + SuggestSmartRepliesRequest.newBuilder() + .setParent( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setCurrentTextInput(TextInput.newBuilder().build()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .build(); + ApiFuture future = + participantsClient.suggestSmartRepliesCallable().futureCall(request); + // Do something. + SuggestSmartRepliesResponse response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_suggestsmartreplies_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/SyncSuggestSmartReplies.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/SyncSuggestSmartReplies.java new file mode 100644 index 000000000000..f2a91d350ea6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/SyncSuggestSmartReplies.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_suggestsmartreplies_sync] +import com.google.cloud.dialogflow.v2beta1.MessageName; +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.SuggestSmartRepliesRequest; +import com.google.cloud.dialogflow.v2beta1.SuggestSmartRepliesResponse; +import com.google.cloud.dialogflow.v2beta1.TextInput; + +public class SyncSuggestSmartReplies { + + public static void main(String[] args) throws Exception { + syncSuggestSmartReplies(); + } + + public static void syncSuggestSmartReplies() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + SuggestSmartRepliesRequest request = + SuggestSmartRepliesRequest.newBuilder() + .setParent( + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString()) + .setCurrentTextInput(TextInput.newBuilder().build()) + .setLatestMessage( + MessageName.ofProjectConversationMessageName( + "[PROJECT]", "[CONVERSATION]", "[MESSAGE]") + .toString()) + .setContextSize(1116903569) + .build(); + SuggestSmartRepliesResponse response = participantsClient.suggestSmartReplies(request); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_suggestsmartreplies_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesParticipantname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesParticipantname.java new file mode 100644 index 000000000000..ff45fea3f653 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesParticipantname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_suggestsmartreplies_participantname_sync] +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.SuggestSmartRepliesResponse; + +public class SyncSuggestSmartRepliesParticipantname { + + public static void main(String[] args) throws Exception { + syncSuggestSmartRepliesParticipantname(); + } + + public static void syncSuggestSmartRepliesParticipantname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + ParticipantName parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"); + SuggestSmartRepliesResponse response = participantsClient.suggestSmartReplies(parent); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_suggestsmartreplies_participantname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesString.java new file mode 100644 index 000000000000..8dfb4ac9f32f --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/suggestsmartreplies/SyncSuggestSmartRepliesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_suggestsmartreplies_string_sync] +import com.google.cloud.dialogflow.v2beta1.ParticipantName; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.SuggestSmartRepliesResponse; + +public class SyncSuggestSmartRepliesString { + + public static void main(String[] args) throws Exception { + syncSuggestSmartRepliesString(); + } + + public static void syncSuggestSmartRepliesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + String parent = + ParticipantName.ofProjectConversationParticipantName( + "[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]") + .toString(); + SuggestSmartRepliesResponse response = participantsClient.suggestSmartReplies(parent); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_suggestsmartreplies_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/updateparticipant/AsyncUpdateParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/updateparticipant/AsyncUpdateParticipant.java new file mode 100644 index 000000000000..cbd8a1f475cf --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/updateparticipant/AsyncUpdateParticipant.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_updateparticipant_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateParticipantRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateParticipant { + + public static void main(String[] args) throws Exception { + asyncUpdateParticipant(); + } + + public static void asyncUpdateParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + UpdateParticipantRequest request = + UpdateParticipantRequest.newBuilder() + .setParticipant(Participant.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + participantsClient.updateParticipantCallable().futureCall(request); + // Do something. + Participant response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_updateparticipant_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/updateparticipant/SyncUpdateParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/updateparticipant/SyncUpdateParticipant.java new file mode 100644 index 000000000000..a508b997143e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/updateparticipant/SyncUpdateParticipant.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantsclient_updateparticipant_sync] +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.cloud.dialogflow.v2beta1.UpdateParticipantRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateParticipant { + + public static void main(String[] args) throws Exception { + syncUpdateParticipant(); + } + + public static void syncUpdateParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + UpdateParticipantRequest request = + UpdateParticipantRequest.newBuilder() + .setParticipant(Participant.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Participant response = participantsClient.updateParticipant(request); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_updateparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/updateparticipant/SyncUpdateParticipantParticipantFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/updateparticipant/SyncUpdateParticipantParticipantFieldmask.java new file mode 100644 index 000000000000..95c0753770ab --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantsclient/updateparticipant/SyncUpdateParticipantParticipantFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_participantsclient_updateparticipant_participantfieldmask_sync] +import com.google.cloud.dialogflow.v2beta1.Participant; +import com.google.cloud.dialogflow.v2beta1.ParticipantsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateParticipantParticipantFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateParticipantParticipantFieldmask(); + } + + public static void syncUpdateParticipantParticipantFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ParticipantsClient participantsClient = ParticipantsClient.create()) { + Participant participant = Participant.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Participant response = participantsClient.updateParticipant(participant, updateMask); + } + } +} +// [END dialogflow_v2beta1_generated_participantsclient_updateparticipant_participantfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantssettings/createparticipant/SyncCreateParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantssettings/createparticipant/SyncCreateParticipant.java new file mode 100644 index 000000000000..7c4789e022be --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/participantssettings/createparticipant/SyncCreateParticipant.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_participantssettings_createparticipant_sync] +import com.google.cloud.dialogflow.v2beta1.ParticipantsSettings; +import java.time.Duration; + +public class SyncCreateParticipant { + + public static void main(String[] args) throws Exception { + syncCreateParticipant(); + } + + public static void syncCreateParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ParticipantsSettings.Builder participantsSettingsBuilder = ParticipantsSettings.newBuilder(); + participantsSettingsBuilder + .createParticipantSettings() + .setRetrySettings( + participantsSettingsBuilder + .createParticipantSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ParticipantsSettings participantsSettings = participantsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_participantssettings_createparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..40f49f156548 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionEntityTypesSettings sessionEntityTypesSettings = + SessionEntityTypesSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + SessionEntityTypesClient sessionEntityTypesClient = + SessionEntityTypesClient.create(sessionEntityTypesSettings); + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..b94478cfd233 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionEntityTypesSettings sessionEntityTypesSettings = + SessionEntityTypesSettings.newBuilder() + .setTransportChannelProvider( + SessionEntityTypesSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + SessionEntityTypesClient sessionEntityTypesClient = + SessionEntityTypesClient.create(sessionEntityTypesSettings); + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..51b5ee744194 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionEntityTypesSettings sessionEntityTypesSettings = + SessionEntityTypesSettings.newBuilder().setEndpoint(myEndpoint).build(); + SessionEntityTypesClient sessionEntityTypesClient = + SessionEntityTypesClient.create(sessionEntityTypesSettings); + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/AsyncCreateSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/AsyncCreateSessionEntityType.java new file mode 100644 index 000000000000..2add8fd551cd --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/AsyncCreateSessionEntityType.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_createsessionentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.CreateSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class AsyncCreateSessionEntityType { + + public static void main(String[] args) throws Exception { + asyncCreateSessionEntityType(); + } + + public static void asyncCreateSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + CreateSessionEntityTypeRequest request = + CreateSessionEntityTypeRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setSessionEntityType(SessionEntityType.newBuilder().build()) + .build(); + ApiFuture future = + sessionEntityTypesClient.createSessionEntityTypeCallable().futureCall(request); + // Do something. + SessionEntityType response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_createsessionentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityType.java new file mode 100644 index 000000000000..b1060a0be83e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityType.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_createsessionentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.CreateSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncCreateSessionEntityType { + + public static void main(String[] args) throws Exception { + syncCreateSessionEntityType(); + } + + public static void syncCreateSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + CreateSessionEntityTypeRequest request = + CreateSessionEntityTypeRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setSessionEntityType(SessionEntityType.newBuilder().build()) + .build(); + SessionEntityType response = sessionEntityTypesClient.createSessionEntityType(request); + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_createsessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeSessionnameSessionentitytype.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeSessionnameSessionentitytype.java new file mode 100644 index 000000000000..320d1441d538 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeSessionnameSessionentitytype.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_sessionentitytypesclient_createsessionentitytype_sessionnamesessionentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncCreateSessionEntityTypeSessionnameSessionentitytype { + + public static void main(String[] args) throws Exception { + syncCreateSessionEntityTypeSessionnameSessionentitytype(); + } + + public static void syncCreateSessionEntityTypeSessionnameSessionentitytype() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + SessionEntityType response = + sessionEntityTypesClient.createSessionEntityType(parent, sessionEntityType); + } + } +} +// [END +// dialogflow_v2beta1_generated_sessionentitytypesclient_createsessionentitytype_sessionnamesessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeStringSessionentitytype.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeStringSessionentitytype.java new file mode 100644 index 000000000000..4c75daae19b3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/createsessionentitytype/SyncCreateSessionEntityTypeStringSessionentitytype.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_sessionentitytypesclient_createsessionentitytype_stringsessionentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncCreateSessionEntityTypeStringSessionentitytype { + + public static void main(String[] args) throws Exception { + syncCreateSessionEntityTypeStringSessionentitytype(); + } + + public static void syncCreateSessionEntityTypeStringSessionentitytype() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + String parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString(); + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + SessionEntityType response = + sessionEntityTypesClient.createSessionEntityType(parent, sessionEntityType); + } + } +} +// [END +// dialogflow_v2beta1_generated_sessionentitytypesclient_createsessionentitytype_stringsessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/AsyncDeleteSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/AsyncDeleteSessionEntityType.java new file mode 100644 index 000000000000..f5b8d042dec2 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/AsyncDeleteSessionEntityType.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_deletesessionentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.DeleteSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteSessionEntityType { + + public static void main(String[] args) throws Exception { + asyncDeleteSessionEntityType(); + } + + public static void asyncDeleteSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + DeleteSessionEntityTypeRequest request = + DeleteSessionEntityTypeRequest.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .build(); + ApiFuture future = + sessionEntityTypesClient.deleteSessionEntityTypeCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_deletesessionentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityType.java new file mode 100644 index 000000000000..c56c974b55cc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityType.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_deletesessionentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.DeleteSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; + +public class SyncDeleteSessionEntityType { + + public static void main(String[] args) throws Exception { + syncDeleteSessionEntityType(); + } + + public static void syncDeleteSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + DeleteSessionEntityTypeRequest request = + DeleteSessionEntityTypeRequest.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .build(); + sessionEntityTypesClient.deleteSessionEntityType(request); + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_deletesessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeSessionentitytypename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeSessionentitytypename.java new file mode 100644 index 000000000000..a587b2645848 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeSessionentitytypename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_sessionentitytypesclient_deletesessionentitytype_sessionentitytypename_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; + +public class SyncDeleteSessionEntityTypeSessionentitytypename { + + public static void main(String[] args) throws Exception { + syncDeleteSessionEntityTypeSessionentitytypename(); + } + + public static void syncDeleteSessionEntityTypeSessionentitytypename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + SessionEntityTypeName name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + sessionEntityTypesClient.deleteSessionEntityType(name); + } + } +} +// [END +// dialogflow_v2beta1_generated_sessionentitytypesclient_deletesessionentitytype_sessionentitytypename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeString.java new file mode 100644 index 000000000000..2b3c414f7b4a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/deletesessionentitytype/SyncDeleteSessionEntityTypeString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_deletesessionentitytype_string_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; + +public class SyncDeleteSessionEntityTypeString { + + public static void main(String[] args) throws Exception { + syncDeleteSessionEntityTypeString(); + } + + public static void syncDeleteSessionEntityTypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + String name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString(); + sessionEntityTypesClient.deleteSessionEntityType(name); + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_deletesessionentitytype_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/AsyncGetSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/AsyncGetSessionEntityType.java new file mode 100644 index 000000000000..c8d472bf1200 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/AsyncGetSessionEntityType.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_getsessionentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.GetSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; + +public class AsyncGetSessionEntityType { + + public static void main(String[] args) throws Exception { + asyncGetSessionEntityType(); + } + + public static void asyncGetSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + GetSessionEntityTypeRequest request = + GetSessionEntityTypeRequest.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .build(); + ApiFuture future = + sessionEntityTypesClient.getSessionEntityTypeCallable().futureCall(request); + // Do something. + SessionEntityType response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_getsessionentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityType.java new file mode 100644 index 000000000000..02546eca67ba --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityType.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_getsessionentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.GetSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; + +public class SyncGetSessionEntityType { + + public static void main(String[] args) throws Exception { + syncGetSessionEntityType(); + } + + public static void syncGetSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + GetSessionEntityTypeRequest request = + GetSessionEntityTypeRequest.newBuilder() + .setName( + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString()) + .build(); + SessionEntityType response = sessionEntityTypesClient.getSessionEntityType(request); + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_getsessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeSessionentitytypename.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeSessionentitytypename.java new file mode 100644 index 000000000000..00f0227a2378 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeSessionentitytypename.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_sessionentitytypesclient_getsessionentitytype_sessionentitytypename_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; + +public class SyncGetSessionEntityTypeSessionentitytypename { + + public static void main(String[] args) throws Exception { + syncGetSessionEntityTypeSessionentitytypename(); + } + + public static void syncGetSessionEntityTypeSessionentitytypename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + SessionEntityTypeName name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + SessionEntityType response = sessionEntityTypesClient.getSessionEntityType(name); + } + } +} +// [END +// dialogflow_v2beta1_generated_sessionentitytypesclient_getsessionentitytype_sessionentitytypename_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeString.java new file mode 100644 index 000000000000..2d38e0fa3fcc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/getsessionentitytype/SyncGetSessionEntityTypeString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_getsessionentitytype_string_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypeName; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; + +public class SyncGetSessionEntityTypeString { + + public static void main(String[] args) throws Exception { + syncGetSessionEntityTypeString(); + } + + public static void syncGetSessionEntityTypeString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + String name = + SessionEntityTypeName.ofProjectSessionEntityTypeName( + "[PROJECT]", "[SESSION]", "[ENTITY_TYPE]") + .toString(); + SessionEntityType response = sessionEntityTypesClient.getSessionEntityType(name); + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_getsessionentitytype_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypes.java new file mode 100644 index 000000000000..b9f17da8c53b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypes.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_listsessionentitytypes_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.ListSessionEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class AsyncListSessionEntityTypes { + + public static void main(String[] args) throws Exception { + asyncListSessionEntityTypes(); + } + + public static void asyncListSessionEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + ListSessionEntityTypesRequest request = + ListSessionEntityTypesRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + sessionEntityTypesClient.listSessionEntityTypesPagedCallable().futureCall(request); + // Do something. + for (SessionEntityType element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_listsessionentitytypes_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypesPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypesPaged.java new file mode 100644 index 000000000000..546df4b1ef47 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/AsyncListSessionEntityTypesPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_listsessionentitytypes_paged_async] +import com.google.cloud.dialogflow.v2beta1.ListSessionEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.ListSessionEntityTypesResponse; +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; +import com.google.common.base.Strings; + +public class AsyncListSessionEntityTypesPaged { + + public static void main(String[] args) throws Exception { + asyncListSessionEntityTypesPaged(); + } + + public static void asyncListSessionEntityTypesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + ListSessionEntityTypesRequest request = + ListSessionEntityTypesRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .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; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_listsessionentitytypes_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypes.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypes.java new file mode 100644 index 000000000000..a0be7287b1ca --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypes.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_listsessionentitytypes_sync] +import com.google.cloud.dialogflow.v2beta1.ListSessionEntityTypesRequest; +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncListSessionEntityTypes { + + public static void main(String[] args) throws Exception { + syncListSessionEntityTypes(); + } + + public static void syncListSessionEntityTypes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + ListSessionEntityTypesRequest request = + ListSessionEntityTypesRequest.newBuilder() + .setParent(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (SessionEntityType element : + sessionEntityTypesClient.listSessionEntityTypes(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_listsessionentitytypes_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesSessionname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesSessionname.java new file mode 100644 index 000000000000..27045b30fb41 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesSessionname.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_sessionentitytypesclient_listsessionentitytypes_sessionname_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncListSessionEntityTypesSessionname { + + public static void main(String[] args) throws Exception { + syncListSessionEntityTypesSessionname(); + } + + public static void syncListSessionEntityTypesSessionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + for (SessionEntityType element : + sessionEntityTypesClient.listSessionEntityTypes(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// dialogflow_v2beta1_generated_sessionentitytypesclient_listsessionentitytypes_sessionname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesString.java new file mode 100644 index 000000000000..2dd928d24485 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/listsessionentitytypes/SyncListSessionEntityTypesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_listsessionentitytypes_string_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.SessionName; + +public class SyncListSessionEntityTypesString { + + public static void main(String[] args) throws Exception { + syncListSessionEntityTypesString(); + } + + public static void syncListSessionEntityTypesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + String parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString(); + for (SessionEntityType element : + sessionEntityTypesClient.listSessionEntityTypes(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_listsessionentitytypes_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/AsyncUpdateSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/AsyncUpdateSessionEntityType.java new file mode 100644 index 000000000000..c7e6ba392cf7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/AsyncUpdateSessionEntityType.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_updatesessionentitytype_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.UpdateSessionEntityTypeRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateSessionEntityType { + + public static void main(String[] args) throws Exception { + asyncUpdateSessionEntityType(); + } + + public static void asyncUpdateSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + UpdateSessionEntityTypeRequest request = + UpdateSessionEntityTypeRequest.newBuilder() + .setSessionEntityType(SessionEntityType.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + sessionEntityTypesClient.updateSessionEntityTypeCallable().futureCall(request); + // Do something. + SessionEntityType response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_updatesessionentitytype_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityType.java new file mode 100644 index 000000000000..95f53a203c3a --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityType.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesclient_updatesessionentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.cloud.dialogflow.v2beta1.UpdateSessionEntityTypeRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateSessionEntityType { + + public static void main(String[] args) throws Exception { + syncUpdateSessionEntityType(); + } + + public static void syncUpdateSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + UpdateSessionEntityTypeRequest request = + UpdateSessionEntityTypeRequest.newBuilder() + .setSessionEntityType(SessionEntityType.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + SessionEntityType response = sessionEntityTypesClient.updateSessionEntityType(request); + } + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesclient_updatesessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytype.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytype.java new file mode 100644 index 000000000000..dbc7799a437b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytype.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_sessionentitytypesclient_updatesessionentitytype_sessionentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; + +public class SyncUpdateSessionEntityTypeSessionentitytype { + + public static void main(String[] args) throws Exception { + syncUpdateSessionEntityTypeSessionentitytype(); + } + + public static void syncUpdateSessionEntityTypeSessionentitytype() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + SessionEntityType response = + sessionEntityTypesClient.updateSessionEntityType(sessionEntityType); + } + } +} +// [END +// dialogflow_v2beta1_generated_sessionentitytypesclient_updatesessionentitytype_sessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytypeFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytypeFieldmask.java new file mode 100644 index 000000000000..a1add7efe306 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypesclient/updatesessionentitytype/SyncUpdateSessionEntityTypeSessionentitytypeFieldmask.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START +// dialogflow_v2beta1_generated_sessionentitytypesclient_updatesessionentitytype_sessionentitytypefieldmask_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityType; +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateSessionEntityTypeSessionentitytypeFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateSessionEntityTypeSessionentitytypeFieldmask(); + } + + public static void syncUpdateSessionEntityTypeSessionentitytypeFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) { + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + SessionEntityType response = + sessionEntityTypesClient.updateSessionEntityType(sessionEntityType, updateMask); + } + } +} +// [END +// dialogflow_v2beta1_generated_sessionentitytypesclient_updatesessionentitytype_sessionentitytypefieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypessettings/getsessionentitytype/SyncGetSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypessettings/getsessionentitytype/SyncGetSessionEntityType.java new file mode 100644 index 000000000000..8d1ddea02891 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionentitytypessettings/getsessionentitytype/SyncGetSessionEntityType.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypessettings_getsessionentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.SessionEntityTypesSettings; +import java.time.Duration; + +public class SyncGetSessionEntityType { + + public static void main(String[] args) throws Exception { + syncGetSessionEntityType(); + } + + public static void syncGetSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionEntityTypesSettings.Builder sessionEntityTypesSettingsBuilder = + SessionEntityTypesSettings.newBuilder(); + sessionEntityTypesSettingsBuilder + .getSessionEntityTypeSettings() + .setRetrySettings( + sessionEntityTypesSettingsBuilder + .getSessionEntityTypeSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SessionEntityTypesSettings sessionEntityTypesSettings = + sessionEntityTypesSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypessettings_getsessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..9be75cc07e17 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.SessionsClient; +import com.google.cloud.dialogflow.v2beta1.SessionsSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionsSettings sessionsSettings = + SessionsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + SessionsClient sessionsClient = SessionsClient.create(sessionsSettings); + } +} +// [END dialogflow_v2beta1_generated_sessionsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..a842b11ce04d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.SessionsClient; +import com.google.cloud.dialogflow.v2beta1.SessionsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionsSettings sessionsSettings = + SessionsSettings.newBuilder() + .setTransportChannelProvider( + SessionsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + SessionsClient sessionsClient = SessionsClient.create(sessionsSettings); + } +} +// [END dialogflow_v2beta1_generated_sessionsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..41bbd8b565ea --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.SessionsClient; +import com.google.cloud.dialogflow.v2beta1.SessionsSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionsSettings sessionsSettings = + SessionsSettings.newBuilder().setEndpoint(myEndpoint).build(); + SessionsClient sessionsClient = SessionsClient.create(sessionsSettings); + } +} +// [END dialogflow_v2beta1_generated_sessionsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/AsyncDetectIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/AsyncDetectIntent.java new file mode 100644 index 000000000000..234693a78699 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/AsyncDetectIntent.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionsclient_detectintent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.DetectIntentRequest; +import com.google.cloud.dialogflow.v2beta1.DetectIntentResponse; +import com.google.cloud.dialogflow.v2beta1.OutputAudioConfig; +import com.google.cloud.dialogflow.v2beta1.QueryInput; +import com.google.cloud.dialogflow.v2beta1.QueryParameters; +import com.google.cloud.dialogflow.v2beta1.SessionName; +import com.google.cloud.dialogflow.v2beta1.SessionsClient; +import com.google.protobuf.ByteString; +import com.google.protobuf.FieldMask; + +public class AsyncDetectIntent { + + public static void main(String[] args) throws Exception { + asyncDetectIntent(); + } + + public static void asyncDetectIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionsClient sessionsClient = SessionsClient.create()) { + DetectIntentRequest request = + DetectIntentRequest.newBuilder() + .setSession(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setQueryParams(QueryParameters.newBuilder().build()) + .setQueryInput(QueryInput.newBuilder().build()) + .setOutputAudioConfig(OutputAudioConfig.newBuilder().build()) + .setOutputAudioConfigMask(FieldMask.newBuilder().build()) + .setInputAudio(ByteString.EMPTY) + .build(); + ApiFuture future = + sessionsClient.detectIntentCallable().futureCall(request); + // Do something. + DetectIntentResponse response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_sessionsclient_detectintent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/SyncDetectIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/SyncDetectIntent.java new file mode 100644 index 000000000000..9385bd8d3dff --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/SyncDetectIntent.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionsclient_detectintent_sync] +import com.google.cloud.dialogflow.v2beta1.DetectIntentRequest; +import com.google.cloud.dialogflow.v2beta1.DetectIntentResponse; +import com.google.cloud.dialogflow.v2beta1.OutputAudioConfig; +import com.google.cloud.dialogflow.v2beta1.QueryInput; +import com.google.cloud.dialogflow.v2beta1.QueryParameters; +import com.google.cloud.dialogflow.v2beta1.SessionName; +import com.google.cloud.dialogflow.v2beta1.SessionsClient; +import com.google.protobuf.ByteString; +import com.google.protobuf.FieldMask; + +public class SyncDetectIntent { + + public static void main(String[] args) throws Exception { + syncDetectIntent(); + } + + public static void syncDetectIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionsClient sessionsClient = SessionsClient.create()) { + DetectIntentRequest request = + DetectIntentRequest.newBuilder() + .setSession(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setQueryParams(QueryParameters.newBuilder().build()) + .setQueryInput(QueryInput.newBuilder().build()) + .setOutputAudioConfig(OutputAudioConfig.newBuilder().build()) + .setOutputAudioConfigMask(FieldMask.newBuilder().build()) + .setInputAudio(ByteString.EMPTY) + .build(); + DetectIntentResponse response = sessionsClient.detectIntent(request); + } + } +} +// [END dialogflow_v2beta1_generated_sessionsclient_detectintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/SyncDetectIntentSessionnameQueryinput.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/SyncDetectIntentSessionnameQueryinput.java new file mode 100644 index 000000000000..c99f07dac53c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/SyncDetectIntentSessionnameQueryinput.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionsclient_detectintent_sessionnamequeryinput_sync] +import com.google.cloud.dialogflow.v2beta1.DetectIntentResponse; +import com.google.cloud.dialogflow.v2beta1.QueryInput; +import com.google.cloud.dialogflow.v2beta1.SessionName; +import com.google.cloud.dialogflow.v2beta1.SessionsClient; + +public class SyncDetectIntentSessionnameQueryinput { + + public static void main(String[] args) throws Exception { + syncDetectIntentSessionnameQueryinput(); + } + + public static void syncDetectIntentSessionnameQueryinput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionsClient sessionsClient = SessionsClient.create()) { + SessionName session = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]"); + QueryInput queryInput = QueryInput.newBuilder().build(); + DetectIntentResponse response = sessionsClient.detectIntent(session, queryInput); + } + } +} +// [END dialogflow_v2beta1_generated_sessionsclient_detectintent_sessionnamequeryinput_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/SyncDetectIntentStringQueryinput.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/SyncDetectIntentStringQueryinput.java new file mode 100644 index 000000000000..2b429aa0522e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/detectintent/SyncDetectIntentStringQueryinput.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionsclient_detectintent_stringqueryinput_sync] +import com.google.cloud.dialogflow.v2beta1.DetectIntentResponse; +import com.google.cloud.dialogflow.v2beta1.QueryInput; +import com.google.cloud.dialogflow.v2beta1.SessionName; +import com.google.cloud.dialogflow.v2beta1.SessionsClient; + +public class SyncDetectIntentStringQueryinput { + + public static void main(String[] args) throws Exception { + syncDetectIntentStringQueryinput(); + } + + public static void syncDetectIntentStringQueryinput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionsClient sessionsClient = SessionsClient.create()) { + String session = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString(); + QueryInput queryInput = QueryInput.newBuilder().build(); + DetectIntentResponse response = sessionsClient.detectIntent(session, queryInput); + } + } +} +// [END dialogflow_v2beta1_generated_sessionsclient_detectintent_stringqueryinput_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/streamingdetectintent/AsyncStreamingDetectIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/streamingdetectintent/AsyncStreamingDetectIntent.java new file mode 100644 index 000000000000..a20618fa72e7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionsclient/streamingdetectintent/AsyncStreamingDetectIntent.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionsclient_streamingdetectintent_async] +import com.google.api.gax.rpc.BidiStream; +import com.google.cloud.dialogflow.v2beta1.OutputAudioConfig; +import com.google.cloud.dialogflow.v2beta1.QueryInput; +import com.google.cloud.dialogflow.v2beta1.QueryParameters; +import com.google.cloud.dialogflow.v2beta1.SessionName; +import com.google.cloud.dialogflow.v2beta1.SessionsClient; +import com.google.cloud.dialogflow.v2beta1.StreamingDetectIntentRequest; +import com.google.cloud.dialogflow.v2beta1.StreamingDetectIntentResponse; +import com.google.protobuf.ByteString; +import com.google.protobuf.FieldMask; + +public class AsyncStreamingDetectIntent { + + public static void main(String[] args) throws Exception { + asyncStreamingDetectIntent(); + } + + public static void asyncStreamingDetectIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SessionsClient sessionsClient = SessionsClient.create()) { + BidiStream bidiStream = + sessionsClient.streamingDetectIntentCallable().call(); + StreamingDetectIntentRequest request = + StreamingDetectIntentRequest.newBuilder() + .setSession(SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]").toString()) + .setQueryParams(QueryParameters.newBuilder().build()) + .setQueryInput(QueryInput.newBuilder().build()) + .setSingleUtterance(true) + .setOutputAudioConfig(OutputAudioConfig.newBuilder().build()) + .setOutputAudioConfigMask(FieldMask.newBuilder().build()) + .setInputAudio(ByteString.EMPTY) + .build(); + bidiStream.send(request); + for (StreamingDetectIntentResponse response : bidiStream) { + // Do something when a response is received. + } + } + } +} +// [END dialogflow_v2beta1_generated_sessionsclient_streamingdetectintent_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionssettings/detectintent/SyncDetectIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionssettings/detectintent/SyncDetectIntent.java new file mode 100644 index 000000000000..abd639d3d8e7 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/sessionssettings/detectintent/SyncDetectIntent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_sessionssettings_detectintent_sync] +import com.google.cloud.dialogflow.v2beta1.SessionsSettings; +import java.time.Duration; + +public class SyncDetectIntent { + + public static void main(String[] args) throws Exception { + syncDetectIntent(); + } + + public static void syncDetectIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionsSettings.Builder sessionsSettingsBuilder = SessionsSettings.newBuilder(); + sessionsSettingsBuilder + .detectIntentSettings() + .setRetrySettings( + sessionsSettingsBuilder + .detectIntentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SessionsSettings sessionsSettings = sessionsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_sessionssettings_detectintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/agentsstubsettings/getagent/SyncGetAgent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/agentsstubsettings/getagent/SyncGetAgent.java new file mode 100644 index 000000000000..b713af209d69 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/agentsstubsettings/getagent/SyncGetAgent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_agentsstubsettings_getagent_sync] +import com.google.cloud.dialogflow.v2beta1.stub.AgentsStubSettings; +import java.time.Duration; + +public class SyncGetAgent { + + public static void main(String[] args) throws Exception { + syncGetAgent(); + } + + public static void syncGetAgent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AgentsStubSettings.Builder agentsSettingsBuilder = AgentsStubSettings.newBuilder(); + agentsSettingsBuilder + .getAgentSettings() + .setRetrySettings( + agentsSettingsBuilder + .getAgentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + AgentsStubSettings agentsSettings = agentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_agentsstubsettings_getagent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/answerrecordsstubsettings/getanswerrecord/SyncGetAnswerRecord.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/answerrecordsstubsettings/getanswerrecord/SyncGetAnswerRecord.java new file mode 100644 index 000000000000..3f48e135f30d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/answerrecordsstubsettings/getanswerrecord/SyncGetAnswerRecord.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_answerrecordsstubsettings_getanswerrecord_sync] +import com.google.cloud.dialogflow.v2beta1.stub.AnswerRecordsStubSettings; +import java.time.Duration; + +public class SyncGetAnswerRecord { + + public static void main(String[] args) throws Exception { + syncGetAnswerRecord(); + } + + public static void syncGetAnswerRecord() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + AnswerRecordsStubSettings.Builder answerRecordsSettingsBuilder = + AnswerRecordsStubSettings.newBuilder(); + answerRecordsSettingsBuilder + .getAnswerRecordSettings() + .setRetrySettings( + answerRecordsSettingsBuilder + .getAnswerRecordSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + AnswerRecordsStubSettings answerRecordsSettings = answerRecordsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_answerrecordsstubsettings_getanswerrecord_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/contextsstubsettings/getcontext/SyncGetContext.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/contextsstubsettings/getcontext/SyncGetContext.java new file mode 100644 index 000000000000..c4011a7bfbe9 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/contextsstubsettings/getcontext/SyncGetContext.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_contextsstubsettings_getcontext_sync] +import com.google.cloud.dialogflow.v2beta1.stub.ContextsStubSettings; +import java.time.Duration; + +public class SyncGetContext { + + public static void main(String[] args) throws Exception { + syncGetContext(); + } + + public static void syncGetContext() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ContextsStubSettings.Builder contextsSettingsBuilder = ContextsStubSettings.newBuilder(); + contextsSettingsBuilder + .getContextSettings() + .setRetrySettings( + contextsSettingsBuilder + .getContextSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ContextsStubSettings contextsSettings = contextsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_contextsstubsettings_getcontext_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/conversationprofilesstubsettings/getconversationprofile/SyncGetConversationProfile.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/conversationprofilesstubsettings/getconversationprofile/SyncGetConversationProfile.java new file mode 100644 index 000000000000..4b6e1cda79c3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/conversationprofilesstubsettings/getconversationprofile/SyncGetConversationProfile.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_conversationprofilesstubsettings_getconversationprofile_sync] +import com.google.cloud.dialogflow.v2beta1.stub.ConversationProfilesStubSettings; +import java.time.Duration; + +public class SyncGetConversationProfile { + + public static void main(String[] args) throws Exception { + syncGetConversationProfile(); + } + + public static void syncGetConversationProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationProfilesStubSettings.Builder conversationProfilesSettingsBuilder = + ConversationProfilesStubSettings.newBuilder(); + conversationProfilesSettingsBuilder + .getConversationProfileSettings() + .setRetrySettings( + conversationProfilesSettingsBuilder + .getConversationProfileSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConversationProfilesStubSettings conversationProfilesSettings = + conversationProfilesSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_conversationprofilesstubsettings_getconversationprofile_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/conversationsstubsettings/createconversation/SyncCreateConversation.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/conversationsstubsettings/createconversation/SyncCreateConversation.java new file mode 100644 index 000000000000..1cd40812ae8d --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/conversationsstubsettings/createconversation/SyncCreateConversation.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_conversationsstubsettings_createconversation_sync] +import com.google.cloud.dialogflow.v2beta1.stub.ConversationsStubSettings; +import java.time.Duration; + +public class SyncCreateConversation { + + public static void main(String[] args) throws Exception { + syncCreateConversation(); + } + + public static void syncCreateConversation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ConversationsStubSettings.Builder conversationsSettingsBuilder = + ConversationsStubSettings.newBuilder(); + conversationsSettingsBuilder + .createConversationSettings() + .setRetrySettings( + conversationsSettingsBuilder + .createConversationSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConversationsStubSettings conversationsSettings = conversationsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_conversationsstubsettings_createconversation_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/documentsstubsettings/getdocument/SyncGetDocument.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/documentsstubsettings/getdocument/SyncGetDocument.java new file mode 100644 index 000000000000..2b04bc33c5f0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/documentsstubsettings/getdocument/SyncGetDocument.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_documentsstubsettings_getdocument_sync] +import com.google.cloud.dialogflow.v2beta1.stub.DocumentsStubSettings; +import java.time.Duration; + +public class SyncGetDocument { + + public static void main(String[] args) throws Exception { + syncGetDocument(); + } + + public static void syncGetDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DocumentsStubSettings.Builder documentsSettingsBuilder = DocumentsStubSettings.newBuilder(); + documentsSettingsBuilder + .getDocumentSettings() + .setRetrySettings( + documentsSettingsBuilder + .getDocumentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DocumentsStubSettings documentsSettings = documentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_documentsstubsettings_getdocument_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/entitytypesstubsettings/getentitytype/SyncGetEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/entitytypesstubsettings/getentitytype/SyncGetEntityType.java new file mode 100644 index 000000000000..77d4fd96a13c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/entitytypesstubsettings/getentitytype/SyncGetEntityType.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_entitytypesstubsettings_getentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.stub.EntityTypesStubSettings; +import java.time.Duration; + +public class SyncGetEntityType { + + public static void main(String[] args) throws Exception { + syncGetEntityType(); + } + + public static void syncGetEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EntityTypesStubSettings.Builder entityTypesSettingsBuilder = + EntityTypesStubSettings.newBuilder(); + entityTypesSettingsBuilder + .getEntityTypeSettings() + .setRetrySettings( + entityTypesSettingsBuilder + .getEntityTypeSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + EntityTypesStubSettings entityTypesSettings = entityTypesSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_entitytypesstubsettings_getentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.java new file mode 100644 index 000000000000..3c4b83cf8856 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_environmentsstubsettings_getenvironment_sync] +import com.google.cloud.dialogflow.v2beta1.stub.EnvironmentsStubSettings; +import java.time.Duration; + +public class SyncGetEnvironment { + + public static void main(String[] args) throws Exception { + syncGetEnvironment(); + } + + public static void syncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsStubSettings.Builder environmentsSettingsBuilder = + EnvironmentsStubSettings.newBuilder(); + environmentsSettingsBuilder + .getEnvironmentSettings() + .setRetrySettings( + environmentsSettingsBuilder + .getEnvironmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + EnvironmentsStubSettings environmentsSettings = environmentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_environmentsstubsettings_getenvironment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/fulfillmentsstubsettings/getfulfillment/SyncGetFulfillment.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/fulfillmentsstubsettings/getfulfillment/SyncGetFulfillment.java new file mode 100644 index 000000000000..af2b7914cd28 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/fulfillmentsstubsettings/getfulfillment/SyncGetFulfillment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_fulfillmentsstubsettings_getfulfillment_sync] +import com.google.cloud.dialogflow.v2beta1.stub.FulfillmentsStubSettings; +import java.time.Duration; + +public class SyncGetFulfillment { + + public static void main(String[] args) throws Exception { + syncGetFulfillment(); + } + + public static void syncGetFulfillment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + FulfillmentsStubSettings.Builder fulfillmentsSettingsBuilder = + FulfillmentsStubSettings.newBuilder(); + fulfillmentsSettingsBuilder + .getFulfillmentSettings() + .setRetrySettings( + fulfillmentsSettingsBuilder + .getFulfillmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + FulfillmentsStubSettings fulfillmentsSettings = fulfillmentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_fulfillmentsstubsettings_getfulfillment_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/intentsstubsettings/getintent/SyncGetIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/intentsstubsettings/getintent/SyncGetIntent.java new file mode 100644 index 000000000000..ae2ebfc88e86 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/intentsstubsettings/getintent/SyncGetIntent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_intentsstubsettings_getintent_sync] +import com.google.cloud.dialogflow.v2beta1.stub.IntentsStubSettings; +import java.time.Duration; + +public class SyncGetIntent { + + public static void main(String[] args) throws Exception { + syncGetIntent(); + } + + public static void syncGetIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + IntentsStubSettings.Builder intentsSettingsBuilder = IntentsStubSettings.newBuilder(); + intentsSettingsBuilder + .getIntentSettings() + .setRetrySettings( + intentsSettingsBuilder + .getIntentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + IntentsStubSettings intentsSettings = intentsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_intentsstubsettings_getintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/knowledgebasesstubsettings/getknowledgebase/SyncGetKnowledgeBase.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/knowledgebasesstubsettings/getknowledgebase/SyncGetKnowledgeBase.java new file mode 100644 index 000000000000..6dd0cb918f49 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/knowledgebasesstubsettings/getknowledgebase/SyncGetKnowledgeBase.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_knowledgebasesstubsettings_getknowledgebase_sync] +import com.google.cloud.dialogflow.v2beta1.stub.KnowledgeBasesStubSettings; +import java.time.Duration; + +public class SyncGetKnowledgeBase { + + public static void main(String[] args) throws Exception { + syncGetKnowledgeBase(); + } + + public static void syncGetKnowledgeBase() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + KnowledgeBasesStubSettings.Builder knowledgeBasesSettingsBuilder = + KnowledgeBasesStubSettings.newBuilder(); + knowledgeBasesSettingsBuilder + .getKnowledgeBaseSettings() + .setRetrySettings( + knowledgeBasesSettingsBuilder + .getKnowledgeBaseSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + KnowledgeBasesStubSettings knowledgeBasesSettings = knowledgeBasesSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_knowledgebasesstubsettings_getknowledgebase_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/participantsstubsettings/createparticipant/SyncCreateParticipant.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/participantsstubsettings/createparticipant/SyncCreateParticipant.java new file mode 100644 index 000000000000..ece54de84696 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/participantsstubsettings/createparticipant/SyncCreateParticipant.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_participantsstubsettings_createparticipant_sync] +import com.google.cloud.dialogflow.v2beta1.stub.ParticipantsStubSettings; +import java.time.Duration; + +public class SyncCreateParticipant { + + public static void main(String[] args) throws Exception { + syncCreateParticipant(); + } + + public static void syncCreateParticipant() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ParticipantsStubSettings.Builder participantsSettingsBuilder = + ParticipantsStubSettings.newBuilder(); + participantsSettingsBuilder + .createParticipantSettings() + .setRetrySettings( + participantsSettingsBuilder + .createParticipantSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ParticipantsStubSettings participantsSettings = participantsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_participantsstubsettings_createparticipant_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/sessionentitytypesstubsettings/getsessionentitytype/SyncGetSessionEntityType.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/sessionentitytypesstubsettings/getsessionentitytype/SyncGetSessionEntityType.java new file mode 100644 index 000000000000..a939bb9889a3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/sessionentitytypesstubsettings/getsessionentitytype/SyncGetSessionEntityType.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_sessionentitytypesstubsettings_getsessionentitytype_sync] +import com.google.cloud.dialogflow.v2beta1.stub.SessionEntityTypesStubSettings; +import java.time.Duration; + +public class SyncGetSessionEntityType { + + public static void main(String[] args) throws Exception { + syncGetSessionEntityType(); + } + + public static void syncGetSessionEntityType() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionEntityTypesStubSettings.Builder sessionEntityTypesSettingsBuilder = + SessionEntityTypesStubSettings.newBuilder(); + sessionEntityTypesSettingsBuilder + .getSessionEntityTypeSettings() + .setRetrySettings( + sessionEntityTypesSettingsBuilder + .getSessionEntityTypeSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SessionEntityTypesStubSettings sessionEntityTypesSettings = + sessionEntityTypesSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_sessionentitytypesstubsettings_getsessionentitytype_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/sessionsstubsettings/detectintent/SyncDetectIntent.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/sessionsstubsettings/detectintent/SyncDetectIntent.java new file mode 100644 index 000000000000..2d418dc543dd --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/sessionsstubsettings/detectintent/SyncDetectIntent.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_sessionsstubsettings_detectintent_sync] +import com.google.cloud.dialogflow.v2beta1.stub.SessionsStubSettings; +import java.time.Duration; + +public class SyncDetectIntent { + + public static void main(String[] args) throws Exception { + syncDetectIntent(); + } + + public static void syncDetectIntent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SessionsStubSettings.Builder sessionsSettingsBuilder = SessionsStubSettings.newBuilder(); + sessionsSettingsBuilder + .detectIntentSettings() + .setRetrySettings( + sessionsSettingsBuilder + .detectIntentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SessionsStubSettings sessionsSettings = sessionsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_sessionsstubsettings_detectintent_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/versionsstubsettings/getversion/SyncGetVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/versionsstubsettings/getversion/SyncGetVersion.java new file mode 100644 index 000000000000..fd2bc0e3500c --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/stub/versionsstubsettings/getversion/SyncGetVersion.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.stub.samples; + +// [START dialogflow_v2beta1_generated_versionsstubsettings_getversion_sync] +import com.google.cloud.dialogflow.v2beta1.stub.VersionsStubSettings; +import java.time.Duration; + +public class SyncGetVersion { + + public static void main(String[] args) throws Exception { + syncGetVersion(); + } + + public static void syncGetVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VersionsStubSettings.Builder versionsSettingsBuilder = VersionsStubSettings.newBuilder(); + versionsSettingsBuilder + .getVersionSettings() + .setRetrySettings( + versionsSettingsBuilder + .getVersionSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VersionsStubSettings versionsSettings = versionsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_versionsstubsettings_getversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/create/SyncCreateSetCredentialsProvider.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..2f237e5842e0 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; +import com.google.cloud.dialogflow.v2beta1.VersionsSettings; +import com.google.cloud.dialogflow.v2beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VersionsSettings versionsSettings = + VersionsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + VersionsClient versionsClient = VersionsClient.create(versionsSettings); + } +} +// [END dialogflow_v2beta1_generated_versionsclient_create_setcredentialsprovider_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/create/SyncCreateSetCredentialsProvider1.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..5a5ba11566c6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.dialogflow.v2beta1.VersionsClient; +import com.google.cloud.dialogflow.v2beta1.VersionsSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VersionsSettings versionsSettings = + VersionsSettings.newBuilder() + .setTransportChannelProvider( + VersionsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + VersionsClient versionsClient = VersionsClient.create(versionsSettings); + } +} +// [END dialogflow_v2beta1_generated_versionsclient_create_setcredentialsprovider1_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/create/SyncCreateSetEndpoint.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..feef998512cc --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_create_setendpoint_sync] +import com.google.cloud.dialogflow.v2beta1.VersionsClient; +import com.google.cloud.dialogflow.v2beta1.VersionsSettings; +import com.google.cloud.dialogflow.v2beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VersionsSettings versionsSettings = + VersionsSettings.newBuilder().setEndpoint(myEndpoint).build(); + VersionsClient versionsClient = VersionsClient.create(versionsSettings); + } +} +// [END dialogflow_v2beta1_generated_versionsclient_create_setendpoint_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/AsyncCreateVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/AsyncCreateVersion.java new file mode 100644 index 000000000000..df15141b1d14 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/AsyncCreateVersion.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_createversion_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.CreateVersionRequest; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class AsyncCreateVersion { + + public static void main(String[] args) throws Exception { + asyncCreateVersion(); + } + + public static void asyncCreateVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + CreateVersionRequest request = + CreateVersionRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setVersion(Version.newBuilder().build()) + .build(); + ApiFuture future = versionsClient.createVersionCallable().futureCall(request); + // Do something. + Version response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_createversion_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/SyncCreateVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/SyncCreateVersion.java new file mode 100644 index 000000000000..f0b109ad9196 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/SyncCreateVersion.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_createversion_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.CreateVersionRequest; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class SyncCreateVersion { + + public static void main(String[] args) throws Exception { + syncCreateVersion(); + } + + public static void syncCreateVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + CreateVersionRequest request = + CreateVersionRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setVersion(Version.newBuilder().build()) + .build(); + Version response = versionsClient.createVersion(request); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_createversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/SyncCreateVersionAgentnameVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/SyncCreateVersionAgentnameVersion.java new file mode 100644 index 000000000000..f750152e27be --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/SyncCreateVersionAgentnameVersion.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_createversion_agentnameversion_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class SyncCreateVersionAgentnameVersion { + + public static void main(String[] args) throws Exception { + syncCreateVersionAgentnameVersion(); + } + + public static void syncCreateVersionAgentnameVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + Version version = Version.newBuilder().build(); + Version response = versionsClient.createVersion(parent, version); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_createversion_agentnameversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/SyncCreateVersionStringVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/SyncCreateVersionStringVersion.java new file mode 100644 index 000000000000..a3649b69b980 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/createversion/SyncCreateVersionStringVersion.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_createversion_stringversion_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class SyncCreateVersionStringVersion { + + public static void main(String[] args) throws Exception { + syncCreateVersionStringVersion(); + } + + public static void syncCreateVersionStringVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + Version version = Version.newBuilder().build(); + Version response = versionsClient.createVersion(parent, version); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_createversion_stringversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/AsyncDeleteVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/AsyncDeleteVersion.java new file mode 100644 index 000000000000..2bfdf3467af6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/AsyncDeleteVersion.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_deleteversion_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.DeleteVersionRequest; +import com.google.cloud.dialogflow.v2beta1.VersionName; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteVersion { + + public static void main(String[] args) throws Exception { + asyncDeleteVersion(); + } + + public static void asyncDeleteVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + DeleteVersionRequest request = + DeleteVersionRequest.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .build(); + ApiFuture future = versionsClient.deleteVersionCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_deleteversion_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/SyncDeleteVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/SyncDeleteVersion.java new file mode 100644 index 000000000000..799b8e063315 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/SyncDeleteVersion.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_deleteversion_sync] +import com.google.cloud.dialogflow.v2beta1.DeleteVersionRequest; +import com.google.cloud.dialogflow.v2beta1.VersionName; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class SyncDeleteVersion { + + public static void main(String[] args) throws Exception { + syncDeleteVersion(); + } + + public static void syncDeleteVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + DeleteVersionRequest request = + DeleteVersionRequest.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .build(); + versionsClient.deleteVersion(request); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_deleteversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/SyncDeleteVersionString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/SyncDeleteVersionString.java new file mode 100644 index 000000000000..e2f6185ac3d3 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/SyncDeleteVersionString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_deleteversion_string_sync] +import com.google.cloud.dialogflow.v2beta1.VersionName; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class SyncDeleteVersionString { + + public static void main(String[] args) throws Exception { + syncDeleteVersionString(); + } + + public static void syncDeleteVersionString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + String name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString(); + versionsClient.deleteVersion(name); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_deleteversion_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/SyncDeleteVersionVersionname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/SyncDeleteVersionVersionname.java new file mode 100644 index 000000000000..bf98eb6bc751 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/deleteversion/SyncDeleteVersionVersionname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_deleteversion_versionname_sync] +import com.google.cloud.dialogflow.v2beta1.VersionName; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class SyncDeleteVersionVersionname { + + public static void main(String[] args) throws Exception { + syncDeleteVersionVersionname(); + } + + public static void syncDeleteVersionVersionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]"); + versionsClient.deleteVersion(name); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_deleteversion_versionname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/AsyncGetVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/AsyncGetVersion.java new file mode 100644 index 000000000000..cba0bbffebc5 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/AsyncGetVersion.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_getversion_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.GetVersionRequest; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionName; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class AsyncGetVersion { + + public static void main(String[] args) throws Exception { + asyncGetVersion(); + } + + public static void asyncGetVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + GetVersionRequest request = + GetVersionRequest.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .build(); + ApiFuture future = versionsClient.getVersionCallable().futureCall(request); + // Do something. + Version response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_getversion_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/SyncGetVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/SyncGetVersion.java new file mode 100644 index 000000000000..df8775e3a579 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/SyncGetVersion.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_getversion_sync] +import com.google.cloud.dialogflow.v2beta1.GetVersionRequest; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionName; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class SyncGetVersion { + + public static void main(String[] args) throws Exception { + syncGetVersion(); + } + + public static void syncGetVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + GetVersionRequest request = + GetVersionRequest.newBuilder() + .setName(VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString()) + .build(); + Version response = versionsClient.getVersion(request); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_getversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/SyncGetVersionString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/SyncGetVersionString.java new file mode 100644 index 000000000000..b0572081fde1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/SyncGetVersionString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_getversion_string_sync] +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionName; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class SyncGetVersionString { + + public static void main(String[] args) throws Exception { + syncGetVersionString(); + } + + public static void syncGetVersionString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + String name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]").toString(); + Version response = versionsClient.getVersion(name); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_getversion_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/SyncGetVersionVersionname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/SyncGetVersionVersionname.java new file mode 100644 index 000000000000..76e20e5ae34b --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/getversion/SyncGetVersionVersionname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_getversion_versionname_sync] +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionName; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class SyncGetVersionVersionname { + + public static void main(String[] args) throws Exception { + syncGetVersionVersionname(); + } + + public static void syncGetVersionVersionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + VersionName name = VersionName.ofProjectVersionName("[PROJECT]", "[VERSION]"); + Version response = versionsClient.getVersion(name); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_getversion_versionname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/AsyncListVersions.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/AsyncListVersions.java new file mode 100644 index 000000000000..222c7a9142df --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/AsyncListVersions.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_listversions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.ListVersionsRequest; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class AsyncListVersions { + + public static void main(String[] args) throws Exception { + asyncListVersions(); + } + + public static void asyncListVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + ListVersionsRequest request = + ListVersionsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = versionsClient.listVersionsPagedCallable().futureCall(request); + // Do something. + for (Version element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_listversions_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/AsyncListVersionsPaged.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/AsyncListVersionsPaged.java new file mode 100644 index 000000000000..bf1c3d858838 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/AsyncListVersionsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_listversions_paged_async] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.ListVersionsRequest; +import com.google.cloud.dialogflow.v2beta1.ListVersionsResponse; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; +import com.google.common.base.Strings; + +public class AsyncListVersionsPaged { + + public static void main(String[] args) throws Exception { + asyncListVersionsPaged(); + } + + public static void asyncListVersionsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + ListVersionsRequest request = + ListVersionsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListVersionsResponse response = versionsClient.listVersionsCallable().call(request); + for (Version element : response.getVersionsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_listversions_paged_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/SyncListVersions.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/SyncListVersions.java new file mode 100644 index 000000000000..a91d21b0c6a1 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/SyncListVersions.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_listversions_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.ListVersionsRequest; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class SyncListVersions { + + public static void main(String[] args) throws Exception { + syncListVersions(); + } + + public static void syncListVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + ListVersionsRequest request = + ListVersionsRequest.newBuilder() + .setParent(AgentName.ofProjectName("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Version element : versionsClient.listVersions(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_listversions_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/SyncListVersionsAgentname.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/SyncListVersionsAgentname.java new file mode 100644 index 000000000000..560d3d0278fb --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/SyncListVersionsAgentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_listversions_agentname_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class SyncListVersionsAgentname { + + public static void main(String[] args) throws Exception { + syncListVersionsAgentname(); + } + + public static void syncListVersionsAgentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + AgentName parent = AgentName.ofProjectName("[PROJECT]"); + for (Version element : versionsClient.listVersions(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_listversions_agentname_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/SyncListVersionsString.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/SyncListVersionsString.java new file mode 100644 index 000000000000..a8b798c509e6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/listversions/SyncListVersionsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_listversions_string_sync] +import com.google.cloud.dialogflow.v2beta1.AgentName; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; + +public class SyncListVersionsString { + + public static void main(String[] args) throws Exception { + syncListVersionsString(); + } + + public static void syncListVersionsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + String parent = AgentName.ofProjectName("[PROJECT]").toString(); + for (Version element : versionsClient.listVersions(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_listversions_string_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/updateversion/AsyncUpdateVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/updateversion/AsyncUpdateVersion.java new file mode 100644 index 000000000000..8a69e23b4e5e --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/updateversion/AsyncUpdateVersion.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_updateversion_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.dialogflow.v2beta1.UpdateVersionRequest; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateVersion { + + public static void main(String[] args) throws Exception { + asyncUpdateVersion(); + } + + public static void asyncUpdateVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + UpdateVersionRequest request = + UpdateVersionRequest.newBuilder() + .setVersion(Version.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = versionsClient.updateVersionCallable().futureCall(request); + // Do something. + Version response = future.get(); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_updateversion_async] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/updateversion/SyncUpdateVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/updateversion/SyncUpdateVersion.java new file mode 100644 index 000000000000..5603875b4c06 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/updateversion/SyncUpdateVersion.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_updateversion_sync] +import com.google.cloud.dialogflow.v2beta1.UpdateVersionRequest; +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateVersion { + + public static void main(String[] args) throws Exception { + syncUpdateVersion(); + } + + public static void syncUpdateVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + UpdateVersionRequest request = + UpdateVersionRequest.newBuilder() + .setVersion(Version.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Version response = versionsClient.updateVersion(request); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_updateversion_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/updateversion/SyncUpdateVersionVersionFieldmask.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/updateversion/SyncUpdateVersionVersionFieldmask.java new file mode 100644 index 000000000000..2323465330b6 --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionsclient/updateversion/SyncUpdateVersionVersionFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionsclient_updateversion_versionfieldmask_sync] +import com.google.cloud.dialogflow.v2beta1.Version; +import com.google.cloud.dialogflow.v2beta1.VersionsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateVersionVersionFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateVersionVersionFieldmask(); + } + + public static void syncUpdateVersionVersionFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VersionsClient versionsClient = VersionsClient.create()) { + Version version = Version.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Version response = versionsClient.updateVersion(version, updateMask); + } + } +} +// [END dialogflow_v2beta1_generated_versionsclient_updateversion_versionfieldmask_sync] diff --git a/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionssettings/getversion/SyncGetVersion.java b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionssettings/getversion/SyncGetVersion.java new file mode 100644 index 000000000000..d4cb6f5969dd --- /dev/null +++ b/java-dialogflow/samples/snippets/generated/com/google/cloud/dialogflow/v2beta1/versionssettings/getversion/SyncGetVersion.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v2beta1.samples; + +// [START dialogflow_v2beta1_generated_versionssettings_getversion_sync] +import com.google.cloud.dialogflow.v2beta1.VersionsSettings; +import java.time.Duration; + +public class SyncGetVersion { + + public static void main(String[] args) throws Exception { + syncGetVersion(); + } + + public static void syncGetVersion() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VersionsSettings.Builder versionsSettingsBuilder = VersionsSettings.newBuilder(); + versionsSettingsBuilder + .getVersionSettings() + .setRetrySettings( + versionsSettingsBuilder + .getVersionSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VersionsSettings versionsSettings = versionsSettingsBuilder.build(); + } +} +// [END dialogflow_v2beta1_generated_versionssettings_getversion_sync]