From 8a3560040c08efce8e1c06e7078c17fa0aa10588 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 08:14:21 -0800 Subject: [PATCH] feat: added Generator API (#6832) docs: updated doc for speech mode PiperOrigin-RevId: 586469693 Source-Link: https://github.com/googleapis/googleapis/commit/e8148d6d4bb02c907e06a784848ef731acb9e258 Source-Link: https://github.com/googleapis/googleapis-gen/commit/85136bd04383ed7172bb18b7b8d220dd7ff6b3a0 Copy-Tag: eyJwIjoiRGlhbG9nZmxvd0N4Ly5Pd2xCb3QueWFtbCIsImgiOiI4NTEzNmJkMDQzODNlZDcxNzJiYjE4YjdiOGQyMjBkZDdmZjZiM2EwIn0= --- DialogflowCx/metadata/V3/Agent.php | Bin 8196 -> 8359 bytes DialogflowCx/metadata/V3/AudioConfig.php | Bin 3120 -> 3316 bytes DialogflowCx/metadata/V3/EntityType.php | Bin 4109 -> 4109 bytes DialogflowCx/metadata/V3/Generator.php | 78 ++ DialogflowCx/metadata/V3/Session.php | Bin 10017 -> 11875 bytes .../V3/GeneratorsClient/create_generator.php | 85 +++ .../V3/GeneratorsClient/delete_generator.php | 71 ++ .../V3/GeneratorsClient/get_generator.php | 73 ++ .../V3/GeneratorsClient/get_location.php | 53 ++ .../V3/GeneratorsClient/list_generators.php | 72 ++ .../V3/GeneratorsClient/list_locations.php | 58 ++ .../V3/GeneratorsClient/update_generator.php | 80 ++ .../SessionsClient/submit_answer_feedback.php | 73 ++ DialogflowCx/src/V3/Agent.php | 44 ++ .../src/V3/Agent/AnswerFeedbackSettings.php | 80 ++ DialogflowCx/src/V3/AnswerFeedback.php | 157 ++++ DialogflowCx/src/V3/AnswerFeedback/Rating.php | 62 ++ .../src/V3/AnswerFeedback/RatingReason.php | 114 +++ DialogflowCx/src/V3/BargeInConfig.php | 143 ++++ DialogflowCx/src/V3/BoostSpec.php | 82 +++ .../src/V3/BoostSpec/ConditionBoostSpec.php | 178 +++++ DialogflowCx/src/V3/BoostSpecs.php | 113 +++ .../src/V3/CreateGeneratorRequest.php | 158 ++++ .../src/V3/DeleteGeneratorRequest.php | 134 ++++ DialogflowCx/src/V3/FilterSpecs.php | 121 +++ .../src/V3/Gapic/GeneratorsGapicClient.php | 687 ++++++++++++++++++ .../src/V3/Gapic/SessionsGapicClient.php | 155 ++++ DialogflowCx/src/V3/Generator.php | 214 ++++++ DialogflowCx/src/V3/Generator/Placeholder.php | 102 +++ DialogflowCx/src/V3/GeneratorsClient.php | 34 + DialogflowCx/src/V3/GetGeneratorRequest.php | 110 +++ DialogflowCx/src/V3/InputAudioConfig.php | 84 ++- DialogflowCx/src/V3/ListGeneratorsRequest.php | 178 +++++ .../src/V3/ListGeneratorsResponse.php | 110 +++ DialogflowCx/src/V3/Phrase.php | 67 ++ DialogflowCx/src/V3/QueryParameters.php | 140 ++++ DialogflowCx/src/V3/QueryResult.php | 38 + DialogflowCx/src/V3/SearchConfig.php | 101 +++ .../src/V3/SubmitAnswerFeedbackRequest.php | 197 +++++ .../src/V3/UpdateGeneratorRequest.php | 160 ++++ DialogflowCx/src/V3/gapic_metadata.json | 49 ++ .../resources/generators_client_config.json | 69 ++ .../generators_descriptor_config.php | 32 + .../generators_rest_client_config.php | 144 ++++ .../V3/resources/sessions_client_config.json | 5 + .../resources/sessions_rest_client_config.php | 12 + .../tests/Unit/V3/GeneratorsClientTest.php | 525 +++++++++++++ .../tests/Unit/V3/SessionsClientTest.php | 69 ++ 48 files changed, 5299 insertions(+), 12 deletions(-) create mode 100644 DialogflowCx/metadata/V3/Generator.php create mode 100644 DialogflowCx/samples/V3/GeneratorsClient/create_generator.php create mode 100644 DialogflowCx/samples/V3/GeneratorsClient/delete_generator.php create mode 100644 DialogflowCx/samples/V3/GeneratorsClient/get_generator.php create mode 100644 DialogflowCx/samples/V3/GeneratorsClient/get_location.php create mode 100644 DialogflowCx/samples/V3/GeneratorsClient/list_generators.php create mode 100644 DialogflowCx/samples/V3/GeneratorsClient/list_locations.php create mode 100644 DialogflowCx/samples/V3/GeneratorsClient/update_generator.php create mode 100644 DialogflowCx/samples/V3/SessionsClient/submit_answer_feedback.php create mode 100644 DialogflowCx/src/V3/Agent/AnswerFeedbackSettings.php create mode 100644 DialogflowCx/src/V3/AnswerFeedback.php create mode 100644 DialogflowCx/src/V3/AnswerFeedback/Rating.php create mode 100644 DialogflowCx/src/V3/AnswerFeedback/RatingReason.php create mode 100644 DialogflowCx/src/V3/BargeInConfig.php create mode 100644 DialogflowCx/src/V3/BoostSpec.php create mode 100644 DialogflowCx/src/V3/BoostSpec/ConditionBoostSpec.php create mode 100644 DialogflowCx/src/V3/BoostSpecs.php create mode 100644 DialogflowCx/src/V3/CreateGeneratorRequest.php create mode 100644 DialogflowCx/src/V3/DeleteGeneratorRequest.php create mode 100644 DialogflowCx/src/V3/FilterSpecs.php create mode 100644 DialogflowCx/src/V3/Gapic/GeneratorsGapicClient.php create mode 100644 DialogflowCx/src/V3/Generator.php create mode 100644 DialogflowCx/src/V3/Generator/Placeholder.php create mode 100644 DialogflowCx/src/V3/GeneratorsClient.php create mode 100644 DialogflowCx/src/V3/GetGeneratorRequest.php create mode 100644 DialogflowCx/src/V3/ListGeneratorsRequest.php create mode 100644 DialogflowCx/src/V3/ListGeneratorsResponse.php create mode 100644 DialogflowCx/src/V3/Phrase.php create mode 100644 DialogflowCx/src/V3/SearchConfig.php create mode 100644 DialogflowCx/src/V3/SubmitAnswerFeedbackRequest.php create mode 100644 DialogflowCx/src/V3/UpdateGeneratorRequest.php create mode 100644 DialogflowCx/src/V3/resources/generators_client_config.json create mode 100644 DialogflowCx/src/V3/resources/generators_descriptor_config.php create mode 100644 DialogflowCx/src/V3/resources/generators_rest_client_config.php create mode 100644 DialogflowCx/tests/Unit/V3/GeneratorsClientTest.php diff --git a/DialogflowCx/metadata/V3/Agent.php b/DialogflowCx/metadata/V3/Agent.php index 713547082285d7f0724d5ba01590197cccf2b36e..c6d8a5a39bdf2f33d38d4a5252980cbf89fcc885 100644 GIT binary patch delta 195 zcmZp1Snjyt5ev&#GcL`^?^xv~W^!-lXZ_2_w1s;!AA2aXick`lL}FfXd1_I7T54)a zQetv;d~s??NoHPpv4oleqXxH;^<+Z{6-7NquqrpGqF|^RC*}u^j8YSrxWp#!;}Y9k z$EC*TDrL(hhF!IgGM89tUSd*CYCM{y5{y8*IKZY^#l*aFjGP=GsI>VEw}l7*n+ZRV delta 53 zcmV-50LuTTL4-iC;sgZJH3}({?gbu^X$!Lt1^od6kqWa82UP>J#|l9K20C0^>OonP LaStN1ZwxpT`eqTG diff --git a/DialogflowCx/metadata/V3/AudioConfig.php b/DialogflowCx/metadata/V3/AudioConfig.php index 90ebbbe774a656132a3c73daba6ca72526a4005a..3549322c910a13f3c1030fce5f6f5e905c2418c8 100644 GIT binary patch delta 143 zcmdlW@kMgO3?`)FqXxH; R&g4E8c~qM=-((4A2LL$FE;9fC delta 27 jcmew&xj|yX3?`{B`}pb^0blV5ApigX diff --git a/DialogflowCx/metadata/V3/Generator.php b/DialogflowCx/metadata/V3/Generator.php new file mode 100644 index 000000000000..18f9780d1802 --- /dev/null +++ b/DialogflowCx/metadata/V3/Generator.php @@ -0,0 +1,78 @@ +internalAddGeneratedFile( + ' +š +-google/cloud/dialogflow/cx/v3/generator.protogoogle.cloud.dialogflow.cx.v3google/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.protogoogle/protobuf/empty.proto google/protobuf/field_mask.proto"è + Generator +name (  + display_name ( BàA? + prompt_text ( 2%.google.cloud.dialogflow.cx.v3.PhraseBàAO + placeholders ( 24.google.cloud.dialogflow.cx.v3.Generator.PlaceholderBàA\' + Placeholder + +id (  +name ( :wêAt +#dialogflow.googleapis.com/GeneratorMprojects/{project}/locations/{location}/agents/{agent}/generators/{generator}" +Phrase +text ( BàA"’ +ListGeneratorsRequest; +parent ( B+àAúA%#dialogflow.googleapis.com/Generator + language_code (  + page_size ( + +page_token ( "o +ListGeneratorsResponse< + +generators ( 2(.google.cloud.dialogflow.cx.v3.Generator +next_page_token ( "g +GetGeneratorRequest9 +name ( B+àAúA% +#dialogflow.googleapis.com/Generator + language_code ( "® +CreateGeneratorRequest; +parent ( B+àAúA%#dialogflow.googleapis.com/Generator@ + generator ( 2(.google.cloud.dialogflow.cx.v3.GeneratorBàA + language_code ( "¢ +UpdateGeneratorRequest@ + generator ( 2(.google.cloud.dialogflow.cx.v3.GeneratorBàA + language_code ( / + update_mask ( 2.google.protobuf.FieldMask"b +DeleteGeneratorRequest9 +name ( B+àAúA% +#dialogflow.googleapis.com/Generator +force (2é + +GeneratorsÇ +ListGenerators4.google.cloud.dialogflow.cx.v3.ListGeneratorsRequest5.google.cloud.dialogflow.cx.v3.ListGeneratorsResponse"H‚Óä“97/v3/{parent=projects/*/locations/*/agents/*}/generatorsÚAparent´ + GetGenerator2.google.cloud.dialogflow.cx.v3.GetGeneratorRequest(.google.cloud.dialogflow.cx.v3.Generator"F‚Óä“97/v3/{name=projects/*/locations/*/agents/*/generators/*}ÚAnameÑ +CreateGenerator5.google.cloud.dialogflow.cx.v3.CreateGeneratorRequest(.google.cloud.dialogflow.cx.v3.Generator"]‚Óä“D"7/v3/{parent=projects/*/locations/*/agents/*}/generators: generatorÚAparent,generatorà +UpdateGenerator5.google.cloud.dialogflow.cx.v3.UpdateGeneratorRequest(.google.cloud.dialogflow.cx.v3.Generator"l‚Óä“N2A/v3/{generator.name=projects/*/locations/*/agents/*/generators/*}: generatorÚAgenerator,update_mask¨ +DeleteGenerator5.google.cloud.dialogflow.cx.v3.DeleteGeneratorRequest.google.protobuf.Empty"F‚Óä“9*7/v3/{name=projects/*/locations/*/agents/*/generators/*}ÚAnamexÊAdialogflow.googleapis.comÒAYhttps://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/dialogflowB +!com.google.cloud.dialogflow.cx.v3BGeneratorProtoPZ1cloud.google.com/go/dialogflow/cx/apiv3/cxpb;cxpbø¢DFªGoogle.Cloud.Dialogflow.Cx.V3bproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/DialogflowCx/metadata/V3/Session.php b/DialogflowCx/metadata/V3/Session.php index 2e769f1faefda55f234a5c369379ff1c664e0525..cff09abf51d47796fadc2e4bfb0e1dddf19ab72e 100644 GIT binary patch delta 1432 zcmbtTJ#5oJ6vj@PG|&CxXi7-cHc3lWfk;rPgaiVb{y~ZwO433RNQdKGf`wxTpF@QZ zRDux(ByUW>3Ie2v4MrBGLJ>7!TPGnbj2>DhrgA+&UAd0{G#mlt~k)D2SO zIdkTGwnt3-5THL_D^yggxf%O)aAqO`l1XUQ&?&)caZ6c5r=eTslf_s4=egg4cpnezS#NFsH>?C>-*C;V@ zg;+96Cr6N-+BGof4*Vo^QX-qm6|5L~Ni9cuxy*j2s*XI5O!I)f-g|8Lp#V*vXd0w~ zVNeUxDp4rg5ug1iJUl$*{ND=2B-4 zZ84WvuyOo=JsI!lrLFGn-N^0Wh9BZ=wrqlf^~&C|aPV9Dt?&;{oUp5-V|yG^xid6% f(=(XdLMu)*r5Kt<6lWD#c/locations//agents/`. Please see + * {@see GeneratorsClient::agentName()} for help formatting this field. + * @param string $generatorDisplayName The human-readable name of the generator, unique within the + * agent. The prompt contains pre-defined parameters such as $conversation, + * $last-user-utterance, etc. populated by Dialogflow. It can also contain + * custom placeholders which will be resolved during fulfillment. + * @param string $generatorPromptTextText Text input which can be used for prompt or banned phrases. + */ +function create_generator_sample( + string $formattedParent, + string $generatorDisplayName, + string $generatorPromptTextText +): void { + // Create a client. + $generatorsClient = new GeneratorsClient(); + + // Prepare any non-scalar elements to be passed along with the request. + $generatorPromptText = (new Phrase()) + ->setText($generatorPromptTextText); + $generator = (new Generator()) + ->setDisplayName($generatorDisplayName) + ->setPromptText($generatorPromptText); + + // Call the API and handle any network failures. + try { + /** @var Generator $response */ + $response = $generatorsClient->createGenerator($formattedParent, $generator); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = GeneratorsClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $generatorDisplayName = '[DISPLAY_NAME]'; + $generatorPromptTextText = '[TEXT]'; + + create_generator_sample($formattedParent, $generatorDisplayName, $generatorPromptTextText); +} +// [END dialogflow_v3_generated_Generators_CreateGenerator_sync] diff --git a/DialogflowCx/samples/V3/GeneratorsClient/delete_generator.php b/DialogflowCx/samples/V3/GeneratorsClient/delete_generator.php new file mode 100644 index 000000000000..24bdfd7ea9ac --- /dev/null +++ b/DialogflowCx/samples/V3/GeneratorsClient/delete_generator.php @@ -0,0 +1,71 @@ +/locations//agents//generators/`. Please see + * {@see GeneratorsClient::generatorName()} for help formatting this field. + */ +function delete_generator_sample(string $formattedName): void +{ + // Create a client. + $generatorsClient = new GeneratorsClient(); + + // Call the API and handle any network failures. + try { + $generatorsClient->deleteGenerator($formattedName); + printf('Call completed successfully.' . PHP_EOL); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = GeneratorsClient::generatorName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[GENERATOR]' + ); + + delete_generator_sample($formattedName); +} +// [END dialogflow_v3_generated_Generators_DeleteGenerator_sync] diff --git a/DialogflowCx/samples/V3/GeneratorsClient/get_generator.php b/DialogflowCx/samples/V3/GeneratorsClient/get_generator.php new file mode 100644 index 000000000000..527c6a633d25 --- /dev/null +++ b/DialogflowCx/samples/V3/GeneratorsClient/get_generator.php @@ -0,0 +1,73 @@ +/locations//agents//generators/`. Please see + * {@see GeneratorsClient::generatorName()} for help formatting this field. + */ +function get_generator_sample(string $formattedName): void +{ + // Create a client. + $generatorsClient = new GeneratorsClient(); + + // Call the API and handle any network failures. + try { + /** @var Generator $response */ + $response = $generatorsClient->getGenerator($formattedName); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = GeneratorsClient::generatorName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[GENERATOR]' + ); + + get_generator_sample($formattedName); +} +// [END dialogflow_v3_generated_Generators_GetGenerator_sync] diff --git a/DialogflowCx/samples/V3/GeneratorsClient/get_location.php b/DialogflowCx/samples/V3/GeneratorsClient/get_location.php new file mode 100644 index 000000000000..b7169998efaa --- /dev/null +++ b/DialogflowCx/samples/V3/GeneratorsClient/get_location.php @@ -0,0 +1,53 @@ +getLocation(); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END dialogflow_v3_generated_Generators_GetLocation_sync] diff --git a/DialogflowCx/samples/V3/GeneratorsClient/list_generators.php b/DialogflowCx/samples/V3/GeneratorsClient/list_generators.php new file mode 100644 index 000000000000..16c3ea187b46 --- /dev/null +++ b/DialogflowCx/samples/V3/GeneratorsClient/list_generators.php @@ -0,0 +1,72 @@ +/locations//agents/`. Please see + * {@see GeneratorsClient::agentName()} for help formatting this field. + */ +function list_generators_sample(string $formattedParent): void +{ + // Create a client. + $generatorsClient = new GeneratorsClient(); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $generatorsClient->listGenerators($formattedParent); + + /** @var Generator $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = GeneratorsClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + + list_generators_sample($formattedParent); +} +// [END dialogflow_v3_generated_Generators_ListGenerators_sync] diff --git a/DialogflowCx/samples/V3/GeneratorsClient/list_locations.php b/DialogflowCx/samples/V3/GeneratorsClient/list_locations.php new file mode 100644 index 000000000000..e65daf96144d --- /dev/null +++ b/DialogflowCx/samples/V3/GeneratorsClient/list_locations.php @@ -0,0 +1,58 @@ +listLocations(); + + /** @var Location $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END dialogflow_v3_generated_Generators_ListLocations_sync] diff --git a/DialogflowCx/samples/V3/GeneratorsClient/update_generator.php b/DialogflowCx/samples/V3/GeneratorsClient/update_generator.php new file mode 100644 index 000000000000..ba7167c613dd --- /dev/null +++ b/DialogflowCx/samples/V3/GeneratorsClient/update_generator.php @@ -0,0 +1,80 @@ +setText($generatorPromptTextText); + $generator = (new Generator()) + ->setDisplayName($generatorDisplayName) + ->setPromptText($generatorPromptText); + + // Call the API and handle any network failures. + try { + /** @var Generator $response */ + $response = $generatorsClient->updateGenerator($generator); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $generatorDisplayName = '[DISPLAY_NAME]'; + $generatorPromptTextText = '[TEXT]'; + + update_generator_sample($generatorDisplayName, $generatorPromptTextText); +} +// [END dialogflow_v3_generated_Generators_UpdateGenerator_sync] diff --git a/DialogflowCx/samples/V3/SessionsClient/submit_answer_feedback.php b/DialogflowCx/samples/V3/SessionsClient/submit_answer_feedback.php new file mode 100644 index 000000000000..a4a14136991d --- /dev/null +++ b/DialogflowCx/samples/V3/SessionsClient/submit_answer_feedback.php @@ -0,0 +1,73 @@ +submitAnswerFeedback($formattedSession, $responseId, $answerFeedback); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedSession = SessionsClient::sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); + $responseId = '[RESPONSE_ID]'; + + submit_answer_feedback_sample($formattedSession, $responseId); +} +// [END dialogflow_v3_generated_Sessions_SubmitAnswerFeedback_sync] diff --git a/DialogflowCx/src/V3/Agent.php b/DialogflowCx/src/V3/Agent.php index d336090e9cc5..cefd638a6cba 100644 --- a/DialogflowCx/src/V3/Agent.php +++ b/DialogflowCx/src/V3/Agent.php @@ -161,6 +161,12 @@ class Agent extends \Google\Protobuf\Internal\Message * Generated from protobuf field optional .google.cloud.dialogflow.cx.v3.Agent.GenAppBuilderSettings gen_app_builder_settings = 33; */ protected $gen_app_builder_settings = null; + /** + * Optional. Answer feedback collection settings. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.Agent.AnswerFeedbackSettings answer_feedback_settings = 38 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $answer_feedback_settings = null; /** * Constructor. @@ -234,6 +240,8 @@ class Agent extends \Google\Protobuf\Internal\Message * output audio content. * @type \Google\Cloud\Dialogflow\Cx\V3\Agent\GenAppBuilderSettings $gen_app_builder_settings * Gen App Builder-related agent-level settings. + * @type \Google\Cloud\Dialogflow\Cx\V3\Agent\AnswerFeedbackSettings $answer_feedback_settings + * Optional. Answer feedback collection settings. * } */ public function __construct($data = NULL) { @@ -801,5 +809,41 @@ public function setGenAppBuilderSettings($var) return $this; } + /** + * Optional. Answer feedback collection settings. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.Agent.AnswerFeedbackSettings answer_feedback_settings = 38 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Dialogflow\Cx\V3\Agent\AnswerFeedbackSettings|null + */ + public function getAnswerFeedbackSettings() + { + return $this->answer_feedback_settings; + } + + public function hasAnswerFeedbackSettings() + { + return isset($this->answer_feedback_settings); + } + + public function clearAnswerFeedbackSettings() + { + unset($this->answer_feedback_settings); + } + + /** + * Optional. Answer feedback collection settings. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.Agent.AnswerFeedbackSettings answer_feedback_settings = 38 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Dialogflow\Cx\V3\Agent\AnswerFeedbackSettings $var + * @return $this + */ + public function setAnswerFeedbackSettings($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\Cx\V3\Agent\AnswerFeedbackSettings::class); + $this->answer_feedback_settings = $var; + + return $this; + } + } diff --git a/DialogflowCx/src/V3/Agent/AnswerFeedbackSettings.php b/DialogflowCx/src/V3/Agent/AnswerFeedbackSettings.php new file mode 100644 index 000000000000..c94f24ce3f37 --- /dev/null +++ b/DialogflowCx/src/V3/Agent/AnswerFeedbackSettings.php @@ -0,0 +1,80 @@ +google.cloud.dialogflow.cx.v3.Agent.AnswerFeedbackSettings + */ +class AnswerFeedbackSettings extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. If enabled, end users will be able to provide + * [answer feedback][google.cloud.dialogflow.cx.v3.AnswerFeedback] to + * Dialogflow responses. Feature works only if interaction logging is + * enabled in the Dialogflow agent. + * + * Generated from protobuf field bool enable_answer_feedback = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $enable_answer_feedback = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type bool $enable_answer_feedback + * Optional. If enabled, end users will be able to provide + * [answer feedback][google.cloud.dialogflow.cx.v3.AnswerFeedback] to + * Dialogflow responses. Feature works only if interaction logging is + * enabled in the Dialogflow agent. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Agent::initOnce(); + parent::__construct($data); + } + + /** + * Optional. If enabled, end users will be able to provide + * [answer feedback][google.cloud.dialogflow.cx.v3.AnswerFeedback] to + * Dialogflow responses. Feature works only if interaction logging is + * enabled in the Dialogflow agent. + * + * Generated from protobuf field bool enable_answer_feedback = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getEnableAnswerFeedback() + { + return $this->enable_answer_feedback; + } + + /** + * Optional. If enabled, end users will be able to provide + * [answer feedback][google.cloud.dialogflow.cx.v3.AnswerFeedback] to + * Dialogflow responses. Feature works only if interaction logging is + * enabled in the Dialogflow agent. + * + * Generated from protobuf field bool enable_answer_feedback = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setEnableAnswerFeedback($var) + { + GPBUtil::checkBool($var); + $this->enable_answer_feedback = $var; + + return $this; + } + +} + + diff --git a/DialogflowCx/src/V3/AnswerFeedback.php b/DialogflowCx/src/V3/AnswerFeedback.php new file mode 100644 index 000000000000..ad47950eb76b --- /dev/null +++ b/DialogflowCx/src/V3/AnswerFeedback.php @@ -0,0 +1,157 @@ +google.cloud.dialogflow.cx.v3.AnswerFeedback + */ +class AnswerFeedback extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Rating from user for the specific Dialogflow response. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.AnswerFeedback.Rating rating = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $rating = 0; + /** + * Optional. In case of thumbs down rating provided, users can optionally + * provide context about the rating. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.AnswerFeedback.RatingReason rating_reason = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $rating_reason = null; + /** + * Optional. Custom rating from the user about the provided answer, with + * maximum length of 1024 characters. For example, client could use a + * customized JSON object to indicate the rating. + * + * Generated from protobuf field string custom_rating = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $custom_rating = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $rating + * Optional. Rating from user for the specific Dialogflow response. + * @type \Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback\RatingReason $rating_reason + * Optional. In case of thumbs down rating provided, users can optionally + * provide context about the rating. + * @type string $custom_rating + * Optional. Custom rating from the user about the provided answer, with + * maximum length of 1024 characters. For example, client could use a + * customized JSON object to indicate the rating. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Session::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Rating from user for the specific Dialogflow response. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.AnswerFeedback.Rating rating = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getRating() + { + return $this->rating; + } + + /** + * Optional. Rating from user for the specific Dialogflow response. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.AnswerFeedback.Rating rating = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setRating($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback\Rating::class); + $this->rating = $var; + + return $this; + } + + /** + * Optional. In case of thumbs down rating provided, users can optionally + * provide context about the rating. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.AnswerFeedback.RatingReason rating_reason = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback\RatingReason|null + */ + public function getRatingReason() + { + return $this->rating_reason; + } + + public function hasRatingReason() + { + return isset($this->rating_reason); + } + + public function clearRatingReason() + { + unset($this->rating_reason); + } + + /** + * Optional. In case of thumbs down rating provided, users can optionally + * provide context about the rating. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.AnswerFeedback.RatingReason rating_reason = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback\RatingReason $var + * @return $this + */ + public function setRatingReason($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback\RatingReason::class); + $this->rating_reason = $var; + + return $this; + } + + /** + * Optional. Custom rating from the user about the provided answer, with + * maximum length of 1024 characters. For example, client could use a + * customized JSON object to indicate the rating. + * + * Generated from protobuf field string custom_rating = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getCustomRating() + { + return $this->custom_rating; + } + + /** + * Optional. Custom rating from the user about the provided answer, with + * maximum length of 1024 characters. For example, client could use a + * customized JSON object to indicate the rating. + * + * Generated from protobuf field string custom_rating = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setCustomRating($var) + { + GPBUtil::checkString($var, True); + $this->custom_rating = $var; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/AnswerFeedback/Rating.php b/DialogflowCx/src/V3/AnswerFeedback/Rating.php new file mode 100644 index 000000000000..e24b0e1601ac --- /dev/null +++ b/DialogflowCx/src/V3/AnswerFeedback/Rating.php @@ -0,0 +1,62 @@ +google.cloud.dialogflow.cx.v3.AnswerFeedback.Rating + */ +class Rating +{ + /** + * Rating not specified. + * + * Generated from protobuf enum RATING_UNSPECIFIED = 0; + */ + const RATING_UNSPECIFIED = 0; + /** + * Thumbs up feedback from user. + * + * Generated from protobuf enum THUMBS_UP = 1; + */ + const THUMBS_UP = 1; + /** + * Thumbs down feedback from user. + * + * Generated from protobuf enum THUMBS_DOWN = 2; + */ + const THUMBS_DOWN = 2; + + private static $valueToName = [ + self::RATING_UNSPECIFIED => 'RATING_UNSPECIFIED', + self::THUMBS_UP => 'THUMBS_UP', + self::THUMBS_DOWN => 'THUMBS_DOWN', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/DialogflowCx/src/V3/AnswerFeedback/RatingReason.php b/DialogflowCx/src/V3/AnswerFeedback/RatingReason.php new file mode 100644 index 000000000000..c757cfd5e74b --- /dev/null +++ b/DialogflowCx/src/V3/AnswerFeedback/RatingReason.php @@ -0,0 +1,114 @@ +google.cloud.dialogflow.cx.v3.AnswerFeedback.RatingReason + */ +class RatingReason extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Custom reason labels for thumbs down rating provided by the + * user. The maximum number of labels allowed is 10 and the maximum length + * of a single label is 128 characters. + * + * Generated from protobuf field repeated string reason_labels = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $reason_labels; + /** + * Optional. Additional feedback about the rating. + * This field can be populated without choosing a predefined `reason`. + * + * Generated from protobuf field string feedback = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $feedback = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $reason_labels + * Optional. Custom reason labels for thumbs down rating provided by the + * user. The maximum number of labels allowed is 10 and the maximum length + * of a single label is 128 characters. + * @type string $feedback + * Optional. Additional feedback about the rating. + * This field can be populated without choosing a predefined `reason`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Session::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Custom reason labels for thumbs down rating provided by the + * user. The maximum number of labels allowed is 10 and the maximum length + * of a single label is 128 characters. + * + * Generated from protobuf field repeated string reason_labels = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getReasonLabels() + { + return $this->reason_labels; + } + + /** + * Optional. Custom reason labels for thumbs down rating provided by the + * user. The maximum number of labels allowed is 10 and the maximum length + * of a single label is 128 characters. + * + * Generated from protobuf field repeated string reason_labels = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setReasonLabels($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->reason_labels = $arr; + + return $this; + } + + /** + * Optional. Additional feedback about the rating. + * This field can be populated without choosing a predefined `reason`. + * + * Generated from protobuf field string feedback = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getFeedback() + { + return $this->feedback; + } + + /** + * Optional. Additional feedback about the rating. + * This field can be populated without choosing a predefined `reason`. + * + * Generated from protobuf field string feedback = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setFeedback($var) + { + GPBUtil::checkString($var, True); + $this->feedback = $var; + + return $this; + } + +} + + diff --git a/DialogflowCx/src/V3/BargeInConfig.php b/DialogflowCx/src/V3/BargeInConfig.php new file mode 100644 index 000000000000..460f824c9159 --- /dev/null +++ b/DialogflowCx/src/V3/BargeInConfig.php @@ -0,0 +1,143 @@ +google.cloud.dialogflow.cx.v3.BargeInConfig + */ +class BargeInConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Duration that is not eligible for barge-in at the beginning of the input + * audio. + * + * Generated from protobuf field .google.protobuf.Duration no_barge_in_duration = 1; + */ + protected $no_barge_in_duration = null; + /** + * Total duration for the playback at the beginning of the input audio. + * + * Generated from protobuf field .google.protobuf.Duration total_duration = 2; + */ + protected $total_duration = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Duration $no_barge_in_duration + * Duration that is not eligible for barge-in at the beginning of the input + * audio. + * @type \Google\Protobuf\Duration $total_duration + * Total duration for the playback at the beginning of the input audio. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\AudioConfig::initOnce(); + parent::__construct($data); + } + + /** + * Duration that is not eligible for barge-in at the beginning of the input + * audio. + * + * Generated from protobuf field .google.protobuf.Duration no_barge_in_duration = 1; + * @return \Google\Protobuf\Duration|null + */ + public function getNoBargeInDuration() + { + return $this->no_barge_in_duration; + } + + public function hasNoBargeInDuration() + { + return isset($this->no_barge_in_duration); + } + + public function clearNoBargeInDuration() + { + unset($this->no_barge_in_duration); + } + + /** + * Duration that is not eligible for barge-in at the beginning of the input + * audio. + * + * Generated from protobuf field .google.protobuf.Duration no_barge_in_duration = 1; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setNoBargeInDuration($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->no_barge_in_duration = $var; + + return $this; + } + + /** + * Total duration for the playback at the beginning of the input audio. + * + * Generated from protobuf field .google.protobuf.Duration total_duration = 2; + * @return \Google\Protobuf\Duration|null + */ + public function getTotalDuration() + { + return $this->total_duration; + } + + public function hasTotalDuration() + { + return isset($this->total_duration); + } + + public function clearTotalDuration() + { + unset($this->total_duration); + } + + /** + * Total duration for the playback at the beginning of the input audio. + * + * Generated from protobuf field .google.protobuf.Duration total_duration = 2; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setTotalDuration($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->total_duration = $var; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/BoostSpec.php b/DialogflowCx/src/V3/BoostSpec.php new file mode 100644 index 000000000000..345be26b4507 --- /dev/null +++ b/DialogflowCx/src/V3/BoostSpec.php @@ -0,0 +1,82 @@ +google.cloud.dialogflow.cx.v3.BoostSpec + */ +class BoostSpec extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Condition boost specifications. If a document matches multiple + * conditions in the specifictions, boost scores from these specifications are + * all applied and combined in a non-linear way. Maximum number of + * specifications is 20. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.BoostSpec.ConditionBoostSpec condition_boost_specs = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $condition_boost_specs; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Dialogflow\Cx\V3\BoostSpec\ConditionBoostSpec>|\Google\Protobuf\Internal\RepeatedField $condition_boost_specs + * Optional. Condition boost specifications. If a document matches multiple + * conditions in the specifictions, boost scores from these specifications are + * all applied and combined in a non-linear way. Maximum number of + * specifications is 20. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Session::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Condition boost specifications. If a document matches multiple + * conditions in the specifictions, boost scores from these specifications are + * all applied and combined in a non-linear way. Maximum number of + * specifications is 20. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.BoostSpec.ConditionBoostSpec condition_boost_specs = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getConditionBoostSpecs() + { + return $this->condition_boost_specs; + } + + /** + * Optional. Condition boost specifications. If a document matches multiple + * conditions in the specifictions, boost scores from these specifications are + * all applied and combined in a non-linear way. Maximum number of + * specifications is 20. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.BoostSpec.ConditionBoostSpec condition_boost_specs = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param array<\Google\Cloud\Dialogflow\Cx\V3\BoostSpec\ConditionBoostSpec>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setConditionBoostSpecs($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\Cx\V3\BoostSpec\ConditionBoostSpec::class); + $this->condition_boost_specs = $arr; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/BoostSpec/ConditionBoostSpec.php b/DialogflowCx/src/V3/BoostSpec/ConditionBoostSpec.php new file mode 100644 index 000000000000..694496ff6c08 --- /dev/null +++ b/DialogflowCx/src/V3/BoostSpec/ConditionBoostSpec.php @@ -0,0 +1,178 @@ +google.cloud.dialogflow.cx.v3.BoostSpec.ConditionBoostSpec + */ +class ConditionBoostSpec extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. An expression which specifies a boost condition. The syntax and + * supported fields are the same as a filter expression. + * Examples: + * * To boost documents with document ID "doc_1" or "doc_2", and + * color + * "Red" or "Blue": + * * (id: ANY("doc_1", "doc_2")) AND (color: ANY("Red","Blue")) + * + * Generated from protobuf field string condition = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $condition = ''; + /** + * Optional. Strength of the condition boost, which should be in [-1, 1]. + * Negative boost means demotion. Default is 0.0. + * Setting to 1.0 gives the document a big promotion. However, it does not + * necessarily mean that the boosted document will be the top result at + * all times, nor that other documents will be excluded. Results could + * still be shown even when none of them matches the condition. And + * results that are significantly more relevant to the search query can + * still trump your heavily favored but irrelevant documents. + * Setting to -1.0 gives the document a big demotion. However, results + * that are deeply relevant might still be shown. The document will have + * an upstream battle to get a fairly high ranking, but it is not blocked + * out completely. + * Setting to 0.0 means no boost applied. The boosting condition is + * ignored. + * + * Generated from protobuf field float boost = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $boost = 0.0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $condition + * Optional. An expression which specifies a boost condition. The syntax and + * supported fields are the same as a filter expression. + * Examples: + * * To boost documents with document ID "doc_1" or "doc_2", and + * color + * "Red" or "Blue": + * * (id: ANY("doc_1", "doc_2")) AND (color: ANY("Red","Blue")) + * @type float $boost + * Optional. Strength of the condition boost, which should be in [-1, 1]. + * Negative boost means demotion. Default is 0.0. + * Setting to 1.0 gives the document a big promotion. However, it does not + * necessarily mean that the boosted document will be the top result at + * all times, nor that other documents will be excluded. Results could + * still be shown even when none of them matches the condition. And + * results that are significantly more relevant to the search query can + * still trump your heavily favored but irrelevant documents. + * Setting to -1.0 gives the document a big demotion. However, results + * that are deeply relevant might still be shown. The document will have + * an upstream battle to get a fairly high ranking, but it is not blocked + * out completely. + * Setting to 0.0 means no boost applied. The boosting condition is + * ignored. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Session::initOnce(); + parent::__construct($data); + } + + /** + * Optional. An expression which specifies a boost condition. The syntax and + * supported fields are the same as a filter expression. + * Examples: + * * To boost documents with document ID "doc_1" or "doc_2", and + * color + * "Red" or "Blue": + * * (id: ANY("doc_1", "doc_2")) AND (color: ANY("Red","Blue")) + * + * Generated from protobuf field string condition = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getCondition() + { + return $this->condition; + } + + /** + * Optional. An expression which specifies a boost condition. The syntax and + * supported fields are the same as a filter expression. + * Examples: + * * To boost documents with document ID "doc_1" or "doc_2", and + * color + * "Red" or "Blue": + * * (id: ANY("doc_1", "doc_2")) AND (color: ANY("Red","Blue")) + * + * Generated from protobuf field string condition = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setCondition($var) + { + GPBUtil::checkString($var, True); + $this->condition = $var; + + return $this; + } + + /** + * Optional. Strength of the condition boost, which should be in [-1, 1]. + * Negative boost means demotion. Default is 0.0. + * Setting to 1.0 gives the document a big promotion. However, it does not + * necessarily mean that the boosted document will be the top result at + * all times, nor that other documents will be excluded. Results could + * still be shown even when none of them matches the condition. And + * results that are significantly more relevant to the search query can + * still trump your heavily favored but irrelevant documents. + * Setting to -1.0 gives the document a big demotion. However, results + * that are deeply relevant might still be shown. The document will have + * an upstream battle to get a fairly high ranking, but it is not blocked + * out completely. + * Setting to 0.0 means no boost applied. The boosting condition is + * ignored. + * + * Generated from protobuf field float boost = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return float + */ + public function getBoost() + { + return $this->boost; + } + + /** + * Optional. Strength of the condition boost, which should be in [-1, 1]. + * Negative boost means demotion. Default is 0.0. + * Setting to 1.0 gives the document a big promotion. However, it does not + * necessarily mean that the boosted document will be the top result at + * all times, nor that other documents will be excluded. Results could + * still be shown even when none of them matches the condition. And + * results that are significantly more relevant to the search query can + * still trump your heavily favored but irrelevant documents. + * Setting to -1.0 gives the document a big demotion. However, results + * that are deeply relevant might still be shown. The document will have + * an upstream battle to get a fairly high ranking, but it is not blocked + * out completely. + * Setting to 0.0 means no boost applied. The boosting condition is + * ignored. + * + * Generated from protobuf field float boost = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param float $var + * @return $this + */ + public function setBoost($var) + { + GPBUtil::checkFloat($var); + $this->boost = $var; + + return $this; + } + +} + + diff --git a/DialogflowCx/src/V3/BoostSpecs.php b/DialogflowCx/src/V3/BoostSpecs.php new file mode 100644 index 000000000000..23a562043bc8 --- /dev/null +++ b/DialogflowCx/src/V3/BoostSpecs.php @@ -0,0 +1,113 @@ +google.cloud.dialogflow.cx.v3.BoostSpecs + */ +class BoostSpecs extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Data Stores where the boosting configuration is applied. The full + * names of the referenced data stores. Formats: + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * `projects/{project}/locations/{location}/dataStores/{data_store} + * + * Generated from protobuf field repeated string data_stores = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $data_stores; + /** + * Optional. A list of boosting specifications. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.BoostSpec spec = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $spec; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $data_stores + * Optional. Data Stores where the boosting configuration is applied. The full + * names of the referenced data stores. Formats: + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * `projects/{project}/locations/{location}/dataStores/{data_store} + * @type array<\Google\Cloud\Dialogflow\Cx\V3\BoostSpec>|\Google\Protobuf\Internal\RepeatedField $spec + * Optional. A list of boosting specifications. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Session::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Data Stores where the boosting configuration is applied. The full + * names of the referenced data stores. Formats: + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * `projects/{project}/locations/{location}/dataStores/{data_store} + * + * Generated from protobuf field repeated string data_stores = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDataStores() + { + return $this->data_stores; + } + + /** + * Optional. Data Stores where the boosting configuration is applied. The full + * names of the referenced data stores. Formats: + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * `projects/{project}/locations/{location}/dataStores/{data_store} + * + * Generated from protobuf field repeated string data_stores = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDataStores($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->data_stores = $arr; + + return $this; + } + + /** + * Optional. A list of boosting specifications. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.BoostSpec spec = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSpec() + { + return $this->spec; + } + + /** + * Optional. A list of boosting specifications. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.BoostSpec spec = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param array<\Google\Cloud\Dialogflow\Cx\V3\BoostSpec>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSpec($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\Cx\V3\BoostSpec::class); + $this->spec = $arr; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/CreateGeneratorRequest.php b/DialogflowCx/src/V3/CreateGeneratorRequest.php new file mode 100644 index 000000000000..25c823bb5d60 --- /dev/null +++ b/DialogflowCx/src/V3/CreateGeneratorRequest.php @@ -0,0 +1,158 @@ +google.cloud.dialogflow.cx.v3.CreateGeneratorRequest + */ +class CreateGeneratorRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The agent to create a generator for. + * Format: `projects//locations//agents/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Required. The generator to create. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.Generator generator = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $generator = null; + /** + * The language to create generators for the following fields: + * * `Generator.prompt_text.text` + * If not specified, the agent's default language is used. + * + * Generated from protobuf field string language_code = 3; + */ + protected $language_code = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The agent to create a generator for. + * Format: `projects//locations//agents/`. + * @type \Google\Cloud\Dialogflow\Cx\V3\Generator $generator + * Required. The generator to create. + * @type string $language_code + * The language to create generators for the following fields: + * * `Generator.prompt_text.text` + * If not specified, the agent's default language is used. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Generator::initOnce(); + parent::__construct($data); + } + + /** + * Required. The agent to create a generator for. + * Format: `projects//locations//agents/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The agent to create a generator for. + * Format: `projects//locations//agents/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The generator to create. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.Generator generator = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Dialogflow\Cx\V3\Generator|null + */ + public function getGenerator() + { + return $this->generator; + } + + public function hasGenerator() + { + return isset($this->generator); + } + + public function clearGenerator() + { + unset($this->generator); + } + + /** + * Required. The generator to create. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.Generator generator = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Dialogflow\Cx\V3\Generator $var + * @return $this + */ + public function setGenerator($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\Cx\V3\Generator::class); + $this->generator = $var; + + return $this; + } + + /** + * The language to create generators for the following fields: + * * `Generator.prompt_text.text` + * If not specified, the agent's default language is used. + * + * Generated from protobuf field string language_code = 3; + * @return string + */ + public function getLanguageCode() + { + return $this->language_code; + } + + /** + * The language to create generators for the following fields: + * * `Generator.prompt_text.text` + * If not specified, the agent's default language is used. + * + * Generated from protobuf field string language_code = 3; + * @param string $var + * @return $this + */ + public function setLanguageCode($var) + { + GPBUtil::checkString($var, True); + $this->language_code = $var; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/DeleteGeneratorRequest.php b/DialogflowCx/src/V3/DeleteGeneratorRequest.php new file mode 100644 index 000000000000..4e4232cc9df6 --- /dev/null +++ b/DialogflowCx/src/V3/DeleteGeneratorRequest.php @@ -0,0 +1,134 @@ +google.cloud.dialogflow.cx.v3.DeleteGeneratorRequest + */ +class DeleteGeneratorRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the generator to delete. + * Format: `projects//locations//agents//generators/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * This field has no effect for generators not being used. + * For generators that are used by pages/flows/transition route groups: + * * If `force` is set to false, an error will be returned with message + * indicating the referenced resources. + * * If `force` is set to true, Dialogflow will remove the generator, as well + * as any references to the generator (i.e. + * [Generator][Fulfillment.generator]) in fulfillments. + * + * Generated from protobuf field bool force = 2; + */ + protected $force = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the generator to delete. + * Format: `projects//locations//agents//generators/`. + * @type bool $force + * This field has no effect for generators not being used. + * For generators that are used by pages/flows/transition route groups: + * * If `force` is set to false, an error will be returned with message + * indicating the referenced resources. + * * If `force` is set to true, Dialogflow will remove the generator, as well + * as any references to the generator (i.e. + * [Generator][Fulfillment.generator]) in fulfillments. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Generator::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the generator to delete. + * Format: `projects//locations//agents//generators/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The name of the generator to delete. + * Format: `projects//locations//agents//generators/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * This field has no effect for generators not being used. + * For generators that are used by pages/flows/transition route groups: + * * If `force` is set to false, an error will be returned with message + * indicating the referenced resources. + * * If `force` is set to true, Dialogflow will remove the generator, as well + * as any references to the generator (i.e. + * [Generator][Fulfillment.generator]) in fulfillments. + * + * Generated from protobuf field bool force = 2; + * @return bool + */ + public function getForce() + { + return $this->force; + } + + /** + * This field has no effect for generators not being used. + * For generators that are used by pages/flows/transition route groups: + * * If `force` is set to false, an error will be returned with message + * indicating the referenced resources. + * * If `force` is set to true, Dialogflow will remove the generator, as well + * as any references to the generator (i.e. + * [Generator][Fulfillment.generator]) in fulfillments. + * + * Generated from protobuf field bool force = 2; + * @param bool $var + * @return $this + */ + public function setForce($var) + { + GPBUtil::checkBool($var); + $this->force = $var; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/FilterSpecs.php b/DialogflowCx/src/V3/FilterSpecs.php new file mode 100644 index 000000000000..f130003cfb8d --- /dev/null +++ b/DialogflowCx/src/V3/FilterSpecs.php @@ -0,0 +1,121 @@ +google.cloud.dialogflow.cx.v3.FilterSpecs + */ +class FilterSpecs extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Data Stores where the boosting configuration is applied. The full + * names of the referenced data stores. Formats: + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * `projects/{project}/locations/{location}/dataStores/{data_store} + * + * Generated from protobuf field repeated string data_stores = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $data_stores; + /** + * Optional. The filter expression to be applied. + * Expression syntax is documented at + * https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata#filter-expression-syntax + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $filter = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $data_stores + * Optional. Data Stores where the boosting configuration is applied. The full + * names of the referenced data stores. Formats: + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * `projects/{project}/locations/{location}/dataStores/{data_store} + * @type string $filter + * Optional. The filter expression to be applied. + * Expression syntax is documented at + * https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata#filter-expression-syntax + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Session::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Data Stores where the boosting configuration is applied. The full + * names of the referenced data stores. Formats: + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * `projects/{project}/locations/{location}/dataStores/{data_store} + * + * Generated from protobuf field repeated string data_stores = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDataStores() + { + return $this->data_stores; + } + + /** + * Optional. Data Stores where the boosting configuration is applied. The full + * names of the referenced data stores. Formats: + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * `projects/{project}/locations/{location}/dataStores/{data_store} + * + * Generated from protobuf field repeated string data_stores = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDataStores($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->data_stores = $arr; + + return $this; + } + + /** + * Optional. The filter expression to be applied. + * Expression syntax is documented at + * https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata#filter-expression-syntax + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Optional. The filter expression to be applied. + * Expression syntax is documented at + * https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata#filter-expression-syntax + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/Gapic/GeneratorsGapicClient.php b/DialogflowCx/src/V3/Gapic/GeneratorsGapicClient.php new file mode 100644 index 000000000000..7678f86f69cc --- /dev/null +++ b/DialogflowCx/src/V3/Gapic/GeneratorsGapicClient.php @@ -0,0 +1,687 @@ +agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + * $generator = new Generator(); + * $response = $generatorsClient->createGenerator($formattedParent, $generator); + * } finally { + * $generatorsClient->close(); + * } + * ``` + * + * Many parameters require resource names to be formatted in a particular way. To + * assist with these names, this class includes a format method for each type of + * name, and additionally a parseName method to extract the individual identifiers + * contained within formatted names that are returned by the API. + */ +class GeneratorsGapicClient +{ + use GapicClientTrait; + + /** The name of the service. */ + const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.Generators'; + + /** The default address of the service. */ + const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private static $agentNameTemplate; + + private static $generatorNameTemplate; + + private static $pathTemplateMap; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/generators_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/generators_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/generators_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/generators_rest_client_config.php', + ], + ], + ]; + } + + private static function getAgentNameTemplate() + { + if (self::$agentNameTemplate == null) { + self::$agentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}'); + } + + return self::$agentNameTemplate; + } + + private static function getGeneratorNameTemplate() + { + if (self::$generatorNameTemplate == null) { + self::$generatorNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/generators/{generator}'); + } + + return self::$generatorNameTemplate; + } + + private static function getPathTemplateMap() + { + if (self::$pathTemplateMap == null) { + self::$pathTemplateMap = [ + 'agent' => self::getAgentNameTemplate(), + 'generator' => self::getGeneratorNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent a agent + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * + * @return string The formatted agent resource. + */ + public static function agentName($project, $location, $agent) + { + return self::getAgentNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a generator + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $generator + * + * @return string The formatted generator resource. + */ + public static function generatorName($project, $location, $agent, $generator) + { + return self::getGeneratorNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'generator' => $generator, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - agent: projects/{project}/locations/{location}/agents/{agent} + * - generator: projects/{project}/locations/{location}/agents/{agent}/generators/{generator} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + */ + public static function parseName($formattedName, $template = null) + { + $templateMap = self::getPathTemplateMap(); + if ($template) { + if (!isset($templateMap[$template])) { + throw new ValidationException("Template name $template does not exist"); + } + + return $templateMap[$template]->match($formattedName); + } + + foreach ($templateMap as $templateName => $pathTemplate) { + try { + return $pathTemplate->match($formattedName); + } catch (ValidationException $ex) { + // Swallow the exception to continue trying other path templates + } + } + + throw new ValidationException("Input did not match any known format. Input: $formattedName"); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'dialogflow.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** + * Creates a generator in the specified agent. + * + * Sample code: + * ``` + * $generatorsClient = new GeneratorsClient(); + * try { + * $formattedParent = $generatorsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + * $generator = new Generator(); + * $response = $generatorsClient->createGenerator($formattedParent, $generator); + * } finally { + * $generatorsClient->close(); + * } + * ``` + * + * @param string $parent Required. The agent to create a generator for. + * Format: `projects//locations//agents/`. + * @param Generator $generator Required. The generator to create. + * @param array $optionalArgs { + * Optional. + * + * @type string $languageCode + * The language to create generators for the following fields: + * * `Generator.prompt_text.text` + * If not specified, the agent's default language is used. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Dialogflow\Cx\V3\Generator + * + * @throws ApiException if the remote call fails + */ + public function createGenerator($parent, $generator, array $optionalArgs = []) + { + $request = new CreateGeneratorRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setGenerator($generator); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['languageCode'])) { + $request->setLanguageCode($optionalArgs['languageCode']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateGenerator', Generator::class, $optionalArgs, $request)->wait(); + } + + /** + * Deletes the specified generators. + * + * Sample code: + * ``` + * $generatorsClient = new GeneratorsClient(); + * try { + * $formattedName = $generatorsClient->generatorName('[PROJECT]', '[LOCATION]', '[AGENT]', '[GENERATOR]'); + * $generatorsClient->deleteGenerator($formattedName); + * } finally { + * $generatorsClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the generator to delete. + * Format: `projects//locations//agents//generators/`. + * @param array $optionalArgs { + * Optional. + * + * @type bool $force + * This field has no effect for generators not being used. + * For generators that are used by pages/flows/transition route groups: + * + * * If `force` is set to false, an error will be returned with message + * indicating the referenced resources. + * * If `force` is set to true, Dialogflow will remove the generator, as well + * as any references to the generator (i.e. + * [Generator][Fulfillment.generator]) in fulfillments. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteGenerator($name, array $optionalArgs = []) + { + $request = new DeleteGeneratorRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['force'])) { + $request->setForce($optionalArgs['force']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteGenerator', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Retrieves the specified generator. + * + * Sample code: + * ``` + * $generatorsClient = new GeneratorsClient(); + * try { + * $formattedName = $generatorsClient->generatorName('[PROJECT]', '[LOCATION]', '[AGENT]', '[GENERATOR]'); + * $response = $generatorsClient->getGenerator($formattedName); + * } finally { + * $generatorsClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the generator. + * Format: `projects//locations//agents//generators/`. + * @param array $optionalArgs { + * Optional. + * + * @type string $languageCode + * The language to list generators for. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Dialogflow\Cx\V3\Generator + * + * @throws ApiException if the remote call fails + */ + public function getGenerator($name, array $optionalArgs = []) + { + $request = new GetGeneratorRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['languageCode'])) { + $request->setLanguageCode($optionalArgs['languageCode']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetGenerator', Generator::class, $optionalArgs, $request)->wait(); + } + + /** + * Returns the list of all generators in the specified agent. + * + * Sample code: + * ``` + * $generatorsClient = new GeneratorsClient(); + * try { + * $formattedParent = $generatorsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + * // Iterate over pages of elements + * $pagedResponse = $generatorsClient->listGenerators($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $generatorsClient->listGenerators($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $generatorsClient->close(); + * } + * ``` + * + * @param string $parent Required. The agent to list all generators for. + * Format: `projects//locations//agents/`. + * @param array $optionalArgs { + * Optional. + * + * @type string $languageCode + * The language to list generators for. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listGenerators($parent, array $optionalArgs = []) + { + $request = new ListGeneratorsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['languageCode'])) { + $request->setLanguageCode($optionalArgs['languageCode']); + } + + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListGenerators', $optionalArgs, ListGeneratorsResponse::class, $request); + } + + /** + * Update the specified generator. + * + * Sample code: + * ``` + * $generatorsClient = new GeneratorsClient(); + * try { + * $generator = new Generator(); + * $response = $generatorsClient->updateGenerator($generator); + * } finally { + * $generatorsClient->close(); + * } + * ``` + * + * @param Generator $generator Required. The generator to update. + * @param array $optionalArgs { + * Optional. + * + * @type string $languageCode + * The language to list generators for. + * @type FieldMask $updateMask + * The mask to control which fields get updated. If the mask is not present, + * all fields will be updated. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Dialogflow\Cx\V3\Generator + * + * @throws ApiException if the remote call fails + */ + public function updateGenerator($generator, array $optionalArgs = []) + { + $request = new UpdateGeneratorRequest(); + $requestParamHeaders = []; + $request->setGenerator($generator); + $requestParamHeaders['generator.name'] = $generator->getName(); + if (isset($optionalArgs['languageCode'])) { + $request->setLanguageCode($optionalArgs['languageCode']); + } + + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateGenerator', Generator::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets information about a location. + * + * Sample code: + * ``` + * $generatorsClient = new GeneratorsClient(); + * try { + * $response = $generatorsClient->getLocation(); + * } finally { + * $generatorsClient->close(); + * } + * ``` + * + * @param array $optionalArgs { + * Optional. + * + * @type string $name + * Resource name for the location. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Location\Location + * + * @throws ApiException if the remote call fails + */ + public function getLocation(array $optionalArgs = []) + { + $request = new GetLocationRequest(); + $requestParamHeaders = []; + if (isset($optionalArgs['name'])) { + $request->setName($optionalArgs['name']); + $requestParamHeaders['name'] = $optionalArgs['name']; + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetLocation', Location::class, $optionalArgs, $request, Call::UNARY_CALL, 'google.cloud.location.Locations')->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * Sample code: + * ``` + * $generatorsClient = new GeneratorsClient(); + * try { + * // Iterate over pages of elements + * $pagedResponse = $generatorsClient->listLocations(); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $generatorsClient->listLocations(); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $generatorsClient->close(); + * } + * ``` + * + * @param array $optionalArgs { + * Optional. + * + * @type string $name + * The resource that owns the locations collection, if applicable. + * @type string $filter + * The standard list filter. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listLocations(array $optionalArgs = []) + { + $request = new ListLocationsRequest(); + $requestParamHeaders = []; + if (isset($optionalArgs['name'])) { + $request->setName($optionalArgs['name']); + $requestParamHeaders['name'] = $optionalArgs['name']; + } + + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListLocations', $optionalArgs, ListLocationsResponse::class, $request, 'google.cloud.location.Locations'); + } +} diff --git a/DialogflowCx/src/V3/Gapic/SessionsGapicClient.php b/DialogflowCx/src/V3/Gapic/SessionsGapicClient.php index 7bf971d55f7d..1fff677b7874 100644 --- a/DialogflowCx/src/V3/Gapic/SessionsGapicClient.php +++ b/DialogflowCx/src/V3/Gapic/SessionsGapicClient.php @@ -34,6 +34,7 @@ use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback; use Google\Cloud\Dialogflow\Cx\V3\DetectIntentRequest; use Google\Cloud\Dialogflow\Cx\V3\DetectIntentResponse; use Google\Cloud\Dialogflow\Cx\V3\FulfillIntentRequest; @@ -46,10 +47,12 @@ use Google\Cloud\Dialogflow\Cx\V3\QueryParameters; use Google\Cloud\Dialogflow\Cx\V3\StreamingDetectIntentRequest; use Google\Cloud\Dialogflow\Cx\V3\StreamingDetectIntentResponse; +use Google\Cloud\Dialogflow\Cx\V3\SubmitAnswerFeedbackRequest; use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; +use Google\Protobuf\FieldMask; /** * Service Description: A session represents an interaction with a user. You retrieve user input @@ -100,6 +103,8 @@ class SessionsGapicClient private static $agentNameTemplate; + private static $dataStoreNameTemplate; + private static $entityTypeNameTemplate; private static $intentNameTemplate; @@ -114,6 +119,10 @@ class SessionsGapicClient private static $projectLocationAgentSessionEntityTypeNameTemplate; + private static $projectLocationCollectionDataStoreNameTemplate; + + private static $projectLocationDataStoreNameTemplate; + private static $sessionNameTemplate; private static $sessionEntityTypeNameTemplate; @@ -150,6 +159,15 @@ private static function getAgentNameTemplate() return self::$agentNameTemplate; } + private static function getDataStoreNameTemplate() + { + if (self::$dataStoreNameTemplate == null) { + self::$dataStoreNameTemplate = new PathTemplate('projects/{project}/locations/{location}/dataStores/{data_store}'); + } + + return self::$dataStoreNameTemplate; + } + private static function getEntityTypeNameTemplate() { if (self::$entityTypeNameTemplate == null) { @@ -213,6 +231,24 @@ private static function getProjectLocationAgentSessionEntityTypeNameTemplate() return self::$projectLocationAgentSessionEntityTypeNameTemplate; } + private static function getProjectLocationCollectionDataStoreNameTemplate() + { + if (self::$projectLocationCollectionDataStoreNameTemplate == null) { + self::$projectLocationCollectionDataStoreNameTemplate = new PathTemplate('projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}'); + } + + return self::$projectLocationCollectionDataStoreNameTemplate; + } + + private static function getProjectLocationDataStoreNameTemplate() + { + if (self::$projectLocationDataStoreNameTemplate == null) { + self::$projectLocationDataStoreNameTemplate = new PathTemplate('projects/{project}/locations/{location}/dataStores/{data_store}'); + } + + return self::$projectLocationDataStoreNameTemplate; + } + private static function getSessionNameTemplate() { if (self::$sessionNameTemplate == null) { @@ -245,6 +281,7 @@ private static function getPathTemplateMap() if (self::$pathTemplateMap == null) { self::$pathTemplateMap = [ 'agent' => self::getAgentNameTemplate(), + 'dataStore' => self::getDataStoreNameTemplate(), 'entityType' => self::getEntityTypeNameTemplate(), 'intent' => self::getIntentNameTemplate(), 'page' => self::getPageNameTemplate(), @@ -252,6 +289,8 @@ private static function getPathTemplateMap() 'projectLocationAgentEnvironmentSessionEntityType' => self::getProjectLocationAgentEnvironmentSessionEntityTypeNameTemplate(), 'projectLocationAgentSession' => self::getProjectLocationAgentSessionNameTemplate(), 'projectLocationAgentSessionEntityType' => self::getProjectLocationAgentSessionEntityTypeNameTemplate(), + 'projectLocationCollectionDataStore' => self::getProjectLocationCollectionDataStoreNameTemplate(), + 'projectLocationDataStore' => self::getProjectLocationDataStoreNameTemplate(), 'session' => self::getSessionNameTemplate(), 'sessionEntityType' => self::getSessionEntityTypeNameTemplate(), 'version' => self::getVersionNameTemplate(), @@ -280,6 +319,25 @@ public static function agentName($project, $location, $agent) ]); } + /** + * Formats a string containing the fully-qualified path to represent a data_store + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted data_store resource. + */ + public static function dataStoreName($project, $location, $dataStore) + { + return self::getDataStoreNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a entity_type * resource. @@ -437,6 +495,46 @@ public static function projectLocationAgentSessionEntityTypeName($project, $loca ]); } + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * + * @return string The formatted project_location_collection_data_store resource. + */ + public static function projectLocationCollectionDataStoreName($project, $location, $collection, $dataStore) + { + return self::getProjectLocationCollectionDataStoreNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted project_location_data_store resource. + */ + public static function projectLocationDataStoreName($project, $location, $dataStore) + { + return self::getProjectLocationDataStoreNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a session * resource. @@ -509,6 +607,7 @@ public static function versionName($project, $location, $agent, $flow, $version) * The following name formats are supported: * Template: Pattern * - agent: projects/{project}/locations/{location}/agents/{agent} + * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} * - entityType: projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type} * - intent: projects/{project}/locations/{location}/agents/{agent}/intents/{intent} * - page: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page} @@ -516,6 +615,8 @@ public static function versionName($project, $location, $agent, $flow, $version) * - projectLocationAgentEnvironmentSessionEntityType: projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/sessions/{session}/entityTypes/{entity_type} * - projectLocationAgentSession: projects/{project}/locations/{location}/agents/{agent}/sessions/{session} * - projectLocationAgentSessionEntityType: projects/{project}/locations/{location}/agents/{agent}/sessions/{session}/entityTypes/{entity_type} + * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} + * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} * - session: projects/{project}/locations/{location}/agents/{agent}/sessions/{session} * - sessionEntityType: projects/{project}/locations/{location}/agents/{agent}/sessions/{session}/entityTypes/{entity_type} * - version: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version} @@ -884,6 +985,60 @@ public function streamingDetectIntent(array $optionalArgs = []) return $this->startCall('StreamingDetectIntent', StreamingDetectIntentResponse::class, $optionalArgs, null, Call::BIDI_STREAMING_CALL); } + /** + * Updates the feedback received from the user for a single turn of the bot + * response. + * + * Sample code: + * ``` + * $sessionsClient = new SessionsClient(); + * try { + * $formattedSession = $sessionsClient->sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); + * $responseId = 'response_id'; + * $answerFeedback = new AnswerFeedback(); + * $response = $sessionsClient->submitAnswerFeedback($formattedSession, $responseId, $answerFeedback); + * } finally { + * $sessionsClient->close(); + * } + * ``` + * + * @param string $session Required. The name of the session the feedback was sent to. + * @param string $responseId Required. ID of the response to update its feedback. This is the same as + * DetectIntentResponse.response_id. + * @param AnswerFeedback $answerFeedback Required. Feedback provided for a bot answer. + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $updateMask + * Optional. The mask to control which fields to update. If the mask is not + * present, all fields will be updated. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback + * + * @throws ApiException if the remote call fails + */ + public function submitAnswerFeedback($session, $responseId, $answerFeedback, array $optionalArgs = []) + { + $request = new SubmitAnswerFeedbackRequest(); + $requestParamHeaders = []; + $request->setSession($session); + $request->setResponseId($responseId); + $request->setAnswerFeedback($answerFeedback); + $requestParamHeaders['session'] = $session; + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('SubmitAnswerFeedback', AnswerFeedback::class, $optionalArgs, $request)->wait(); + } + /** * Gets information about a location. * diff --git a/DialogflowCx/src/V3/Generator.php b/DialogflowCx/src/V3/Generator.php new file mode 100644 index 000000000000..ecfa207613e0 --- /dev/null +++ b/DialogflowCx/src/V3/Generator.php @@ -0,0 +1,214 @@ +google.cloud.dialogflow.cx.v3.Generator + */ +class Generator extends \Google\Protobuf\Internal\Message +{ + /** + * The unique identifier of the generator. + * Must be set for the + * [Generators.UpdateGenerator][google.cloud.dialogflow.cx.v3.Generators.UpdateGenerator] + * method. [Generators.CreateGenerate][] populates the name automatically. + * Format: `projects//locations//agents//generators/`. + * + * Generated from protobuf field string name = 1; + */ + protected $name = ''; + /** + * Required. The human-readable name of the generator, unique within the + * agent. The prompt contains pre-defined parameters such as $conversation, + * $last-user-utterance, etc. populated by Dialogflow. It can also contain + * custom placeholders which will be resolved during fulfillment. + * + * Generated from protobuf field string display_name = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $display_name = ''; + /** + * Required. Prompt for the LLM model. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.Phrase prompt_text = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $prompt_text = null; + /** + * Optional. List of custom placeholders in the prompt text. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.Generator.Placeholder placeholders = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $placeholders; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * The unique identifier of the generator. + * Must be set for the + * [Generators.UpdateGenerator][google.cloud.dialogflow.cx.v3.Generators.UpdateGenerator] + * method. [Generators.CreateGenerate][] populates the name automatically. + * Format: `projects//locations//agents//generators/`. + * @type string $display_name + * Required. The human-readable name of the generator, unique within the + * agent. The prompt contains pre-defined parameters such as $conversation, + * $last-user-utterance, etc. populated by Dialogflow. It can also contain + * custom placeholders which will be resolved during fulfillment. + * @type \Google\Cloud\Dialogflow\Cx\V3\Phrase $prompt_text + * Required. Prompt for the LLM model. + * @type array<\Google\Cloud\Dialogflow\Cx\V3\Generator\Placeholder>|\Google\Protobuf\Internal\RepeatedField $placeholders + * Optional. List of custom placeholders in the prompt text. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Generator::initOnce(); + parent::__construct($data); + } + + /** + * The unique identifier of the generator. + * Must be set for the + * [Generators.UpdateGenerator][google.cloud.dialogflow.cx.v3.Generators.UpdateGenerator] + * method. [Generators.CreateGenerate][] populates the name automatically. + * Format: `projects//locations//agents//generators/`. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The unique identifier of the generator. + * Must be set for the + * [Generators.UpdateGenerator][google.cloud.dialogflow.cx.v3.Generators.UpdateGenerator] + * method. [Generators.CreateGenerate][] populates the name automatically. + * Format: `projects//locations//agents//generators/`. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. The human-readable name of the generator, unique within the + * agent. The prompt contains pre-defined parameters such as $conversation, + * $last-user-utterance, etc. populated by Dialogflow. It can also contain + * custom placeholders which will be resolved during fulfillment. + * + * Generated from protobuf field string display_name = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getDisplayName() + { + return $this->display_name; + } + + /** + * Required. The human-readable name of the generator, unique within the + * agent. The prompt contains pre-defined parameters such as $conversation, + * $last-user-utterance, etc. populated by Dialogflow. It can also contain + * custom placeholders which will be resolved during fulfillment. + * + * Generated from protobuf field string display_name = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->display_name = $var; + + return $this; + } + + /** + * Required. Prompt for the LLM model. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.Phrase prompt_text = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Dialogflow\Cx\V3\Phrase|null + */ + public function getPromptText() + { + return $this->prompt_text; + } + + public function hasPromptText() + { + return isset($this->prompt_text); + } + + public function clearPromptText() + { + unset($this->prompt_text); + } + + /** + * Required. Prompt for the LLM model. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.Phrase prompt_text = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Dialogflow\Cx\V3\Phrase $var + * @return $this + */ + public function setPromptText($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\Cx\V3\Phrase::class); + $this->prompt_text = $var; + + return $this; + } + + /** + * Optional. List of custom placeholders in the prompt text. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.Generator.Placeholder placeholders = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPlaceholders() + { + return $this->placeholders; + } + + /** + * Optional. List of custom placeholders in the prompt text. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.Generator.Placeholder placeholders = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param array<\Google\Cloud\Dialogflow\Cx\V3\Generator\Placeholder>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPlaceholders($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\Cx\V3\Generator\Placeholder::class); + $this->placeholders = $arr; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/Generator/Placeholder.php b/DialogflowCx/src/V3/Generator/Placeholder.php new file mode 100644 index 000000000000..df273ba9966b --- /dev/null +++ b/DialogflowCx/src/V3/Generator/Placeholder.php @@ -0,0 +1,102 @@ +google.cloud.dialogflow.cx.v3.Generator.Placeholder + */ +class Placeholder extends \Google\Protobuf\Internal\Message +{ + /** + * Unique ID used to map custom placeholder to parameters in fulfillment. + * + * Generated from protobuf field string id = 1; + */ + protected $id = ''; + /** + * Custom placeholder value in the prompt text. + * + * Generated from protobuf field string name = 2; + */ + protected $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $id + * Unique ID used to map custom placeholder to parameters in fulfillment. + * @type string $name + * Custom placeholder value in the prompt text. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Generator::initOnce(); + parent::__construct($data); + } + + /** + * Unique ID used to map custom placeholder to parameters in fulfillment. + * + * Generated from protobuf field string id = 1; + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Unique ID used to map custom placeholder to parameters in fulfillment. + * + * Generated from protobuf field string id = 1; + * @param string $var + * @return $this + */ + public function setId($var) + { + GPBUtil::checkString($var, True); + $this->id = $var; + + return $this; + } + + /** + * Custom placeholder value in the prompt text. + * + * Generated from protobuf field string name = 2; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Custom placeholder value in the prompt text. + * + * Generated from protobuf field string name = 2; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + + diff --git a/DialogflowCx/src/V3/GeneratorsClient.php b/DialogflowCx/src/V3/GeneratorsClient.php new file mode 100644 index 000000000000..16771a3ba24e --- /dev/null +++ b/DialogflowCx/src/V3/GeneratorsClient.php @@ -0,0 +1,34 @@ +google.cloud.dialogflow.cx.v3.GetGeneratorRequest + */ +class GetGeneratorRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the generator. + * Format: `projects//locations//agents//generators/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * The language to list generators for. + * + * Generated from protobuf field string language_code = 2; + */ + protected $language_code = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the generator. + * Format: `projects//locations//agents//generators/`. + * @type string $language_code + * The language to list generators for. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Generator::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the generator. + * Format: `projects//locations//agents//generators/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The name of the generator. + * Format: `projects//locations//agents//generators/`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The language to list generators for. + * + * Generated from protobuf field string language_code = 2; + * @return string + */ + public function getLanguageCode() + { + return $this->language_code; + } + + /** + * The language to list generators for. + * + * Generated from protobuf field string language_code = 2; + * @param string $var + * @return $this + */ + public function setLanguageCode($var) + { + GPBUtil::checkString($var, True); + $this->language_code = $var; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/InputAudioConfig.php b/DialogflowCx/src/V3/InputAudioConfig.php index 7eb6ddfa3cc9..caba5fe00fbe 100644 --- a/DialogflowCx/src/V3/InputAudioConfig.php +++ b/DialogflowCx/src/V3/InputAudioConfig.php @@ -55,8 +55,8 @@ class InputAudioConfig extends \Google\Protobuf\Internal\Message /** * Optional. Which Speech model to select for the given request. Select the * model best suited to your domain to get best results. If a model is not - * explicitly specified, then we auto-select a model based on the parameters - * in the InputAudioConfig. + * explicitly specified, then Dialogflow auto-selects a model based on other + * parameters in the InputAudioConfig and Agent settings. * If enhanced speech model is enabled for the agent and an enhanced * version of the specified model for the language does not exist, then the * speech is recognized using the standard version of the specified model. @@ -68,7 +68,11 @@ class InputAudioConfig extends \Google\Protobuf\Internal\Message * performance: * - phone_call (best for Agent Assist and telephony) * - latest_short (best for Dialogflow non-telephony) - * - command_and_search (best for very short utterances and commands) + * - command_and_search + * Leave this field unspecified to use + * [Agent Speech + * settings](https://cloud.google.com/dialogflow/cx/docs/concept/agent#settings-speech) + * for model selection. * * Generated from protobuf field string model = 7; */ @@ -93,6 +97,12 @@ class InputAudioConfig extends \Google\Protobuf\Internal\Message * Generated from protobuf field bool single_utterance = 8; */ protected $single_utterance = false; + /** + * Configuration of barge-in behavior during the streaming of input audio. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.BargeInConfig barge_in_config = 15; + */ + protected $barge_in_config = null; /** * Constructor. @@ -124,8 +134,8 @@ class InputAudioConfig extends \Google\Protobuf\Internal\Message * @type string $model * Optional. Which Speech model to select for the given request. Select the * model best suited to your domain to get best results. If a model is not - * explicitly specified, then we auto-select a model based on the parameters - * in the InputAudioConfig. + * explicitly specified, then Dialogflow auto-selects a model based on other + * parameters in the InputAudioConfig and Agent settings. * If enhanced speech model is enabled for the agent and an enhanced * version of the specified model for the language does not exist, then the * speech is recognized using the standard version of the specified model. @@ -137,7 +147,11 @@ class InputAudioConfig extends \Google\Protobuf\Internal\Message * performance: * - phone_call (best for Agent Assist and telephony) * - latest_short (best for Dialogflow non-telephony) - * - command_and_search (best for very short utterances and commands) + * - command_and_search + * Leave this field unspecified to use + * [Agent Speech + * settings](https://cloud.google.com/dialogflow/cx/docs/concept/agent#settings-speech) + * for model selection. * @type int $model_variant * Optional. Which variant of the [Speech * model][google.cloud.dialogflow.cx.v3.InputAudioConfig.model] to use. @@ -150,6 +164,8 @@ class InputAudioConfig extends \Google\Protobuf\Internal\Message * client should close the stream and start a new request with a new stream as * needed. * Note: This setting is relevant only for streaming methods. + * @type \Google\Cloud\Dialogflow\Cx\V3\BargeInConfig $barge_in_config + * Configuration of barge-in behavior during the streaming of input audio. * } */ public function __construct($data = NULL) { @@ -290,8 +306,8 @@ public function setPhraseHints($var) /** * Optional. Which Speech model to select for the given request. Select the * model best suited to your domain to get best results. If a model is not - * explicitly specified, then we auto-select a model based on the parameters - * in the InputAudioConfig. + * explicitly specified, then Dialogflow auto-selects a model based on other + * parameters in the InputAudioConfig and Agent settings. * If enhanced speech model is enabled for the agent and an enhanced * version of the specified model for the language does not exist, then the * speech is recognized using the standard version of the specified model. @@ -303,7 +319,11 @@ public function setPhraseHints($var) * performance: * - phone_call (best for Agent Assist and telephony) * - latest_short (best for Dialogflow non-telephony) - * - command_and_search (best for very short utterances and commands) + * - command_and_search + * Leave this field unspecified to use + * [Agent Speech + * settings](https://cloud.google.com/dialogflow/cx/docs/concept/agent#settings-speech) + * for model selection. * * Generated from protobuf field string model = 7; * @return string @@ -316,8 +336,8 @@ public function getModel() /** * Optional. Which Speech model to select for the given request. Select the * model best suited to your domain to get best results. If a model is not - * explicitly specified, then we auto-select a model based on the parameters - * in the InputAudioConfig. + * explicitly specified, then Dialogflow auto-selects a model based on other + * parameters in the InputAudioConfig and Agent settings. * If enhanced speech model is enabled for the agent and an enhanced * version of the specified model for the language does not exist, then the * speech is recognized using the standard version of the specified model. @@ -329,7 +349,11 @@ public function getModel() * performance: * - phone_call (best for Agent Assist and telephony) * - latest_short (best for Dialogflow non-telephony) - * - command_and_search (best for very short utterances and commands) + * - command_and_search + * Leave this field unspecified to use + * [Agent Speech + * settings](https://cloud.google.com/dialogflow/cx/docs/concept/agent#settings-speech) + * for model selection. * * Generated from protobuf field string model = 7; * @param string $var @@ -411,5 +435,41 @@ public function setSingleUtterance($var) return $this; } + /** + * Configuration of barge-in behavior during the streaming of input audio. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.BargeInConfig barge_in_config = 15; + * @return \Google\Cloud\Dialogflow\Cx\V3\BargeInConfig|null + */ + public function getBargeInConfig() + { + return $this->barge_in_config; + } + + public function hasBargeInConfig() + { + return isset($this->barge_in_config); + } + + public function clearBargeInConfig() + { + unset($this->barge_in_config); + } + + /** + * Configuration of barge-in behavior during the streaming of input audio. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.BargeInConfig barge_in_config = 15; + * @param \Google\Cloud\Dialogflow\Cx\V3\BargeInConfig $var + * @return $this + */ + public function setBargeInConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\Cx\V3\BargeInConfig::class); + $this->barge_in_config = $var; + + return $this; + } + } diff --git a/DialogflowCx/src/V3/ListGeneratorsRequest.php b/DialogflowCx/src/V3/ListGeneratorsRequest.php new file mode 100644 index 000000000000..49d3ddef2d77 --- /dev/null +++ b/DialogflowCx/src/V3/ListGeneratorsRequest.php @@ -0,0 +1,178 @@ +google.cloud.dialogflow.cx.v3.ListGeneratorsRequest + */ +class ListGeneratorsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The agent to list all generators for. + * Format: `projects//locations//agents/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * The language to list generators for. + * + * Generated from protobuf field string language_code = 2; + */ + protected $language_code = ''; + /** + * The maximum number of items to return in a single page. By default 100 and + * at most 1000. + * + * Generated from protobuf field int32 page_size = 3; + */ + protected $page_size = 0; + /** + * The next_page_token value returned from a previous list request. + * + * Generated from protobuf field string page_token = 4; + */ + protected $page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The agent to list all generators for. + * Format: `projects//locations//agents/`. + * @type string $language_code + * The language to list generators for. + * @type int $page_size + * The maximum number of items to return in a single page. By default 100 and + * at most 1000. + * @type string $page_token + * The next_page_token value returned from a previous list request. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Generator::initOnce(); + parent::__construct($data); + } + + /** + * Required. The agent to list all generators for. + * Format: `projects//locations//agents/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The agent to list all generators for. + * Format: `projects//locations//agents/`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * The language to list generators for. + * + * Generated from protobuf field string language_code = 2; + * @return string + */ + public function getLanguageCode() + { + return $this->language_code; + } + + /** + * The language to list generators for. + * + * Generated from protobuf field string language_code = 2; + * @param string $var + * @return $this + */ + public function setLanguageCode($var) + { + GPBUtil::checkString($var, True); + $this->language_code = $var; + + return $this; + } + + /** + * The maximum number of items to return in a single page. By default 100 and + * at most 1000. + * + * Generated from protobuf field int32 page_size = 3; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * The maximum number of items to return in a single page. By default 100 and + * at most 1000. + * + * Generated from protobuf field int32 page_size = 3; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * The next_page_token value returned from a previous list request. + * + * Generated from protobuf field string page_token = 4; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * The next_page_token value returned from a previous list request. + * + * Generated from protobuf field string page_token = 4; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/ListGeneratorsResponse.php b/DialogflowCx/src/V3/ListGeneratorsResponse.php new file mode 100644 index 000000000000..f66e1e370fc6 --- /dev/null +++ b/DialogflowCx/src/V3/ListGeneratorsResponse.php @@ -0,0 +1,110 @@ +google.cloud.dialogflow.cx.v3.ListGeneratorsResponse + */ +class ListGeneratorsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of generators. There will be a maximum number of items returned + * based on the page_size field in the request. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.Generator generators = 1; + */ + private $generators; + /** + * Token to retrieve the next page of results, or empty if there are no more + * results in the list. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Dialogflow\Cx\V3\Generator>|\Google\Protobuf\Internal\RepeatedField $generators + * The list of generators. There will be a maximum number of items returned + * based on the page_size field in the request. + * @type string $next_page_token + * Token to retrieve the next page of results, or empty if there are no more + * results in the list. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Generator::initOnce(); + parent::__construct($data); + } + + /** + * The list of generators. There will be a maximum number of items returned + * based on the page_size field in the request. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.Generator generators = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getGenerators() + { + return $this->generators; + } + + /** + * The list of generators. There will be a maximum number of items returned + * based on the page_size field in the request. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.Generator generators = 1; + * @param array<\Google\Cloud\Dialogflow\Cx\V3\Generator>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setGenerators($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\Cx\V3\Generator::class); + $this->generators = $arr; + + return $this; + } + + /** + * Token to retrieve the next page of results, or empty if there are no more + * results in the list. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * Token to retrieve the next page of results, or empty if there are no more + * results in the list. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/Phrase.php b/DialogflowCx/src/V3/Phrase.php new file mode 100644 index 000000000000..e5a15744098e --- /dev/null +++ b/DialogflowCx/src/V3/Phrase.php @@ -0,0 +1,67 @@ +google.cloud.dialogflow.cx.v3.Phrase + */ +class Phrase extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Text input which can be used for prompt or banned phrases. + * + * Generated from protobuf field string text = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $text = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $text + * Required. Text input which can be used for prompt or banned phrases. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Generator::initOnce(); + parent::__construct($data); + } + + /** + * Required. Text input which can be used for prompt or banned phrases. + * + * Generated from protobuf field string text = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Required. Text input which can be used for prompt or banned phrases. + * + * Generated from protobuf field string text = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setText($var) + { + GPBUtil::checkString($var, True); + $this->text = $var; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/QueryParameters.php b/DialogflowCx/src/V3/QueryParameters.php index 238b2eda2a52..eb6f95fb686d 100644 --- a/DialogflowCx/src/V3/QueryParameters.php +++ b/DialogflowCx/src/V3/QueryParameters.php @@ -158,6 +158,31 @@ class QueryParameters extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.protobuf.Duration session_ttl = 16 [(.google.api.field_behavior) = OPTIONAL]; */ protected $session_ttl = null; + /** + * Optional. Information about the end-user to improve the relevance and + * accuracy of generative answers. + * This will be interpreted and used by a language model, so, for good + * results, the data should be self-descriptive, and in a simple structure. + * Example: + * ```json + * { + * "subscription plan": "Business Premium Plus", + * "devices owned": [ + * {"model": "Google Pixel 7"}, + * {"model": "Google Pixel Tablet"} + * ] + * } + * ``` + * + * Generated from protobuf field .google.protobuf.Struct end_user_metadata = 18 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $end_user_metadata = null; + /** + * Optional. Search configuration for UCS search queries. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.SearchConfig search_config = 20 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $search_config = null; /** * Constructor. @@ -260,6 +285,23 @@ class QueryParameters extends \Google\Protobuf\Internal\Message * By default, a Dialogflow session remains active and its data is stored for * 30 minutes after the last request is sent for the session. * This value should be no longer than 1 day. + * @type \Google\Protobuf\Struct $end_user_metadata + * Optional. Information about the end-user to improve the relevance and + * accuracy of generative answers. + * This will be interpreted and used by a language model, so, for good + * results, the data should be self-descriptive, and in a simple structure. + * Example: + * ```json + * { + * "subscription plan": "Business Premium Plus", + * "devices owned": [ + * {"model": "Google Pixel 7"}, + * {"model": "Google Pixel Tablet"} + * ] + * } + * ``` + * @type \Google\Cloud\Dialogflow\Cx\V3\SearchConfig $search_config + * Optional. Search configuration for UCS search queries. * } */ public function __construct($data = NULL) { @@ -761,5 +803,103 @@ public function setSessionTtl($var) return $this; } + /** + * Optional. Information about the end-user to improve the relevance and + * accuracy of generative answers. + * This will be interpreted and used by a language model, so, for good + * results, the data should be self-descriptive, and in a simple structure. + * Example: + * ```json + * { + * "subscription plan": "Business Premium Plus", + * "devices owned": [ + * {"model": "Google Pixel 7"}, + * {"model": "Google Pixel Tablet"} + * ] + * } + * ``` + * + * Generated from protobuf field .google.protobuf.Struct end_user_metadata = 18 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Struct|null + */ + public function getEndUserMetadata() + { + return $this->end_user_metadata; + } + + public function hasEndUserMetadata() + { + return isset($this->end_user_metadata); + } + + public function clearEndUserMetadata() + { + unset($this->end_user_metadata); + } + + /** + * Optional. Information about the end-user to improve the relevance and + * accuracy of generative answers. + * This will be interpreted and used by a language model, so, for good + * results, the data should be self-descriptive, and in a simple structure. + * Example: + * ```json + * { + * "subscription plan": "Business Premium Plus", + * "devices owned": [ + * {"model": "Google Pixel 7"}, + * {"model": "Google Pixel Tablet"} + * ] + * } + * ``` + * + * Generated from protobuf field .google.protobuf.Struct end_user_metadata = 18 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\Struct $var + * @return $this + */ + public function setEndUserMetadata($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class); + $this->end_user_metadata = $var; + + return $this; + } + + /** + * Optional. Search configuration for UCS search queries. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.SearchConfig search_config = 20 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Dialogflow\Cx\V3\SearchConfig|null + */ + public function getSearchConfig() + { + return $this->search_config; + } + + public function hasSearchConfig() + { + return isset($this->search_config); + } + + public function clearSearchConfig() + { + unset($this->search_config); + } + + /** + * Optional. Search configuration for UCS search queries. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.SearchConfig search_config = 20 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Dialogflow\Cx\V3\SearchConfig $var + * @return $this + */ + public function setSearchConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\Cx\V3\SearchConfig::class); + $this->search_config = $var; + + return $this; + } + } diff --git a/DialogflowCx/src/V3/QueryResult.php b/DialogflowCx/src/V3/QueryResult.php index 7a4ab40c86b2..50a556025a23 100644 --- a/DialogflowCx/src/V3/QueryResult.php +++ b/DialogflowCx/src/V3/QueryResult.php @@ -145,6 +145,13 @@ class QueryResult extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.cloud.dialogflow.cx.v3.AdvancedSettings advanced_settings = 21; */ protected $advanced_settings = null; + /** + * Indicates whether the Thumbs up/Thumbs down rating controls are need to be + * shown for the response in the Dialogflow Messenger widget. + * + * Generated from protobuf field bool allow_answer_feedback = 32; + */ + protected $allow_answer_feedback = false; protected $query; /** @@ -252,6 +259,9 @@ class QueryResult extends \Google\Protobuf\Internal\Message * the client may need to perform special logic at the moment. For example, if * Dialogflow exports audio to Google Cloud Storage, then the client may need * to wait for the resulting object to appear in the bucket before proceeding. + * @type bool $allow_answer_feedback + * Indicates whether the Thumbs up/Thumbs down rating controls are need to be + * shown for the response in the Dialogflow Messenger widget. * } */ public function __construct($data = NULL) { @@ -936,6 +946,34 @@ public function setAdvancedSettings($var) return $this; } + /** + * Indicates whether the Thumbs up/Thumbs down rating controls are need to be + * shown for the response in the Dialogflow Messenger widget. + * + * Generated from protobuf field bool allow_answer_feedback = 32; + * @return bool + */ + public function getAllowAnswerFeedback() + { + return $this->allow_answer_feedback; + } + + /** + * Indicates whether the Thumbs up/Thumbs down rating controls are need to be + * shown for the response in the Dialogflow Messenger widget. + * + * Generated from protobuf field bool allow_answer_feedback = 32; + * @param bool $var + * @return $this + */ + public function setAllowAnswerFeedback($var) + { + GPBUtil::checkBool($var); + $this->allow_answer_feedback = $var; + + return $this; + } + /** * @return string */ diff --git a/DialogflowCx/src/V3/SearchConfig.php b/DialogflowCx/src/V3/SearchConfig.php new file mode 100644 index 000000000000..5707ad2e73bd --- /dev/null +++ b/DialogflowCx/src/V3/SearchConfig.php @@ -0,0 +1,101 @@ +google.cloud.dialogflow.cx.v3.SearchConfig + */ +class SearchConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Boosting configuration for the datastores. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.BoostSpecs boost_specs = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $boost_specs; + /** + * Optional. Filter configuration for the datastores. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.FilterSpecs filter_specs = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $filter_specs; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Dialogflow\Cx\V3\BoostSpecs>|\Google\Protobuf\Internal\RepeatedField $boost_specs + * Optional. Boosting configuration for the datastores. + * @type array<\Google\Cloud\Dialogflow\Cx\V3\FilterSpecs>|\Google\Protobuf\Internal\RepeatedField $filter_specs + * Optional. Filter configuration for the datastores. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Session::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Boosting configuration for the datastores. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.BoostSpecs boost_specs = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getBoostSpecs() + { + return $this->boost_specs; + } + + /** + * Optional. Boosting configuration for the datastores. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.BoostSpecs boost_specs = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param array<\Google\Cloud\Dialogflow\Cx\V3\BoostSpecs>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setBoostSpecs($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\Cx\V3\BoostSpecs::class); + $this->boost_specs = $arr; + + return $this; + } + + /** + * Optional. Filter configuration for the datastores. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.FilterSpecs filter_specs = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getFilterSpecs() + { + return $this->filter_specs; + } + + /** + * Optional. Filter configuration for the datastores. + * + * Generated from protobuf field repeated .google.cloud.dialogflow.cx.v3.FilterSpecs filter_specs = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param array<\Google\Cloud\Dialogflow\Cx\V3\FilterSpecs>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setFilterSpecs($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\Cx\V3\FilterSpecs::class); + $this->filter_specs = $arr; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/SubmitAnswerFeedbackRequest.php b/DialogflowCx/src/V3/SubmitAnswerFeedbackRequest.php new file mode 100644 index 000000000000..58052fdac077 --- /dev/null +++ b/DialogflowCx/src/V3/SubmitAnswerFeedbackRequest.php @@ -0,0 +1,197 @@ +google.cloud.dialogflow.cx.v3.SubmitAnswerFeedbackRequest + */ +class SubmitAnswerFeedbackRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the session the feedback was sent to. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $session = ''; + /** + * Required. ID of the response to update its feedback. This is the same as + * DetectIntentResponse.response_id. + * + * Generated from protobuf field string response_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $response_id = ''; + /** + * Required. Feedback provided for a bot answer. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.AnswerFeedback answer_feedback = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $answer_feedback = null; + /** + * Optional. The mask to control which fields to update. If the mask is not + * present, all fields will be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $update_mask = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $session + * Required. The name of the session the feedback was sent to. + * @type string $response_id + * Required. ID of the response to update its feedback. This is the same as + * DetectIntentResponse.response_id. + * @type \Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback $answer_feedback + * Required. Feedback provided for a bot answer. + * @type \Google\Protobuf\FieldMask $update_mask + * Optional. The mask to control which fields to update. If the mask is not + * present, all fields will be updated. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Session::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the session the feedback was sent to. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getSession() + { + return $this->session; + } + + /** + * Required. The name of the session the feedback was sent to. + * + * Generated from protobuf field string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setSession($var) + { + GPBUtil::checkString($var, True); + $this->session = $var; + + return $this; + } + + /** + * Required. ID of the response to update its feedback. This is the same as + * DetectIntentResponse.response_id. + * + * Generated from protobuf field string response_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getResponseId() + { + return $this->response_id; + } + + /** + * Required. ID of the response to update its feedback. This is the same as + * DetectIntentResponse.response_id. + * + * Generated from protobuf field string response_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setResponseId($var) + { + GPBUtil::checkString($var, True); + $this->response_id = $var; + + return $this; + } + + /** + * Required. Feedback provided for a bot answer. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.AnswerFeedback answer_feedback = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback|null + */ + public function getAnswerFeedback() + { + return $this->answer_feedback; + } + + public function hasAnswerFeedback() + { + return isset($this->answer_feedback); + } + + public function clearAnswerFeedback() + { + unset($this->answer_feedback); + } + + /** + * Required. Feedback provided for a bot answer. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.AnswerFeedback answer_feedback = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback $var + * @return $this + */ + public function setAnswerFeedback($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback::class); + $this->answer_feedback = $var; + + return $this; + } + + /** + * Optional. The mask to control which fields to update. If the mask is not + * present, all fields will be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * Optional. The mask to control which fields to update. If the mask is not + * present, all fields will be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/UpdateGeneratorRequest.php b/DialogflowCx/src/V3/UpdateGeneratorRequest.php new file mode 100644 index 000000000000..b9533fc00423 --- /dev/null +++ b/DialogflowCx/src/V3/UpdateGeneratorRequest.php @@ -0,0 +1,160 @@ +google.cloud.dialogflow.cx.v3.UpdateGeneratorRequest + */ +class UpdateGeneratorRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The generator to update. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.Generator generator = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $generator = null; + /** + * The language to list generators for. + * + * Generated from protobuf field string language_code = 2; + */ + protected $language_code = ''; + /** + * The mask to control which fields get updated. If the mask is not present, + * all fields will be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; + */ + protected $update_mask = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Dialogflow\Cx\V3\Generator $generator + * Required. The generator to update. + * @type string $language_code + * The language to list generators for. + * @type \Google\Protobuf\FieldMask $update_mask + * The mask to control which fields get updated. If the mask is not present, + * all fields will be updated. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dialogflow\Cx\V3\Generator::initOnce(); + parent::__construct($data); + } + + /** + * Required. The generator to update. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.Generator generator = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Dialogflow\Cx\V3\Generator|null + */ + public function getGenerator() + { + return $this->generator; + } + + public function hasGenerator() + { + return isset($this->generator); + } + + public function clearGenerator() + { + unset($this->generator); + } + + /** + * Required. The generator to update. + * + * Generated from protobuf field .google.cloud.dialogflow.cx.v3.Generator generator = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Dialogflow\Cx\V3\Generator $var + * @return $this + */ + public function setGenerator($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\Cx\V3\Generator::class); + $this->generator = $var; + + return $this; + } + + /** + * The language to list generators for. + * + * Generated from protobuf field string language_code = 2; + * @return string + */ + public function getLanguageCode() + { + return $this->language_code; + } + + /** + * The language to list generators for. + * + * Generated from protobuf field string language_code = 2; + * @param string $var + * @return $this + */ + public function setLanguageCode($var) + { + GPBUtil::checkString($var, True); + $this->language_code = $var; + + return $this; + } + + /** + * The mask to control which fields get updated. If the mask is not present, + * all fields will be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * The mask to control which fields get updated. If the mask is not present, + * all fields will be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + +} + diff --git a/DialogflowCx/src/V3/gapic_metadata.json b/DialogflowCx/src/V3/gapic_metadata.json index 96de7ba87aca..073996c4a206 100644 --- a/DialogflowCx/src/V3/gapic_metadata.json +++ b/DialogflowCx/src/V3/gapic_metadata.json @@ -417,6 +417,11 @@ "streamingDetectIntent" ] }, + "SubmitAnswerFeedback": { + "methods": [ + "submitAnswerFeedback" + ] + }, "GetLocation": { "methods": [ "getLocation" @@ -716,6 +721,50 @@ } } }, + "Generators": { + "clients": { + "grpc": { + "libraryClient": "GeneratorsGapicClient", + "rpcs": { + "CreateGenerator": { + "methods": [ + "createGenerator" + ] + }, + "DeleteGenerator": { + "methods": [ + "deleteGenerator" + ] + }, + "GetGenerator": { + "methods": [ + "getGenerator" + ] + }, + "ListGenerators": { + "methods": [ + "listGenerators" + ] + }, + "UpdateGenerator": { + "methods": [ + "updateGenerator" + ] + }, + "GetLocation": { + "methods": [ + "getLocation" + ] + }, + "ListLocations": { + "methods": [ + "listLocations" + ] + } + } + } + } + }, "SecuritySettingsService": { "clients": { "grpc": { diff --git a/DialogflowCx/src/V3/resources/generators_client_config.json b/DialogflowCx/src/V3/resources/generators_client_config.json new file mode 100644 index 000000000000..905579ccb0b3 --- /dev/null +++ b/DialogflowCx/src/V3/resources/generators_client_config.json @@ -0,0 +1,69 @@ +{ + "interfaces": { + "google.cloud.dialogflow.cx.v3.Generators": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_1_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 60000 + } + }, + "methods": { + "CreateGenerator": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "DeleteGenerator": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetGenerator": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListGenerators": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "UpdateGenerator": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetLocation": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListLocations": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + } + } + } + } +} diff --git a/DialogflowCx/src/V3/resources/generators_descriptor_config.php b/DialogflowCx/src/V3/resources/generators_descriptor_config.php new file mode 100644 index 000000000000..991f2a0163ac --- /dev/null +++ b/DialogflowCx/src/V3/resources/generators_descriptor_config.php @@ -0,0 +1,32 @@ + [ + 'google.cloud.dialogflow.cx.v3.Generators' => [ + 'ListGenerators' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getGenerators', + ], + ], + 'GetLocation' => [ + 'interfaceOverride' => 'google.cloud.location.Locations', + ], + 'ListLocations' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getLocations', + ], + 'interfaceOverride' => 'google.cloud.location.Locations', + ], + ], + ], +]; diff --git a/DialogflowCx/src/V3/resources/generators_rest_client_config.php b/DialogflowCx/src/V3/resources/generators_rest_client_config.php new file mode 100644 index 000000000000..de0883d2fda5 --- /dev/null +++ b/DialogflowCx/src/V3/resources/generators_rest_client_config.php @@ -0,0 +1,144 @@ + [ + 'google.cloud.dialogflow.cx.v3.Generators' => [ + 'CreateGenerator' => [ + 'method' => 'post', + 'uriTemplate' => '/v3/{parent=projects/*/locations/*/agents/*}/generators', + 'body' => 'generator', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteGenerator' => [ + 'method' => 'delete', + 'uriTemplate' => '/v3/{name=projects/*/locations/*/agents/*/generators/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetGenerator' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*/locations/*/agents/*/generators/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListGenerators' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{parent=projects/*/locations/*/agents/*}/generators', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateGenerator' => [ + 'method' => 'patch', + 'uriTemplate' => '/v3/{generator.name=projects/*/locations/*/agents/*/generators/*}', + 'body' => 'generator', + 'placeholders' => [ + 'generator.name' => [ + 'getters' => [ + 'getGenerator', + 'getName', + ], + ], + ], + ], + ], + 'google.cloud.location.Locations' => [ + 'GetLocation' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*/locations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListLocations' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*}/locations', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v3/{name=projects/*/operations/*}:cancel', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v3/{name=projects/*/locations/*/operations/*}:cancel', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*/operations/*}', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*/locations/*/operations/*}', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*}/operations', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*/locations/*}/operations', + ], + ], + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/DialogflowCx/src/V3/resources/sessions_client_config.json b/DialogflowCx/src/V3/resources/sessions_client_config.json index c9d5f66794ce..e82d7cfdbb8b 100644 --- a/DialogflowCx/src/V3/resources/sessions_client_config.json +++ b/DialogflowCx/src/V3/resources/sessions_client_config.json @@ -68,6 +68,11 @@ "StreamingDetectIntent": { "timeout_millis": 220000 }, + "SubmitAnswerFeedback": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, "GetLocation": { "timeout_millis": 60000, "retry_codes_name": "retry_policy_1_codes", diff --git a/DialogflowCx/src/V3/resources/sessions_rest_client_config.php b/DialogflowCx/src/V3/resources/sessions_rest_client_config.php index 81ae0fce66b6..5ac70f88b828 100644 --- a/DialogflowCx/src/V3/resources/sessions_rest_client_config.php +++ b/DialogflowCx/src/V3/resources/sessions_rest_client_config.php @@ -61,6 +61,18 @@ ], ], ], + 'SubmitAnswerFeedback' => [ + 'method' => 'post', + 'uriTemplate' => '/v3/{session=projects/*/locations/*/agents/*/sessions/*}:submitAnswerFeedback', + 'body' => '*', + 'placeholders' => [ + 'session' => [ + 'getters' => [ + 'getSession', + ], + ], + ], + ], ], 'google.cloud.location.Locations' => [ 'GetLocation' => [ diff --git a/DialogflowCx/tests/Unit/V3/GeneratorsClientTest.php b/DialogflowCx/tests/Unit/V3/GeneratorsClientTest.php new file mode 100644 index 000000000000..f1b422a65d87 --- /dev/null +++ b/DialogflowCx/tests/Unit/V3/GeneratorsClientTest.php @@ -0,0 +1,525 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return GeneratorsClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new GeneratorsClient($options); + } + + /** @test */ + public function createGeneratorTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $expectedResponse = new Generator(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $generator = new Generator(); + $generatorDisplayName = 'generatorDisplayName421654938'; + $generator->setDisplayName($generatorDisplayName); + $generatorPromptText = new Phrase(); + $promptTextText = 'promptTextText-1712080514'; + $generatorPromptText->setText($promptTextText); + $generator->setPromptText($generatorPromptText); + $response = $gapicClient->createGenerator($formattedParent, $generator); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.dialogflow.cx.v3.Generators/CreateGenerator', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getGenerator(); + $this->assertProtobufEquals($generator, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createGeneratorExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $generator = new Generator(); + $generatorDisplayName = 'generatorDisplayName421654938'; + $generator->setDisplayName($generatorDisplayName); + $generatorPromptText = new Phrase(); + $promptTextText = 'promptTextText-1712080514'; + $generatorPromptText->setText($promptTextText); + $generator->setPromptText($generatorPromptText); + try { + $gapicClient->createGenerator($formattedParent, $generator); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteGeneratorTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->generatorName('[PROJECT]', '[LOCATION]', '[AGENT]', '[GENERATOR]'); + $gapicClient->deleteGenerator($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.dialogflow.cx.v3.Generators/DeleteGenerator', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteGeneratorExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->generatorName('[PROJECT]', '[LOCATION]', '[AGENT]', '[GENERATOR]'); + try { + $gapicClient->deleteGenerator($formattedName); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getGeneratorTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $displayName = 'displayName1615086568'; + $expectedResponse = new Generator(); + $expectedResponse->setName($name2); + $expectedResponse->setDisplayName($displayName); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->generatorName('[PROJECT]', '[LOCATION]', '[AGENT]', '[GENERATOR]'); + $response = $gapicClient->getGenerator($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.dialogflow.cx.v3.Generators/GetGenerator', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getGeneratorExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->generatorName('[PROJECT]', '[LOCATION]', '[AGENT]', '[GENERATOR]'); + try { + $gapicClient->getGenerator($formattedName); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listGeneratorsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $generatorsElement = new Generator(); + $generators = [ + $generatorsElement, + ]; + $expectedResponse = new ListGeneratorsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setGenerators($generators); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $response = $gapicClient->listGenerators($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getGenerators()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.dialogflow.cx.v3.Generators/ListGenerators', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listGeneratorsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + try { + $gapicClient->listGenerators($formattedParent); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateGeneratorTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $expectedResponse = new Generator(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $transport->addResponse($expectedResponse); + // Mock request + $generator = new Generator(); + $generatorDisplayName = 'generatorDisplayName421654938'; + $generator->setDisplayName($generatorDisplayName); + $generatorPromptText = new Phrase(); + $promptTextText = 'promptTextText-1712080514'; + $generatorPromptText->setText($promptTextText); + $generator->setPromptText($generatorPromptText); + $response = $gapicClient->updateGenerator($generator); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.dialogflow.cx.v3.Generators/UpdateGenerator', $actualFuncCall); + $actualValue = $actualRequestObject->getGenerator(); + $this->assertProtobufEquals($generator, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateGeneratorExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $generator = new Generator(); + $generatorDisplayName = 'generatorDisplayName421654938'; + $generator->setDisplayName($generatorDisplayName); + $generatorPromptText = new Phrase(); + $promptTextText = 'promptTextText-1712080514'; + $generatorPromptText->setText($promptTextText); + $generator->setPromptText($generatorPromptText); + try { + $gapicClient->updateGenerator($generator); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getLocationTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $locationId = 'locationId552319461'; + $displayName = 'displayName1615086568'; + $expectedResponse = new Location(); + $expectedResponse->setName($name2); + $expectedResponse->setLocationId($locationId); + $expectedResponse->setDisplayName($displayName); + $transport->addResponse($expectedResponse); + $response = $gapicClient->getLocation(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.location.Locations/GetLocation', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getLocationExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + try { + $gapicClient->getLocation(); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listLocationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $locationsElement = new Location(); + $locations = [ + $locationsElement, + ]; + $expectedResponse = new ListLocationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setLocations($locations); + $transport->addResponse($expectedResponse); + $response = $gapicClient->listLocations(); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listLocationsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + try { + $gapicClient->listLocations(); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/DialogflowCx/tests/Unit/V3/SessionsClientTest.php b/DialogflowCx/tests/Unit/V3/SessionsClientTest.php index a48fa8c596d5..bfd1f68f9b74 100644 --- a/DialogflowCx/tests/Unit/V3/SessionsClientTest.php +++ b/DialogflowCx/tests/Unit/V3/SessionsClientTest.php @@ -27,6 +27,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback; use Google\Cloud\Dialogflow\Cx\V3\DetectIntentResponse; use Google\Cloud\Dialogflow\Cx\V3\FulfillIntentResponse; use Google\Cloud\Dialogflow\Cx\V3\MatchIntentResponse; @@ -363,6 +364,74 @@ public function streamingDetectIntentExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function submitAnswerFeedbackTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $customRating = 'customRating1123127851'; + $expectedResponse = new AnswerFeedback(); + $expectedResponse->setCustomRating($customRating); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); + $responseId = 'responseId1847552473'; + $answerFeedback = new AnswerFeedback(); + $response = $gapicClient->submitAnswerFeedback($formattedSession, $responseId, $answerFeedback); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.dialogflow.cx.v3.Sessions/SubmitAnswerFeedback', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getResponseId(); + $this->assertProtobufEquals($responseId, $actualValue); + $actualValue = $actualRequestObject->getAnswerFeedback(); + $this->assertProtobufEquals($answerFeedback, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function submitAnswerFeedbackExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); + $responseId = 'responseId1847552473'; + $answerFeedback = new AnswerFeedback(); + try { + $gapicClient->submitAnswerFeedback($formattedSession, $responseId, $answerFeedback); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function getLocationTest() {