diff --git a/DialogflowCx/samples/V3/AgentsClient/create_agent.php b/DialogflowCx/samples/V3/AgentsClient/create_agent.php index ba6981578c17..3ef7ed4fd802 100644 --- a/DialogflowCx/samples/V3/AgentsClient/create_agent.php +++ b/DialogflowCx/samples/V3/AgentsClient/create_agent.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Agents_CreateAgent_sync] use Google\ApiCore\ApiException; use Google\Cloud\Dialogflow\Cx\V3\Agent; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateAgentRequest; /** * Creates an agent in the specified location. @@ -58,16 +59,19 @@ function create_agent_sample( // Create a client. $agentsClient = new AgentsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $agent = (new Agent()) ->setDisplayName($agentDisplayName) ->setDefaultLanguageCode($agentDefaultLanguageCode) ->setTimeZone($agentTimeZone); + $request = (new CreateAgentRequest()) + ->setParent($formattedParent) + ->setAgent($agent); // Call the API and handle any network failures. try { /** @var Agent $response */ - $response = $agentsClient->createAgent($formattedParent, $agent); + $response = $agentsClient->createAgent($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/AgentsClient/delete_agent.php b/DialogflowCx/samples/V3/AgentsClient/delete_agent.php index 9f77bc9c0723..87177478ab00 100644 --- a/DialogflowCx/samples/V3/AgentsClient/delete_agent.php +++ b/DialogflowCx/samples/V3/AgentsClient/delete_agent.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Agents_DeleteAgent_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\DeleteAgentRequest; /** * Deletes the specified agent. @@ -38,9 +39,13 @@ function delete_agent_sample(string $formattedName): void // Create a client. $agentsClient = new AgentsClient(); + // Prepare the request message. + $request = (new DeleteAgentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $agentsClient->deleteAgent($formattedName); + $agentsClient->deleteAgent($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/AgentsClient/export_agent.php b/DialogflowCx/samples/V3/AgentsClient/export_agent.php index d4ef9b3af079..152fde95ed70 100644 --- a/DialogflowCx/samples/V3/AgentsClient/export_agent.php +++ b/DialogflowCx/samples/V3/AgentsClient/export_agent.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Agents_ExportAgent_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\ExportAgentRequest; use Google\Cloud\Dialogflow\Cx\V3\ExportAgentResponse; use Google\Rpc\Status; @@ -50,10 +51,14 @@ function export_agent_sample(string $formattedName): void // Create a client. $agentsClient = new AgentsClient(); + // Prepare the request message. + $request = (new ExportAgentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $agentsClient->exportAgent($formattedName); + $response = $agentsClient->exportAgent($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/AgentsClient/get_agent.php b/DialogflowCx/samples/V3/AgentsClient/get_agent.php index c26c6d2c84bf..8b648dd5fb8f 100644 --- a/DialogflowCx/samples/V3/AgentsClient/get_agent.php +++ b/DialogflowCx/samples/V3/AgentsClient/get_agent.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Agents_GetAgent_sync] use Google\ApiCore\ApiException; use Google\Cloud\Dialogflow\Cx\V3\Agent; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetAgentRequest; /** * Retrieves the specified agent. @@ -39,10 +40,14 @@ function get_agent_sample(string $formattedName): void // Create a client. $agentsClient = new AgentsClient(); + // Prepare the request message. + $request = (new GetAgentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var Agent $response */ - $response = $agentsClient->getAgent($formattedName); + $response = $agentsClient->getAgent($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/AgentsClient/get_agent_validation_result.php b/DialogflowCx/samples/V3/AgentsClient/get_agent_validation_result.php index 879591653c2c..69638dde44d8 100644 --- a/DialogflowCx/samples/V3/AgentsClient/get_agent_validation_result.php +++ b/DialogflowCx/samples/V3/AgentsClient/get_agent_validation_result.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Agents_GetAgentValidationResult_sync] use Google\ApiCore\ApiException; use Google\Cloud\Dialogflow\Cx\V3\AgentValidationResult; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetAgentValidationResultRequest; /** * Gets the latest agent validation result. Agent validation is performed @@ -41,10 +42,14 @@ function get_agent_validation_result_sample(string $formattedName): void // Create a client. $agentsClient = new AgentsClient(); + // Prepare the request message. + $request = (new GetAgentValidationResultRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var AgentValidationResult $response */ - $response = $agentsClient->getAgentValidationResult($formattedName); + $response = $agentsClient->getAgentValidationResult($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/AgentsClient/get_generative_settings.php b/DialogflowCx/samples/V3/AgentsClient/get_generative_settings.php index 84b5e0045ce3..823bbb6ee977 100644 --- a/DialogflowCx/samples/V3/AgentsClient/get_generative_settings.php +++ b/DialogflowCx/samples/V3/AgentsClient/get_generative_settings.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Agents_GetGenerativeSettings_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; use Google\Cloud\Dialogflow\Cx\V3\GenerativeSettings; +use Google\Cloud\Dialogflow\Cx\V3\GetGenerativeSettingsRequest; /** * Gets the generative settings for the agent. @@ -40,10 +41,15 @@ function get_generative_settings_sample(string $formattedName, string $languageC // Create a client. $agentsClient = new AgentsClient(); + // Prepare the request message. + $request = (new GetGenerativeSettingsRequest()) + ->setName($formattedName) + ->setLanguageCode($languageCode); + // Call the API and handle any network failures. try { /** @var GenerativeSettings $response */ - $response = $agentsClient->getGenerativeSettings($formattedName, $languageCode); + $response = $agentsClient->getGenerativeSettings($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/AgentsClient/get_location.php b/DialogflowCx/samples/V3/AgentsClient/get_location.php index 6d31f74143a6..92bccb0a40f2 100644 --- a/DialogflowCx/samples/V3/AgentsClient/get_location.php +++ b/DialogflowCx/samples/V3/AgentsClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Agents_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $agentsClient = new AgentsClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $agentsClient->getLocation(); + $response = $agentsClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/AgentsClient/list_agents.php b/DialogflowCx/samples/V3/AgentsClient/list_agents.php index 988f161c5745..2b4b13d6d742 100644 --- a/DialogflowCx/samples/V3/AgentsClient/list_agents.php +++ b/DialogflowCx/samples/V3/AgentsClient/list_agents.php @@ -26,7 +26,8 @@ use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; use Google\Cloud\Dialogflow\Cx\V3\Agent; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\ListAgentsRequest; /** * Returns the list of all agents in the specified location. @@ -40,10 +41,14 @@ function list_agents_sample(string $formattedParent): void // Create a client. $agentsClient = new AgentsClient(); + // Prepare the request message. + $request = (new ListAgentsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $agentsClient->listAgents($formattedParent); + $response = $agentsClient->listAgents($request); /** @var Agent $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/AgentsClient/list_locations.php b/DialogflowCx/samples/V3/AgentsClient/list_locations.php index 680ad836190a..7e4f61f9a404 100644 --- a/DialogflowCx/samples/V3/AgentsClient/list_locations.php +++ b/DialogflowCx/samples/V3/AgentsClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Agents_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $agentsClient = new AgentsClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $agentsClient->listLocations(); + $response = $agentsClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/AgentsClient/restore_agent.php b/DialogflowCx/samples/V3/AgentsClient/restore_agent.php index 3df24506f35a..18f117c3ba11 100644 --- a/DialogflowCx/samples/V3/AgentsClient/restore_agent.php +++ b/DialogflowCx/samples/V3/AgentsClient/restore_agent.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Agents_RestoreAgent_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\RestoreAgentRequest; use Google\Rpc\Status; /** @@ -56,10 +57,14 @@ function restore_agent_sample(string $formattedName): void // Create a client. $agentsClient = new AgentsClient(); + // Prepare the request message. + $request = (new RestoreAgentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $agentsClient->restoreAgent($formattedName); + $response = $agentsClient->restoreAgent($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/AgentsClient/update_agent.php b/DialogflowCx/samples/V3/AgentsClient/update_agent.php index ef947fcb9570..53ec084a1b48 100644 --- a/DialogflowCx/samples/V3/AgentsClient/update_agent.php +++ b/DialogflowCx/samples/V3/AgentsClient/update_agent.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Agents_UpdateAgent_sync] use Google\ApiCore\ApiException; use Google\Cloud\Dialogflow\Cx\V3\Agent; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateAgentRequest; /** * Updates the specified agent. @@ -54,16 +55,18 @@ function update_agent_sample( // Create a client. $agentsClient = new AgentsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $agent = (new Agent()) ->setDisplayName($agentDisplayName) ->setDefaultLanguageCode($agentDefaultLanguageCode) ->setTimeZone($agentTimeZone); + $request = (new UpdateAgentRequest()) + ->setAgent($agent); // Call the API and handle any network failures. try { /** @var Agent $response */ - $response = $agentsClient->updateAgent($agent); + $response = $agentsClient->updateAgent($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/AgentsClient/update_generative_settings.php b/DialogflowCx/samples/V3/AgentsClient/update_generative_settings.php index 37872104b275..30f577d6ff48 100644 --- a/DialogflowCx/samples/V3/AgentsClient/update_generative_settings.php +++ b/DialogflowCx/samples/V3/AgentsClient/update_generative_settings.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Agents_UpdateGenerativeSettings_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; use Google\Cloud\Dialogflow\Cx\V3\GenerativeSettings; +use Google\Cloud\Dialogflow\Cx\V3\UpdateGenerativeSettingsRequest; /** * Updates the generative settings for the agent. @@ -41,13 +42,15 @@ function update_generative_settings_sample(): void // Create a client. $agentsClient = new AgentsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $generativeSettings = new GenerativeSettings(); + $request = (new UpdateGenerativeSettingsRequest()) + ->setGenerativeSettings($generativeSettings); // Call the API and handle any network failures. try { /** @var GenerativeSettings $response */ - $response = $agentsClient->updateGenerativeSettings($generativeSettings); + $response = $agentsClient->updateGenerativeSettings($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/AgentsClient/validate_agent.php b/DialogflowCx/samples/V3/AgentsClient/validate_agent.php index 7579edfa9a8a..56deabb6f10d 100644 --- a/DialogflowCx/samples/V3/AgentsClient/validate_agent.php +++ b/DialogflowCx/samples/V3/AgentsClient/validate_agent.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Agents_ValidateAgent_sync] use Google\ApiCore\ApiException; use Google\Cloud\Dialogflow\Cx\V3\AgentValidationResult; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\ValidateAgentRequest; /** * Validates the specified agent and creates or updates validation results. @@ -41,10 +42,14 @@ function validate_agent_sample(string $formattedName): void // Create a client. $agentsClient = new AgentsClient(); + // Prepare the request message. + $request = (new ValidateAgentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var AgentValidationResult $response */ - $response = $agentsClient->validateAgent($formattedName); + $response = $agentsClient->validateAgent($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/ChangelogsClient/get_changelog.php b/DialogflowCx/samples/V3/ChangelogsClient/get_changelog.php index f21eab0ce86b..6b098bc95566 100644 --- a/DialogflowCx/samples/V3/ChangelogsClient/get_changelog.php +++ b/DialogflowCx/samples/V3/ChangelogsClient/get_changelog.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Changelogs_GetChangelog_sync] use Google\ApiCore\ApiException; use Google\Cloud\Dialogflow\Cx\V3\Changelog; -use Google\Cloud\Dialogflow\Cx\V3\ChangelogsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\ChangelogsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetChangelogRequest; /** * Retrieves the specified Changelog. @@ -40,10 +41,14 @@ function get_changelog_sample(string $formattedName): void // Create a client. $changelogsClient = new ChangelogsClient(); + // Prepare the request message. + $request = (new GetChangelogRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var Changelog $response */ - $response = $changelogsClient->getChangelog($formattedName); + $response = $changelogsClient->getChangelog($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/ChangelogsClient/get_location.php b/DialogflowCx/samples/V3/ChangelogsClient/get_location.php index 978ba5dbfd10..9d9219c93609 100644 --- a/DialogflowCx/samples/V3/ChangelogsClient/get_location.php +++ b/DialogflowCx/samples/V3/ChangelogsClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Changelogs_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\ChangelogsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\ChangelogsClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $changelogsClient = new ChangelogsClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $changelogsClient->getLocation(); + $response = $changelogsClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/ChangelogsClient/list_changelogs.php b/DialogflowCx/samples/V3/ChangelogsClient/list_changelogs.php index caead0cb16a2..835438d49104 100644 --- a/DialogflowCx/samples/V3/ChangelogsClient/list_changelogs.php +++ b/DialogflowCx/samples/V3/ChangelogsClient/list_changelogs.php @@ -26,7 +26,8 @@ use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; use Google\Cloud\Dialogflow\Cx\V3\Changelog; -use Google\Cloud\Dialogflow\Cx\V3\ChangelogsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\ChangelogsClient; +use Google\Cloud\Dialogflow\Cx\V3\ListChangelogsRequest; /** * Returns the list of Changelogs. @@ -40,10 +41,14 @@ function list_changelogs_sample(string $formattedParent): void // Create a client. $changelogsClient = new ChangelogsClient(); + // Prepare the request message. + $request = (new ListChangelogsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $changelogsClient->listChangelogs($formattedParent); + $response = $changelogsClient->listChangelogs($request); /** @var Changelog $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/ChangelogsClient/list_locations.php b/DialogflowCx/samples/V3/ChangelogsClient/list_locations.php index 3f818f58406e..b1bc99319159 100644 --- a/DialogflowCx/samples/V3/ChangelogsClient/list_locations.php +++ b/DialogflowCx/samples/V3/ChangelogsClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Changelogs_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\ChangelogsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\ChangelogsClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $changelogsClient = new ChangelogsClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $changelogsClient->listLocations(); + $response = $changelogsClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/DeploymentsClient/get_deployment.php b/DialogflowCx/samples/V3/DeploymentsClient/get_deployment.php index 1a0f6f10dcaa..c9e282215650 100644 --- a/DialogflowCx/samples/V3/DeploymentsClient/get_deployment.php +++ b/DialogflowCx/samples/V3/DeploymentsClient/get_deployment.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Deployments_GetDeployment_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\DeploymentsClient; use Google\Cloud\Dialogflow\Cx\V3\Deployment; -use Google\Cloud\Dialogflow\Cx\V3\DeploymentsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetDeploymentRequest; /** * Retrieves the specified @@ -42,10 +43,14 @@ function get_deployment_sample(string $formattedName): void // Create a client. $deploymentsClient = new DeploymentsClient(); + // Prepare the request message. + $request = (new GetDeploymentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var Deployment $response */ - $response = $deploymentsClient->getDeployment($formattedName); + $response = $deploymentsClient->getDeployment($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/DeploymentsClient/get_location.php b/DialogflowCx/samples/V3/DeploymentsClient/get_location.php index 232f5f032cb5..864f5a05fb77 100644 --- a/DialogflowCx/samples/V3/DeploymentsClient/get_location.php +++ b/DialogflowCx/samples/V3/DeploymentsClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Deployments_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\DeploymentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\DeploymentsClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $deploymentsClient = new DeploymentsClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $deploymentsClient->getLocation(); + $response = $deploymentsClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/DeploymentsClient/list_deployments.php b/DialogflowCx/samples/V3/DeploymentsClient/list_deployments.php index 7f21d4bae752..06fd63c09b8c 100644 --- a/DialogflowCx/samples/V3/DeploymentsClient/list_deployments.php +++ b/DialogflowCx/samples/V3/DeploymentsClient/list_deployments.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Deployments_ListDeployments_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\DeploymentsClient; use Google\Cloud\Dialogflow\Cx\V3\Deployment; -use Google\Cloud\Dialogflow\Cx\V3\DeploymentsClient; +use Google\Cloud\Dialogflow\Cx\V3\ListDeploymentsRequest; /** * Returns the list of all deployments in the specified @@ -43,10 +44,14 @@ function list_deployments_sample(string $formattedParent): void // Create a client. $deploymentsClient = new DeploymentsClient(); + // Prepare the request message. + $request = (new ListDeploymentsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $deploymentsClient->listDeployments($formattedParent); + $response = $deploymentsClient->listDeployments($request); /** @var Deployment $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/DeploymentsClient/list_locations.php b/DialogflowCx/samples/V3/DeploymentsClient/list_locations.php index dc67996cf9fd..1fcb37b51487 100644 --- a/DialogflowCx/samples/V3/DeploymentsClient/list_locations.php +++ b/DialogflowCx/samples/V3/DeploymentsClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Deployments_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\DeploymentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\DeploymentsClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $deploymentsClient = new DeploymentsClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $deploymentsClient->listLocations(); + $response = $deploymentsClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/EntityTypesClient/create_entity_type.php b/DialogflowCx/samples/V3/EntityTypesClient/create_entity_type.php index b536ce190972..07ede591165c 100644 --- a/DialogflowCx/samples/V3/EntityTypesClient/create_entity_type.php +++ b/DialogflowCx/samples/V3/EntityTypesClient/create_entity_type.php @@ -24,9 +24,10 @@ // [START dialogflow_v3_generated_EntityTypes_CreateEntityType_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\EntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateEntityTypeRequest; use Google\Cloud\Dialogflow\Cx\V3\EntityType; use Google\Cloud\Dialogflow\Cx\V3\EntityType\Kind; -use Google\Cloud\Dialogflow\Cx\V3\EntityTypesClient; /** * Creates an entity type in the specified agent. @@ -50,15 +51,18 @@ function create_entity_type_sample( // Create a client. $entityTypesClient = new EntityTypesClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $entityType = (new EntityType()) ->setDisplayName($entityTypeDisplayName) ->setKind($entityTypeKind); + $request = (new CreateEntityTypeRequest()) + ->setParent($formattedParent) + ->setEntityType($entityType); // Call the API and handle any network failures. try { /** @var EntityType $response */ - $response = $entityTypesClient->createEntityType($formattedParent, $entityType); + $response = $entityTypesClient->createEntityType($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/EntityTypesClient/delete_entity_type.php b/DialogflowCx/samples/V3/EntityTypesClient/delete_entity_type.php index a81719d3adc1..f963847d5a97 100644 --- a/DialogflowCx/samples/V3/EntityTypesClient/delete_entity_type.php +++ b/DialogflowCx/samples/V3/EntityTypesClient/delete_entity_type.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_EntityTypes_DeleteEntityType_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\EntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\EntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\DeleteEntityTypeRequest; /** * Deletes the specified entity type. @@ -43,9 +44,13 @@ function delete_entity_type_sample(string $formattedName): void // Create a client. $entityTypesClient = new EntityTypesClient(); + // Prepare the request message. + $request = (new DeleteEntityTypeRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $entityTypesClient->deleteEntityType($formattedName); + $entityTypesClient->deleteEntityType($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/EntityTypesClient/get_entity_type.php b/DialogflowCx/samples/V3/EntityTypesClient/get_entity_type.php index d4a8dffa6745..84e6c9335508 100644 --- a/DialogflowCx/samples/V3/EntityTypesClient/get_entity_type.php +++ b/DialogflowCx/samples/V3/EntityTypesClient/get_entity_type.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_EntityTypes_GetEntityType_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\EntityTypesClient; use Google\Cloud\Dialogflow\Cx\V3\EntityType; -use Google\Cloud\Dialogflow\Cx\V3\EntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\GetEntityTypeRequest; /** * Retrieves the specified entity type. @@ -40,10 +41,14 @@ function get_entity_type_sample(string $formattedName): void // Create a client. $entityTypesClient = new EntityTypesClient(); + // Prepare the request message. + $request = (new GetEntityTypeRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var EntityType $response */ - $response = $entityTypesClient->getEntityType($formattedName); + $response = $entityTypesClient->getEntityType($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/EntityTypesClient/get_location.php b/DialogflowCx/samples/V3/EntityTypesClient/get_location.php index ae2e8b85f6a7..944c7b35ad82 100644 --- a/DialogflowCx/samples/V3/EntityTypesClient/get_location.php +++ b/DialogflowCx/samples/V3/EntityTypesClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_EntityTypes_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\EntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\EntityTypesClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $entityTypesClient = new EntityTypesClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $entityTypesClient->getLocation(); + $response = $entityTypesClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/EntityTypesClient/list_entity_types.php b/DialogflowCx/samples/V3/EntityTypesClient/list_entity_types.php index b6e450580482..8dda6344a959 100644 --- a/DialogflowCx/samples/V3/EntityTypesClient/list_entity_types.php +++ b/DialogflowCx/samples/V3/EntityTypesClient/list_entity_types.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_EntityTypes_ListEntityTypes_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\EntityTypesClient; use Google\Cloud\Dialogflow\Cx\V3\EntityType; -use Google\Cloud\Dialogflow\Cx\V3\EntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\ListEntityTypesRequest; /** * Returns the list of all entity types in the specified agent. @@ -40,10 +41,14 @@ function list_entity_types_sample(string $formattedParent): void // Create a client. $entityTypesClient = new EntityTypesClient(); + // Prepare the request message. + $request = (new ListEntityTypesRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $entityTypesClient->listEntityTypes($formattedParent); + $response = $entityTypesClient->listEntityTypes($request); /** @var EntityType $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/EntityTypesClient/list_locations.php b/DialogflowCx/samples/V3/EntityTypesClient/list_locations.php index ab29e47f9445..1f18d96ad673 100644 --- a/DialogflowCx/samples/V3/EntityTypesClient/list_locations.php +++ b/DialogflowCx/samples/V3/EntityTypesClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_EntityTypes_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\EntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\EntityTypesClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $entityTypesClient = new EntityTypesClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $entityTypesClient->listLocations(); + $response = $entityTypesClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/EntityTypesClient/update_entity_type.php b/DialogflowCx/samples/V3/EntityTypesClient/update_entity_type.php index 02f22ac9c07a..4a10dafb1fa5 100644 --- a/DialogflowCx/samples/V3/EntityTypesClient/update_entity_type.php +++ b/DialogflowCx/samples/V3/EntityTypesClient/update_entity_type.php @@ -24,9 +24,10 @@ // [START dialogflow_v3_generated_EntityTypes_UpdateEntityType_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\EntityTypesClient; use Google\Cloud\Dialogflow\Cx\V3\EntityType; use Google\Cloud\Dialogflow\Cx\V3\EntityType\Kind; -use Google\Cloud\Dialogflow\Cx\V3\EntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateEntityTypeRequest; /** * Updates the specified entity type. @@ -44,15 +45,17 @@ function update_entity_type_sample(string $entityTypeDisplayName, int $entityTyp // Create a client. $entityTypesClient = new EntityTypesClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $entityType = (new EntityType()) ->setDisplayName($entityTypeDisplayName) ->setKind($entityTypeKind); + $request = (new UpdateEntityTypeRequest()) + ->setEntityType($entityType); // Call the API and handle any network failures. try { /** @var EntityType $response */ - $response = $entityTypesClient->updateEntityType($entityType); + $response = $entityTypesClient->updateEntityType($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/EnvironmentsClient/create_environment.php b/DialogflowCx/samples/V3/EnvironmentsClient/create_environment.php index 760c9e98cb76..0712d84d32f5 100644 --- a/DialogflowCx/samples/V3/EnvironmentsClient/create_environment.php +++ b/DialogflowCx/samples/V3/EnvironmentsClient/create_environment.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Environments_CreateEnvironment_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateEnvironmentRequest; use Google\Cloud\Dialogflow\Cx\V3\Environment; -use Google\Cloud\Dialogflow\Cx\V3\EnvironmentsClient; use Google\Rpc\Status; /** @@ -53,14 +54,17 @@ function create_environment_sample(string $formattedParent, string $environmentD // Create a client. $environmentsClient = new EnvironmentsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $environment = (new Environment()) ->setDisplayName($environmentDisplayName); + $request = (new CreateEnvironmentRequest()) + ->setParent($formattedParent) + ->setEnvironment($environment); // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $environmentsClient->createEnvironment($formattedParent, $environment); + $response = $environmentsClient->createEnvironment($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/EnvironmentsClient/delete_environment.php b/DialogflowCx/samples/V3/EnvironmentsClient/delete_environment.php index 67c2166b2dc7..5c09f67ad316 100644 --- a/DialogflowCx/samples/V3/EnvironmentsClient/delete_environment.php +++ b/DialogflowCx/samples/V3/EnvironmentsClient/delete_environment.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Environments_DeleteEnvironment_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\DeleteEnvironmentRequest; /** * Deletes the specified @@ -41,9 +42,13 @@ function delete_environment_sample(string $formattedName): void // Create a client. $environmentsClient = new EnvironmentsClient(); + // Prepare the request message. + $request = (new DeleteEnvironmentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $environmentsClient->deleteEnvironment($formattedName); + $environmentsClient->deleteEnvironment($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/EnvironmentsClient/deploy_flow.php b/DialogflowCx/samples/V3/EnvironmentsClient/deploy_flow.php index 57a58eee6cd5..9d4343eb51fb 100644 --- a/DialogflowCx/samples/V3/EnvironmentsClient/deploy_flow.php +++ b/DialogflowCx/samples/V3/EnvironmentsClient/deploy_flow.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Environments_DeployFlow_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\DeployFlowRequest; use Google\Cloud\Dialogflow\Cx\V3\DeployFlowResponse; -use Google\Cloud\Dialogflow\Cx\V3\EnvironmentsClient; use Google\Rpc\Status; /** @@ -56,10 +57,15 @@ function deploy_flow_sample(string $formattedEnvironment, string $formattedFlowV // Create a client. $environmentsClient = new EnvironmentsClient(); + // Prepare the request message. + $request = (new DeployFlowRequest()) + ->setEnvironment($formattedEnvironment) + ->setFlowVersion($formattedFlowVersion); + // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $environmentsClient->deployFlow($formattedEnvironment, $formattedFlowVersion); + $response = $environmentsClient->deployFlow($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/EnvironmentsClient/get_environment.php b/DialogflowCx/samples/V3/EnvironmentsClient/get_environment.php index 5d000f5947e5..e91f34316d18 100644 --- a/DialogflowCx/samples/V3/EnvironmentsClient/get_environment.php +++ b/DialogflowCx/samples/V3/EnvironmentsClient/get_environment.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Environments_GetEnvironment_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\EnvironmentsClient; use Google\Cloud\Dialogflow\Cx\V3\Environment; -use Google\Cloud\Dialogflow\Cx\V3\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetEnvironmentRequest; /** * Retrieves the specified @@ -42,10 +43,14 @@ function get_environment_sample(string $formattedName): void // Create a client. $environmentsClient = new EnvironmentsClient(); + // Prepare the request message. + $request = (new GetEnvironmentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var Environment $response */ - $response = $environmentsClient->getEnvironment($formattedName); + $response = $environmentsClient->getEnvironment($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/EnvironmentsClient/get_location.php b/DialogflowCx/samples/V3/EnvironmentsClient/get_location.php index 7b5417306553..c75c94f7c06c 100644 --- a/DialogflowCx/samples/V3/EnvironmentsClient/get_location.php +++ b/DialogflowCx/samples/V3/EnvironmentsClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Environments_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\EnvironmentsClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $environmentsClient = new EnvironmentsClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $environmentsClient->getLocation(); + $response = $environmentsClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/EnvironmentsClient/list_continuous_test_results.php b/DialogflowCx/samples/V3/EnvironmentsClient/list_continuous_test_results.php index f05df473962e..28881033cdcd 100644 --- a/DialogflowCx/samples/V3/EnvironmentsClient/list_continuous_test_results.php +++ b/DialogflowCx/samples/V3/EnvironmentsClient/list_continuous_test_results.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Environments_ListContinuousTestResults_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\EnvironmentsClient; use Google\Cloud\Dialogflow\Cx\V3\ContinuousTestResult; -use Google\Cloud\Dialogflow\Cx\V3\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\ListContinuousTestResultsRequest; /** * Fetches a list of continuous test results for a given environment. @@ -41,10 +42,14 @@ function list_continuous_test_results_sample(string $formattedParent): void // Create a client. $environmentsClient = new EnvironmentsClient(); + // Prepare the request message. + $request = (new ListContinuousTestResultsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $environmentsClient->listContinuousTestResults($formattedParent); + $response = $environmentsClient->listContinuousTestResults($request); /** @var ContinuousTestResult $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/EnvironmentsClient/list_environments.php b/DialogflowCx/samples/V3/EnvironmentsClient/list_environments.php index 9591f1a8da7e..37ae4570a800 100644 --- a/DialogflowCx/samples/V3/EnvironmentsClient/list_environments.php +++ b/DialogflowCx/samples/V3/EnvironmentsClient/list_environments.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Environments_ListEnvironments_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\EnvironmentsClient; use Google\Cloud\Dialogflow\Cx\V3\Environment; -use Google\Cloud\Dialogflow\Cx\V3\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\ListEnvironmentsRequest; /** * Returns the list of all environments in the specified @@ -42,10 +43,14 @@ function list_environments_sample(string $formattedParent): void // Create a client. $environmentsClient = new EnvironmentsClient(); + // Prepare the request message. + $request = (new ListEnvironmentsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $environmentsClient->listEnvironments($formattedParent); + $response = $environmentsClient->listEnvironments($request); /** @var Environment $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/EnvironmentsClient/list_locations.php b/DialogflowCx/samples/V3/EnvironmentsClient/list_locations.php index e05ac218a40c..c45da2bc10f2 100644 --- a/DialogflowCx/samples/V3/EnvironmentsClient/list_locations.php +++ b/DialogflowCx/samples/V3/EnvironmentsClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Environments_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\EnvironmentsClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $environmentsClient = new EnvironmentsClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $environmentsClient->listLocations(); + $response = $environmentsClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/EnvironmentsClient/lookup_environment_history.php b/DialogflowCx/samples/V3/EnvironmentsClient/lookup_environment_history.php index af93b16126bf..15f795fe5ecc 100644 --- a/DialogflowCx/samples/V3/EnvironmentsClient/lookup_environment_history.php +++ b/DialogflowCx/samples/V3/EnvironmentsClient/lookup_environment_history.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Environments_LookupEnvironmentHistory_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\EnvironmentsClient; use Google\Cloud\Dialogflow\Cx\V3\Environment; -use Google\Cloud\Dialogflow\Cx\V3\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\LookupEnvironmentHistoryRequest; /** * Looks up the history of the specified @@ -42,10 +43,14 @@ function lookup_environment_history_sample(string $formattedName): void // Create a client. $environmentsClient = new EnvironmentsClient(); + // Prepare the request message. + $request = (new LookupEnvironmentHistoryRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $environmentsClient->lookupEnvironmentHistory($formattedName); + $response = $environmentsClient->lookupEnvironmentHistory($request); /** @var Environment $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/EnvironmentsClient/run_continuous_test.php b/DialogflowCx/samples/V3/EnvironmentsClient/run_continuous_test.php index 9387471357fe..e285637ae5c7 100644 --- a/DialogflowCx/samples/V3/EnvironmentsClient/run_continuous_test.php +++ b/DialogflowCx/samples/V3/EnvironmentsClient/run_continuous_test.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Environments_RunContinuousTest_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; -use Google\Cloud\Dialogflow\Cx\V3\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\RunContinuousTestRequest; use Google\Cloud\Dialogflow\Cx\V3\RunContinuousTestResponse; use Google\Rpc\Status; @@ -51,10 +52,14 @@ function run_continuous_test_sample(string $formattedEnvironment): void // Create a client. $environmentsClient = new EnvironmentsClient(); + // Prepare the request message. + $request = (new RunContinuousTestRequest()) + ->setEnvironment($formattedEnvironment); + // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $environmentsClient->runContinuousTest($formattedEnvironment); + $response = $environmentsClient->runContinuousTest($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/EnvironmentsClient/update_environment.php b/DialogflowCx/samples/V3/EnvironmentsClient/update_environment.php index da86c99f5dcd..369a509e33da 100644 --- a/DialogflowCx/samples/V3/EnvironmentsClient/update_environment.php +++ b/DialogflowCx/samples/V3/EnvironmentsClient/update_environment.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Environments_UpdateEnvironment_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\EnvironmentsClient; use Google\Cloud\Dialogflow\Cx\V3\Environment; -use Google\Cloud\Dialogflow\Cx\V3\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateEnvironmentRequest; use Google\Protobuf\FieldMask; use Google\Rpc\Status; @@ -50,15 +51,18 @@ function update_environment_sample(string $environmentDisplayName): void // Create a client. $environmentsClient = new EnvironmentsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $environment = (new Environment()) ->setDisplayName($environmentDisplayName); $updateMask = new FieldMask(); + $request = (new UpdateEnvironmentRequest()) + ->setEnvironment($environment) + ->setUpdateMask($updateMask); // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $environmentsClient->updateEnvironment($environment, $updateMask); + $response = $environmentsClient->updateEnvironment($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/ExperimentsClient/create_experiment.php b/DialogflowCx/samples/V3/ExperimentsClient/create_experiment.php index d8ecc02da010..6f27e03edb00 100644 --- a/DialogflowCx/samples/V3/ExperimentsClient/create_experiment.php +++ b/DialogflowCx/samples/V3/ExperimentsClient/create_experiment.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Experiments_CreateExperiment_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\ExperimentsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateExperimentRequest; use Google\Cloud\Dialogflow\Cx\V3\Experiment; -use Google\Cloud\Dialogflow\Cx\V3\ExperimentsClient; /** * Creates an [Experiment][google.cloud.dialogflow.cx.v3.Experiment] in the @@ -44,14 +45,17 @@ function create_experiment_sample(string $formattedParent, string $experimentDis // Create a client. $experimentsClient = new ExperimentsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $experiment = (new Experiment()) ->setDisplayName($experimentDisplayName); + $request = (new CreateExperimentRequest()) + ->setParent($formattedParent) + ->setExperiment($experiment); // Call the API and handle any network failures. try { /** @var Experiment $response */ - $response = $experimentsClient->createExperiment($formattedParent, $experiment); + $response = $experimentsClient->createExperiment($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/ExperimentsClient/delete_experiment.php b/DialogflowCx/samples/V3/ExperimentsClient/delete_experiment.php index dc7eb292055c..5f75b7094649 100644 --- a/DialogflowCx/samples/V3/ExperimentsClient/delete_experiment.php +++ b/DialogflowCx/samples/V3/ExperimentsClient/delete_experiment.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Experiments_DeleteExperiment_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\ExperimentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\ExperimentsClient; +use Google\Cloud\Dialogflow\Cx\V3\DeleteExperimentRequest; /** * Deletes the specified @@ -41,9 +42,13 @@ function delete_experiment_sample(string $formattedName): void // Create a client. $experimentsClient = new ExperimentsClient(); + // Prepare the request message. + $request = (new DeleteExperimentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $experimentsClient->deleteExperiment($formattedName); + $experimentsClient->deleteExperiment($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/ExperimentsClient/get_experiment.php b/DialogflowCx/samples/V3/ExperimentsClient/get_experiment.php index f24aa5b2b73f..7f700c2a5421 100644 --- a/DialogflowCx/samples/V3/ExperimentsClient/get_experiment.php +++ b/DialogflowCx/samples/V3/ExperimentsClient/get_experiment.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Experiments_GetExperiment_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\ExperimentsClient; use Google\Cloud\Dialogflow\Cx\V3\Experiment; -use Google\Cloud\Dialogflow\Cx\V3\ExperimentsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetExperimentRequest; /** * Retrieves the specified @@ -42,10 +43,14 @@ function get_experiment_sample(string $formattedName): void // Create a client. $experimentsClient = new ExperimentsClient(); + // Prepare the request message. + $request = (new GetExperimentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var Experiment $response */ - $response = $experimentsClient->getExperiment($formattedName); + $response = $experimentsClient->getExperiment($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/ExperimentsClient/get_location.php b/DialogflowCx/samples/V3/ExperimentsClient/get_location.php index 2e430e0ab69b..3239645a1dbd 100644 --- a/DialogflowCx/samples/V3/ExperimentsClient/get_location.php +++ b/DialogflowCx/samples/V3/ExperimentsClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Experiments_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\ExperimentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\ExperimentsClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $experimentsClient = new ExperimentsClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $experimentsClient->getLocation(); + $response = $experimentsClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/ExperimentsClient/list_experiments.php b/DialogflowCx/samples/V3/ExperimentsClient/list_experiments.php index 9f38d5cb9bc9..980e118ff5b0 100644 --- a/DialogflowCx/samples/V3/ExperimentsClient/list_experiments.php +++ b/DialogflowCx/samples/V3/ExperimentsClient/list_experiments.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Experiments_ListExperiments_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\ExperimentsClient; use Google\Cloud\Dialogflow\Cx\V3\Experiment; -use Google\Cloud\Dialogflow\Cx\V3\ExperimentsClient; +use Google\Cloud\Dialogflow\Cx\V3\ListExperimentsRequest; /** * Returns the list of all experiments in the specified @@ -43,10 +44,14 @@ function list_experiments_sample(string $formattedParent): void // Create a client. $experimentsClient = new ExperimentsClient(); + // Prepare the request message. + $request = (new ListExperimentsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $experimentsClient->listExperiments($formattedParent); + $response = $experimentsClient->listExperiments($request); /** @var Experiment $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/ExperimentsClient/list_locations.php b/DialogflowCx/samples/V3/ExperimentsClient/list_locations.php index a1e6e4706f69..c26b6046256c 100644 --- a/DialogflowCx/samples/V3/ExperimentsClient/list_locations.php +++ b/DialogflowCx/samples/V3/ExperimentsClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Experiments_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\ExperimentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\ExperimentsClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $experimentsClient = new ExperimentsClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $experimentsClient->listLocations(); + $response = $experimentsClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/ExperimentsClient/start_experiment.php b/DialogflowCx/samples/V3/ExperimentsClient/start_experiment.php index 659118339be9..000a648db2e8 100644 --- a/DialogflowCx/samples/V3/ExperimentsClient/start_experiment.php +++ b/DialogflowCx/samples/V3/ExperimentsClient/start_experiment.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Experiments_StartExperiment_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\ExperimentsClient; use Google\Cloud\Dialogflow\Cx\V3\Experiment; -use Google\Cloud\Dialogflow\Cx\V3\ExperimentsClient; +use Google\Cloud\Dialogflow\Cx\V3\StartExperimentRequest; /** * Starts the specified @@ -42,10 +43,14 @@ function start_experiment_sample(string $formattedName): void // Create a client. $experimentsClient = new ExperimentsClient(); + // Prepare the request message. + $request = (new StartExperimentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var Experiment $response */ - $response = $experimentsClient->startExperiment($formattedName); + $response = $experimentsClient->startExperiment($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/ExperimentsClient/stop_experiment.php b/DialogflowCx/samples/V3/ExperimentsClient/stop_experiment.php index 642c3afc03b4..fd1252fb7474 100644 --- a/DialogflowCx/samples/V3/ExperimentsClient/stop_experiment.php +++ b/DialogflowCx/samples/V3/ExperimentsClient/stop_experiment.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Experiments_StopExperiment_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\ExperimentsClient; use Google\Cloud\Dialogflow\Cx\V3\Experiment; -use Google\Cloud\Dialogflow\Cx\V3\ExperimentsClient; +use Google\Cloud\Dialogflow\Cx\V3\StopExperimentRequest; /** * Stops the specified [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. @@ -41,10 +42,14 @@ function stop_experiment_sample(string $formattedName): void // Create a client. $experimentsClient = new ExperimentsClient(); + // Prepare the request message. + $request = (new StopExperimentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var Experiment $response */ - $response = $experimentsClient->stopExperiment($formattedName); + $response = $experimentsClient->stopExperiment($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/ExperimentsClient/update_experiment.php b/DialogflowCx/samples/V3/ExperimentsClient/update_experiment.php index acec26fdcc9f..e450fed739ce 100644 --- a/DialogflowCx/samples/V3/ExperimentsClient/update_experiment.php +++ b/DialogflowCx/samples/V3/ExperimentsClient/update_experiment.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Experiments_UpdateExperiment_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\ExperimentsClient; use Google\Cloud\Dialogflow\Cx\V3\Experiment; -use Google\Cloud\Dialogflow\Cx\V3\ExperimentsClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateExperimentRequest; use Google\Protobuf\FieldMask; /** @@ -40,15 +41,18 @@ function update_experiment_sample(string $experimentDisplayName): void // Create a client. $experimentsClient = new ExperimentsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $experiment = (new Experiment()) ->setDisplayName($experimentDisplayName); $updateMask = new FieldMask(); + $request = (new UpdateExperimentRequest()) + ->setExperiment($experiment) + ->setUpdateMask($updateMask); // Call the API and handle any network failures. try { /** @var Experiment $response */ - $response = $experimentsClient->updateExperiment($experiment, $updateMask); + $response = $experimentsClient->updateExperiment($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/FlowsClient/create_flow.php b/DialogflowCx/samples/V3/FlowsClient/create_flow.php index fab9c1bf749e..25341629a947 100644 --- a/DialogflowCx/samples/V3/FlowsClient/create_flow.php +++ b/DialogflowCx/samples/V3/FlowsClient/create_flow.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Flows_CreateFlow_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateFlowRequest; use Google\Cloud\Dialogflow\Cx\V3\Flow; -use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; /** * Creates a flow in the specified agent. @@ -44,14 +45,17 @@ function create_flow_sample(string $formattedParent, string $flowDisplayName): v // Create a client. $flowsClient = new FlowsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $flow = (new Flow()) ->setDisplayName($flowDisplayName); + $request = (new CreateFlowRequest()) + ->setParent($formattedParent) + ->setFlow($flow); // Call the API and handle any network failures. try { /** @var Flow $response */ - $response = $flowsClient->createFlow($formattedParent, $flow); + $response = $flowsClient->createFlow($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/FlowsClient/delete_flow.php b/DialogflowCx/samples/V3/FlowsClient/delete_flow.php index 16b576625873..33f57cc0f794 100644 --- a/DialogflowCx/samples/V3/FlowsClient/delete_flow.php +++ b/DialogflowCx/samples/V3/FlowsClient/delete_flow.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Flows_DeleteFlow_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\DeleteFlowRequest; /** * Deletes a specified flow. @@ -39,9 +40,13 @@ function delete_flow_sample(string $formattedName): void // Create a client. $flowsClient = new FlowsClient(); + // Prepare the request message. + $request = (new DeleteFlowRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $flowsClient->deleteFlow($formattedName); + $flowsClient->deleteFlow($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/FlowsClient/export_flow.php b/DialogflowCx/samples/V3/FlowsClient/export_flow.php index 5230de34e396..9d029e88a7bd 100644 --- a/DialogflowCx/samples/V3/FlowsClient/export_flow.php +++ b/DialogflowCx/samples/V3/FlowsClient/export_flow.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Flows_ExportFlow_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\ExportFlowRequest; use Google\Cloud\Dialogflow\Cx\V3\ExportFlowResponse; -use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; use Google\Rpc\Status; /** @@ -54,10 +55,14 @@ function export_flow_sample(string $formattedName): void // Create a client. $flowsClient = new FlowsClient(); + // Prepare the request message. + $request = (new ExportFlowRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $flowsClient->exportFlow($formattedName); + $response = $flowsClient->exportFlow($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/FlowsClient/get_flow.php b/DialogflowCx/samples/V3/FlowsClient/get_flow.php index 1e03ef911afd..9332d14a519c 100644 --- a/DialogflowCx/samples/V3/FlowsClient/get_flow.php +++ b/DialogflowCx/samples/V3/FlowsClient/get_flow.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Flows_GetFlow_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient; use Google\Cloud\Dialogflow\Cx\V3\Flow; -use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetFlowRequest; /** * Retrieves the specified flow. @@ -40,10 +41,14 @@ function get_flow_sample(string $formattedName): void // Create a client. $flowsClient = new FlowsClient(); + // Prepare the request message. + $request = (new GetFlowRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var Flow $response */ - $response = $flowsClient->getFlow($formattedName); + $response = $flowsClient->getFlow($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/FlowsClient/get_flow_validation_result.php b/DialogflowCx/samples/V3/FlowsClient/get_flow_validation_result.php index e8bf068caa34..25377d59327f 100644 --- a/DialogflowCx/samples/V3/FlowsClient/get_flow_validation_result.php +++ b/DialogflowCx/samples/V3/FlowsClient/get_flow_validation_result.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Flows_GetFlowValidationResult_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient; use Google\Cloud\Dialogflow\Cx\V3\FlowValidationResult; -use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetFlowValidationResultRequest; /** * Gets the latest flow validation result. Flow validation is performed @@ -41,10 +42,14 @@ function get_flow_validation_result_sample(string $formattedName): void // Create a client. $flowsClient = new FlowsClient(); + // Prepare the request message. + $request = (new GetFlowValidationResultRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var FlowValidationResult $response */ - $response = $flowsClient->getFlowValidationResult($formattedName); + $response = $flowsClient->getFlowValidationResult($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/FlowsClient/get_location.php b/DialogflowCx/samples/V3/FlowsClient/get_location.php index ee4821b62211..d037263201eb 100644 --- a/DialogflowCx/samples/V3/FlowsClient/get_location.php +++ b/DialogflowCx/samples/V3/FlowsClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Flows_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $flowsClient = new FlowsClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $flowsClient->getLocation(); + $response = $flowsClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/FlowsClient/import_flow.php b/DialogflowCx/samples/V3/FlowsClient/import_flow.php index eba189bcb62e..61e29b03a04b 100644 --- a/DialogflowCx/samples/V3/FlowsClient/import_flow.php +++ b/DialogflowCx/samples/V3/FlowsClient/import_flow.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Flows_ImportFlow_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; -use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\ImportFlowRequest; use Google\Cloud\Dialogflow\Cx\V3\ImportFlowResponse; use Google\Rpc\Status; @@ -54,10 +55,14 @@ function import_flow_sample(string $formattedParent): void // Create a client. $flowsClient = new FlowsClient(); + // Prepare the request message. + $request = (new ImportFlowRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $flowsClient->importFlow($formattedParent); + $response = $flowsClient->importFlow($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/FlowsClient/list_flows.php b/DialogflowCx/samples/V3/FlowsClient/list_flows.php index b0ac9ad7a078..14e3c2f08ac0 100644 --- a/DialogflowCx/samples/V3/FlowsClient/list_flows.php +++ b/DialogflowCx/samples/V3/FlowsClient/list_flows.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Flows_ListFlows_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient; use Google\Cloud\Dialogflow\Cx\V3\Flow; -use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\ListFlowsRequest; /** * Returns the list of all flows in the specified agent. @@ -40,10 +41,14 @@ function list_flows_sample(string $formattedParent): void // Create a client. $flowsClient = new FlowsClient(); + // Prepare the request message. + $request = (new ListFlowsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $flowsClient->listFlows($formattedParent); + $response = $flowsClient->listFlows($request); /** @var Flow $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/FlowsClient/list_locations.php b/DialogflowCx/samples/V3/FlowsClient/list_locations.php index 0473daea63ab..1f937eaf1105 100644 --- a/DialogflowCx/samples/V3/FlowsClient/list_locations.php +++ b/DialogflowCx/samples/V3/FlowsClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Flows_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $flowsClient = new FlowsClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $flowsClient->listLocations(); + $response = $flowsClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/FlowsClient/train_flow.php b/DialogflowCx/samples/V3/FlowsClient/train_flow.php index 0563d0a6d0a8..60d72613eff4 100644 --- a/DialogflowCx/samples/V3/FlowsClient/train_flow.php +++ b/DialogflowCx/samples/V3/FlowsClient/train_flow.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Flows_TrainFlow_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; -use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\TrainFlowRequest; use Google\Rpc\Status; /** @@ -55,10 +56,14 @@ function train_flow_sample(string $formattedName): void // Create a client. $flowsClient = new FlowsClient(); + // Prepare the request message. + $request = (new TrainFlowRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $flowsClient->trainFlow($formattedName); + $response = $flowsClient->trainFlow($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/FlowsClient/update_flow.php b/DialogflowCx/samples/V3/FlowsClient/update_flow.php index 59e7bd05b0d3..cd6b34b2443c 100644 --- a/DialogflowCx/samples/V3/FlowsClient/update_flow.php +++ b/DialogflowCx/samples/V3/FlowsClient/update_flow.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Flows_UpdateFlow_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient; use Google\Cloud\Dialogflow\Cx\V3\Flow; -use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateFlowRequest; /** * Updates the specified flow. @@ -41,14 +42,16 @@ function update_flow_sample(string $flowDisplayName): void // Create a client. $flowsClient = new FlowsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $flow = (new Flow()) ->setDisplayName($flowDisplayName); + $request = (new UpdateFlowRequest()) + ->setFlow($flow); // Call the API and handle any network failures. try { /** @var Flow $response */ - $response = $flowsClient->updateFlow($flow); + $response = $flowsClient->updateFlow($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/FlowsClient/validate_flow.php b/DialogflowCx/samples/V3/FlowsClient/validate_flow.php index eafd2bbedfae..2966e0e4d152 100644 --- a/DialogflowCx/samples/V3/FlowsClient/validate_flow.php +++ b/DialogflowCx/samples/V3/FlowsClient/validate_flow.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Flows_ValidateFlow_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient; use Google\Cloud\Dialogflow\Cx\V3\FlowValidationResult; -use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\ValidateFlowRequest; /** * Validates the specified flow and creates or updates validation results. @@ -42,10 +43,14 @@ function validate_flow_sample(string $formattedName): void // Create a client. $flowsClient = new FlowsClient(); + // Prepare the request message. + $request = (new ValidateFlowRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var FlowValidationResult $response */ - $response = $flowsClient->validateFlow($formattedName); + $response = $flowsClient->validateFlow($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/GeneratorsClient/create_generator.php b/DialogflowCx/samples/V3/GeneratorsClient/create_generator.php index f88efcf74fb9..d64af776758d 100644 --- a/DialogflowCx/samples/V3/GeneratorsClient/create_generator.php +++ b/DialogflowCx/samples/V3/GeneratorsClient/create_generator.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Generators_CreateGenerator_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\GeneratorsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateGeneratorRequest; use Google\Cloud\Dialogflow\Cx\V3\Generator; -use Google\Cloud\Dialogflow\Cx\V3\GeneratorsClient; use Google\Cloud\Dialogflow\Cx\V3\Phrase; /** @@ -48,17 +49,20 @@ function create_generator_sample( // Create a client. $generatorsClient = new GeneratorsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $generatorPromptText = (new Phrase()) ->setText($generatorPromptTextText); $generator = (new Generator()) ->setDisplayName($generatorDisplayName) ->setPromptText($generatorPromptText); + $request = (new CreateGeneratorRequest()) + ->setParent($formattedParent) + ->setGenerator($generator); // Call the API and handle any network failures. try { /** @var Generator $response */ - $response = $generatorsClient->createGenerator($formattedParent, $generator); + $response = $generatorsClient->createGenerator($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/GeneratorsClient/delete_generator.php b/DialogflowCx/samples/V3/GeneratorsClient/delete_generator.php index 24bdfd7ea9ac..c581b190e504 100644 --- a/DialogflowCx/samples/V3/GeneratorsClient/delete_generator.php +++ b/DialogflowCx/samples/V3/GeneratorsClient/delete_generator.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Generators_DeleteGenerator_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\GeneratorsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\GeneratorsClient; +use Google\Cloud\Dialogflow\Cx\V3\DeleteGeneratorRequest; /** * Deletes the specified generators. @@ -39,9 +40,13 @@ function delete_generator_sample(string $formattedName): void // Create a client. $generatorsClient = new GeneratorsClient(); + // Prepare the request message. + $request = (new DeleteGeneratorRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $generatorsClient->deleteGenerator($formattedName); + $generatorsClient->deleteGenerator($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/GeneratorsClient/get_generator.php b/DialogflowCx/samples/V3/GeneratorsClient/get_generator.php index 527c6a633d25..f44b708b397c 100644 --- a/DialogflowCx/samples/V3/GeneratorsClient/get_generator.php +++ b/DialogflowCx/samples/V3/GeneratorsClient/get_generator.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Generators_GetGenerator_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\GeneratorsClient; use Google\Cloud\Dialogflow\Cx\V3\Generator; -use Google\Cloud\Dialogflow\Cx\V3\GeneratorsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetGeneratorRequest; /** * Retrieves the specified generator. @@ -40,10 +41,14 @@ function get_generator_sample(string $formattedName): void // Create a client. $generatorsClient = new GeneratorsClient(); + // Prepare the request message. + $request = (new GetGeneratorRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var Generator $response */ - $response = $generatorsClient->getGenerator($formattedName); + $response = $generatorsClient->getGenerator($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/GeneratorsClient/get_location.php b/DialogflowCx/samples/V3/GeneratorsClient/get_location.php index b7169998efaa..3d3662670f8b 100644 --- a/DialogflowCx/samples/V3/GeneratorsClient/get_location.php +++ b/DialogflowCx/samples/V3/GeneratorsClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Generators_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\GeneratorsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\GeneratorsClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $generatorsClient = new GeneratorsClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $generatorsClient->getLocation(); + $response = $generatorsClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/GeneratorsClient/list_generators.php b/DialogflowCx/samples/V3/GeneratorsClient/list_generators.php index 16c3ea187b46..4a3fa3befd34 100644 --- a/DialogflowCx/samples/V3/GeneratorsClient/list_generators.php +++ b/DialogflowCx/samples/V3/GeneratorsClient/list_generators.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Generators_ListGenerators_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\GeneratorsClient; use Google\Cloud\Dialogflow\Cx\V3\Generator; -use Google\Cloud\Dialogflow\Cx\V3\GeneratorsClient; +use Google\Cloud\Dialogflow\Cx\V3\ListGeneratorsRequest; /** * Returns the list of all generators in the specified agent. @@ -40,10 +41,14 @@ function list_generators_sample(string $formattedParent): void // Create a client. $generatorsClient = new GeneratorsClient(); + // Prepare the request message. + $request = (new ListGeneratorsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $generatorsClient->listGenerators($formattedParent); + $response = $generatorsClient->listGenerators($request); /** @var Generator $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/GeneratorsClient/list_locations.php b/DialogflowCx/samples/V3/GeneratorsClient/list_locations.php index e65daf96144d..5945d2f025da 100644 --- a/DialogflowCx/samples/V3/GeneratorsClient/list_locations.php +++ b/DialogflowCx/samples/V3/GeneratorsClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Generators_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\GeneratorsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\GeneratorsClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $generatorsClient = new GeneratorsClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $generatorsClient->listLocations(); + $response = $generatorsClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/GeneratorsClient/update_generator.php b/DialogflowCx/samples/V3/GeneratorsClient/update_generator.php index ba7167c613dd..9c0f08230d99 100644 --- a/DialogflowCx/samples/V3/GeneratorsClient/update_generator.php +++ b/DialogflowCx/samples/V3/GeneratorsClient/update_generator.php @@ -24,9 +24,10 @@ // [START dialogflow_v3_generated_Generators_UpdateGenerator_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\GeneratorsClient; use Google\Cloud\Dialogflow\Cx\V3\Generator; -use Google\Cloud\Dialogflow\Cx\V3\GeneratorsClient; use Google\Cloud\Dialogflow\Cx\V3\Phrase; +use Google\Cloud\Dialogflow\Cx\V3\UpdateGeneratorRequest; /** * Update the specified generator. @@ -44,17 +45,19 @@ function update_generator_sample( // Create a client. $generatorsClient = new GeneratorsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $generatorPromptText = (new Phrase()) ->setText($generatorPromptTextText); $generator = (new Generator()) ->setDisplayName($generatorDisplayName) ->setPromptText($generatorPromptText); + $request = (new UpdateGeneratorRequest()) + ->setGenerator($generator); // Call the API and handle any network failures. try { /** @var Generator $response */ - $response = $generatorsClient->updateGenerator($generator); + $response = $generatorsClient->updateGenerator($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/IntentsClient/create_intent.php b/DialogflowCx/samples/V3/IntentsClient/create_intent.php index 8da24bdfca57..0d749913034c 100644 --- a/DialogflowCx/samples/V3/IntentsClient/create_intent.php +++ b/DialogflowCx/samples/V3/IntentsClient/create_intent.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Intents_CreateIntent_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\IntentsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateIntentRequest; use Google\Cloud\Dialogflow\Cx\V3\Intent; -use Google\Cloud\Dialogflow\Cx\V3\IntentsClient; /** * Creates an intent in the specified agent. @@ -44,14 +45,17 @@ function create_intent_sample(string $formattedParent, string $intentDisplayName // Create a client. $intentsClient = new IntentsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $intent = (new Intent()) ->setDisplayName($intentDisplayName); + $request = (new CreateIntentRequest()) + ->setParent($formattedParent) + ->setIntent($intent); // Call the API and handle any network failures. try { /** @var Intent $response */ - $response = $intentsClient->createIntent($formattedParent, $intent); + $response = $intentsClient->createIntent($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/IntentsClient/delete_intent.php b/DialogflowCx/samples/V3/IntentsClient/delete_intent.php index ed3141f0880b..dc5366fc3b14 100644 --- a/DialogflowCx/samples/V3/IntentsClient/delete_intent.php +++ b/DialogflowCx/samples/V3/IntentsClient/delete_intent.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Intents_DeleteIntent_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\IntentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\IntentsClient; +use Google\Cloud\Dialogflow\Cx\V3\DeleteIntentRequest; /** * Deletes the specified intent. @@ -43,9 +44,13 @@ function delete_intent_sample(string $formattedName): void // Create a client. $intentsClient = new IntentsClient(); + // Prepare the request message. + $request = (new DeleteIntentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $intentsClient->deleteIntent($formattedName); + $intentsClient->deleteIntent($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/IntentsClient/export_intents.php b/DialogflowCx/samples/V3/IntentsClient/export_intents.php index 705b8787e161..1ea57bdfcb27 100644 --- a/DialogflowCx/samples/V3/IntentsClient/export_intents.php +++ b/DialogflowCx/samples/V3/IntentsClient/export_intents.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Intents_ExportIntents_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\IntentsClient; +use Google\Cloud\Dialogflow\Cx\V3\ExportIntentsRequest; use Google\Cloud\Dialogflow\Cx\V3\ExportIntentsResponse; -use Google\Cloud\Dialogflow\Cx\V3\IntentsClient; use Google\Rpc\Status; /** @@ -54,13 +55,16 @@ function export_intents_sample(string $formattedParent, string $intentsElement): // Create a client. $intentsClient = new IntentsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $intents = [$intentsElement,]; + $request = (new ExportIntentsRequest()) + ->setParent($formattedParent) + ->setIntents($intents); // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $intentsClient->exportIntents($formattedParent, $intents); + $response = $intentsClient->exportIntents($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/IntentsClient/get_intent.php b/DialogflowCx/samples/V3/IntentsClient/get_intent.php index dc6ec01f2b9e..c9ce78ef1989 100644 --- a/DialogflowCx/samples/V3/IntentsClient/get_intent.php +++ b/DialogflowCx/samples/V3/IntentsClient/get_intent.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Intents_GetIntent_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\IntentsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetIntentRequest; use Google\Cloud\Dialogflow\Cx\V3\Intent; -use Google\Cloud\Dialogflow\Cx\V3\IntentsClient; /** * Retrieves the specified intent. @@ -40,10 +41,14 @@ function get_intent_sample(string $formattedName): void // Create a client. $intentsClient = new IntentsClient(); + // Prepare the request message. + $request = (new GetIntentRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var Intent $response */ - $response = $intentsClient->getIntent($formattedName); + $response = $intentsClient->getIntent($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/IntentsClient/get_location.php b/DialogflowCx/samples/V3/IntentsClient/get_location.php index 2bc81b563adc..7c5f80cee977 100644 --- a/DialogflowCx/samples/V3/IntentsClient/get_location.php +++ b/DialogflowCx/samples/V3/IntentsClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Intents_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\IntentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\IntentsClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $intentsClient = new IntentsClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $intentsClient->getLocation(); + $response = $intentsClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/IntentsClient/import_intents.php b/DialogflowCx/samples/V3/IntentsClient/import_intents.php index b1d85e26f055..34ee761d50ab 100644 --- a/DialogflowCx/samples/V3/IntentsClient/import_intents.php +++ b/DialogflowCx/samples/V3/IntentsClient/import_intents.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Intents_ImportIntents_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\IntentsClient; +use Google\Cloud\Dialogflow\Cx\V3\ImportIntentsRequest; use Google\Cloud\Dialogflow\Cx\V3\ImportIntentsResponse; -use Google\Cloud\Dialogflow\Cx\V3\IntentsClient; use Google\Rpc\Status; /** @@ -50,10 +51,14 @@ function import_intents_sample(string $formattedParent): void // Create a client. $intentsClient = new IntentsClient(); + // Prepare the request message. + $request = (new ImportIntentsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $intentsClient->importIntents($formattedParent); + $response = $intentsClient->importIntents($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/IntentsClient/list_intents.php b/DialogflowCx/samples/V3/IntentsClient/list_intents.php index 9580b931ab10..45a04e3a4981 100644 --- a/DialogflowCx/samples/V3/IntentsClient/list_intents.php +++ b/DialogflowCx/samples/V3/IntentsClient/list_intents.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Intents_ListIntents_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\IntentsClient; use Google\Cloud\Dialogflow\Cx\V3\Intent; -use Google\Cloud\Dialogflow\Cx\V3\IntentsClient; +use Google\Cloud\Dialogflow\Cx\V3\ListIntentsRequest; /** * Returns the list of all intents in the specified agent. @@ -40,10 +41,14 @@ function list_intents_sample(string $formattedParent): void // Create a client. $intentsClient = new IntentsClient(); + // Prepare the request message. + $request = (new ListIntentsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $intentsClient->listIntents($formattedParent); + $response = $intentsClient->listIntents($request); /** @var Intent $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/IntentsClient/list_locations.php b/DialogflowCx/samples/V3/IntentsClient/list_locations.php index 01f26c5f5c82..d0045558a73e 100644 --- a/DialogflowCx/samples/V3/IntentsClient/list_locations.php +++ b/DialogflowCx/samples/V3/IntentsClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Intents_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\IntentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\IntentsClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $intentsClient = new IntentsClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $intentsClient->listLocations(); + $response = $intentsClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/IntentsClient/update_intent.php b/DialogflowCx/samples/V3/IntentsClient/update_intent.php index da1750837b80..d6fbd77b0120 100644 --- a/DialogflowCx/samples/V3/IntentsClient/update_intent.php +++ b/DialogflowCx/samples/V3/IntentsClient/update_intent.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Intents_UpdateIntent_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\IntentsClient; use Google\Cloud\Dialogflow\Cx\V3\Intent; -use Google\Cloud\Dialogflow\Cx\V3\IntentsClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateIntentRequest; /** * Updates the specified intent. @@ -41,14 +42,16 @@ function update_intent_sample(string $intentDisplayName): void // Create a client. $intentsClient = new IntentsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $intent = (new Intent()) ->setDisplayName($intentDisplayName); + $request = (new UpdateIntentRequest()) + ->setIntent($intent); // Call the API and handle any network failures. try { /** @var Intent $response */ - $response = $intentsClient->updateIntent($intent); + $response = $intentsClient->updateIntent($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/PagesClient/create_page.php b/DialogflowCx/samples/V3/PagesClient/create_page.php index 6ec2a046a555..4114ef1ddd80 100644 --- a/DialogflowCx/samples/V3/PagesClient/create_page.php +++ b/DialogflowCx/samples/V3/PagesClient/create_page.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Pages_CreatePage_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\PagesClient; +use Google\Cloud\Dialogflow\Cx\V3\CreatePageRequest; use Google\Cloud\Dialogflow\Cx\V3\Page; -use Google\Cloud\Dialogflow\Cx\V3\PagesClient; /** * Creates a page in the specified flow. @@ -45,14 +46,17 @@ function create_page_sample(string $formattedParent, string $pageDisplayName): v // Create a client. $pagesClient = new PagesClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $page = (new Page()) ->setDisplayName($pageDisplayName); + $request = (new CreatePageRequest()) + ->setParent($formattedParent) + ->setPage($page); // Call the API and handle any network failures. try { /** @var Page $response */ - $response = $pagesClient->createPage($formattedParent, $page); + $response = $pagesClient->createPage($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/PagesClient/delete_page.php b/DialogflowCx/samples/V3/PagesClient/delete_page.php index 8ed6a24fa56f..79b5085bfe40 100644 --- a/DialogflowCx/samples/V3/PagesClient/delete_page.php +++ b/DialogflowCx/samples/V3/PagesClient/delete_page.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Pages_DeletePage_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\PagesClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\PagesClient; +use Google\Cloud\Dialogflow\Cx\V3\DeletePageRequest; /** * Deletes the specified page. @@ -43,9 +44,13 @@ function delete_page_sample(string $formattedName): void // Create a client. $pagesClient = new PagesClient(); + // Prepare the request message. + $request = (new DeletePageRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $pagesClient->deletePage($formattedName); + $pagesClient->deletePage($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/PagesClient/get_location.php b/DialogflowCx/samples/V3/PagesClient/get_location.php index 49c712376b42..4bdd781f63e8 100644 --- a/DialogflowCx/samples/V3/PagesClient/get_location.php +++ b/DialogflowCx/samples/V3/PagesClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Pages_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\PagesClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\PagesClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $pagesClient = new PagesClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $pagesClient->getLocation(); + $response = $pagesClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/PagesClient/get_page.php b/DialogflowCx/samples/V3/PagesClient/get_page.php index e6c7069f4c87..5a67f7b14512 100644 --- a/DialogflowCx/samples/V3/PagesClient/get_page.php +++ b/DialogflowCx/samples/V3/PagesClient/get_page.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Pages_GetPage_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\PagesClient; +use Google\Cloud\Dialogflow\Cx\V3\GetPageRequest; use Google\Cloud\Dialogflow\Cx\V3\Page; -use Google\Cloud\Dialogflow\Cx\V3\PagesClient; /** * Retrieves the specified page. @@ -40,10 +41,14 @@ function get_page_sample(string $formattedName): void // Create a client. $pagesClient = new PagesClient(); + // Prepare the request message. + $request = (new GetPageRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var Page $response */ - $response = $pagesClient->getPage($formattedName); + $response = $pagesClient->getPage($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/PagesClient/list_locations.php b/DialogflowCx/samples/V3/PagesClient/list_locations.php index c27c8ea3306a..54777b00316e 100644 --- a/DialogflowCx/samples/V3/PagesClient/list_locations.php +++ b/DialogflowCx/samples/V3/PagesClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Pages_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\PagesClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\PagesClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $pagesClient = new PagesClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $pagesClient->listLocations(); + $response = $pagesClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/PagesClient/list_pages.php b/DialogflowCx/samples/V3/PagesClient/list_pages.php index 86ade7949aa3..26ef14f835fe 100644 --- a/DialogflowCx/samples/V3/PagesClient/list_pages.php +++ b/DialogflowCx/samples/V3/PagesClient/list_pages.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Pages_ListPages_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\PagesClient; +use Google\Cloud\Dialogflow\Cx\V3\ListPagesRequest; use Google\Cloud\Dialogflow\Cx\V3\Page; -use Google\Cloud\Dialogflow\Cx\V3\PagesClient; /** * Returns the list of all pages in the specified flow. @@ -41,10 +42,14 @@ function list_pages_sample(string $formattedParent): void // Create a client. $pagesClient = new PagesClient(); + // Prepare the request message. + $request = (new ListPagesRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $pagesClient->listPages($formattedParent); + $response = $pagesClient->listPages($request); /** @var Page $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/PagesClient/update_page.php b/DialogflowCx/samples/V3/PagesClient/update_page.php index e0c16dbc9d2b..bb4a0b12392d 100644 --- a/DialogflowCx/samples/V3/PagesClient/update_page.php +++ b/DialogflowCx/samples/V3/PagesClient/update_page.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Pages_UpdatePage_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\PagesClient; use Google\Cloud\Dialogflow\Cx\V3\Page; -use Google\Cloud\Dialogflow\Cx\V3\PagesClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdatePageRequest; /** * Updates the specified page. @@ -41,14 +42,16 @@ function update_page_sample(string $pageDisplayName): void // Create a client. $pagesClient = new PagesClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $page = (new Page()) ->setDisplayName($pageDisplayName); + $request = (new UpdatePageRequest()) + ->setPage($page); // Call the API and handle any network failures. try { /** @var Page $response */ - $response = $pagesClient->updatePage($page); + $response = $pagesClient->updatePage($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/create_security_settings.php b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/create_security_settings.php index 30b2a7806643..4fa08d7dd73d 100644 --- a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/create_security_settings.php +++ b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/create_security_settings.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_SecuritySettingsService_CreateSecuritySettings_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\SecuritySettingsServiceClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateSecuritySettingsRequest; use Google\Cloud\Dialogflow\Cx\V3\SecuritySettings; -use Google\Cloud\Dialogflow\Cx\V3\SecuritySettingsServiceClient; /** * Create security settings in the specified location. @@ -44,17 +45,17 @@ function create_security_settings_sample( // Create a client. $securitySettingsServiceClient = new SecuritySettingsServiceClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $securitySettings = (new SecuritySettings()) ->setDisplayName($securitySettingsDisplayName); + $request = (new CreateSecuritySettingsRequest()) + ->setParent($formattedParent) + ->setSecuritySettings($securitySettings); // Call the API and handle any network failures. try { /** @var SecuritySettings $response */ - $response = $securitySettingsServiceClient->createSecuritySettings( - $formattedParent, - $securitySettings - ); + $response = $securitySettingsServiceClient->createSecuritySettings($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/delete_security_settings.php b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/delete_security_settings.php index 8b7b5e3ec991..3d880e26b5c1 100644 --- a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/delete_security_settings.php +++ b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/delete_security_settings.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_SecuritySettingsService_DeleteSecuritySettings_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\SecuritySettingsServiceClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\SecuritySettingsServiceClient; +use Google\Cloud\Dialogflow\Cx\V3\DeleteSecuritySettingsRequest; /** * Deletes the specified @@ -41,9 +42,13 @@ function delete_security_settings_sample(string $formattedName): void // Create a client. $securitySettingsServiceClient = new SecuritySettingsServiceClient(); + // Prepare the request message. + $request = (new DeleteSecuritySettingsRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $securitySettingsServiceClient->deleteSecuritySettings($formattedName); + $securitySettingsServiceClient->deleteSecuritySettings($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/get_location.php b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/get_location.php index 0dcacaefb3ad..e0b17f52f85c 100644 --- a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/get_location.php +++ b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_SecuritySettingsService_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\SecuritySettingsServiceClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\SecuritySettingsServiceClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $securitySettingsServiceClient = new SecuritySettingsServiceClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $securitySettingsServiceClient->getLocation(); + $response = $securitySettingsServiceClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/get_security_settings.php b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/get_security_settings.php index 0d8d4736a343..ebd5a4ef5fa3 100644 --- a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/get_security_settings.php +++ b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/get_security_settings.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_SecuritySettingsService_GetSecuritySettings_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\SecuritySettingsServiceClient; +use Google\Cloud\Dialogflow\Cx\V3\GetSecuritySettingsRequest; use Google\Cloud\Dialogflow\Cx\V3\SecuritySettings; -use Google\Cloud\Dialogflow\Cx\V3\SecuritySettingsServiceClient; /** * Retrieves the specified @@ -42,10 +43,14 @@ function get_security_settings_sample(string $formattedName): void // Create a client. $securitySettingsServiceClient = new SecuritySettingsServiceClient(); + // Prepare the request message. + $request = (new GetSecuritySettingsRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var SecuritySettings $response */ - $response = $securitySettingsServiceClient->getSecuritySettings($formattedName); + $response = $securitySettingsServiceClient->getSecuritySettings($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/list_locations.php b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/list_locations.php index bf4accef8b62..be4f58953a40 100644 --- a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/list_locations.php +++ b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_SecuritySettingsService_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\SecuritySettingsServiceClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\SecuritySettingsServiceClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $securitySettingsServiceClient = new SecuritySettingsServiceClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $securitySettingsServiceClient->listLocations(); + $response = $securitySettingsServiceClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/list_security_settings.php b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/list_security_settings.php index e2342cfeb402..27a5ecb03817 100644 --- a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/list_security_settings.php +++ b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/list_security_settings.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_SecuritySettingsService_ListSecuritySettings_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\SecuritySettingsServiceClient; +use Google\Cloud\Dialogflow\Cx\V3\ListSecuritySettingsRequest; use Google\Cloud\Dialogflow\Cx\V3\SecuritySettings; -use Google\Cloud\Dialogflow\Cx\V3\SecuritySettingsServiceClient; /** * Returns the list of all security settings in the specified location. @@ -40,10 +41,14 @@ function list_security_settings_sample(string $formattedParent): void // Create a client. $securitySettingsServiceClient = new SecuritySettingsServiceClient(); + // Prepare the request message. + $request = (new ListSecuritySettingsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $securitySettingsServiceClient->listSecuritySettings($formattedParent); + $response = $securitySettingsServiceClient->listSecuritySettings($request); /** @var SecuritySettings $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/update_security_settings.php b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/update_security_settings.php index 9eb8b5f84a08..415e7ca677b2 100644 --- a/DialogflowCx/samples/V3/SecuritySettingsServiceClient/update_security_settings.php +++ b/DialogflowCx/samples/V3/SecuritySettingsServiceClient/update_security_settings.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_SecuritySettingsService_UpdateSecuritySettings_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\SecuritySettingsServiceClient; use Google\Cloud\Dialogflow\Cx\V3\SecuritySettings; -use Google\Cloud\Dialogflow\Cx\V3\SecuritySettingsServiceClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateSecuritySettingsRequest; use Google\Protobuf\FieldMask; /** @@ -40,15 +41,18 @@ function update_security_settings_sample(string $securitySettingsDisplayName): v // Create a client. $securitySettingsServiceClient = new SecuritySettingsServiceClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $securitySettings = (new SecuritySettings()) ->setDisplayName($securitySettingsDisplayName); $updateMask = new FieldMask(); + $request = (new UpdateSecuritySettingsRequest()) + ->setSecuritySettings($securitySettings) + ->setUpdateMask($updateMask); // Call the API and handle any network failures. try { /** @var SecuritySettings $response */ - $response = $securitySettingsServiceClient->updateSecuritySettings($securitySettings, $updateMask); + $response = $securitySettingsServiceClient->updateSecuritySettings($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SessionEntityTypesClient/create_session_entity_type.php b/DialogflowCx/samples/V3/SessionEntityTypesClient/create_session_entity_type.php index 4cccdab488eb..d66ed4c3fde9 100644 --- a/DialogflowCx/samples/V3/SessionEntityTypesClient/create_session_entity_type.php +++ b/DialogflowCx/samples/V3/SessionEntityTypesClient/create_session_entity_type.php @@ -24,10 +24,11 @@ // [START dialogflow_v3_generated_SessionEntityTypes_CreateSessionEntityType_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionEntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateSessionEntityTypeRequest; use Google\Cloud\Dialogflow\Cx\V3\EntityType\Entity; use Google\Cloud\Dialogflow\Cx\V3\SessionEntityType; use Google\Cloud\Dialogflow\Cx\V3\SessionEntityType\EntityOverrideMode; -use Google\Cloud\Dialogflow\Cx\V3\SessionEntityTypesClient; /** * Creates a session entity type. @@ -78,7 +79,7 @@ function create_session_entity_type_sample( // Create a client. $sessionEntityTypesClient = new SessionEntityTypesClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $sessionEntityTypeEntitiesSynonyms = [$sessionEntityTypeEntitiesSynonymsElement,]; $entity = (new Entity()) ->setValue($sessionEntityTypeEntitiesValue) @@ -88,14 +89,14 @@ function create_session_entity_type_sample( ->setName($sessionEntityTypeName) ->setEntityOverrideMode($sessionEntityTypeEntityOverrideMode) ->setEntities($sessionEntityTypeEntities); + $request = (new CreateSessionEntityTypeRequest()) + ->setParent($formattedParent) + ->setSessionEntityType($sessionEntityType); // Call the API and handle any network failures. try { /** @var SessionEntityType $response */ - $response = $sessionEntityTypesClient->createSessionEntityType( - $formattedParent, - $sessionEntityType - ); + $response = $sessionEntityTypesClient->createSessionEntityType($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SessionEntityTypesClient/delete_session_entity_type.php b/DialogflowCx/samples/V3/SessionEntityTypesClient/delete_session_entity_type.php index f885465342d5..335f8fdfa221 100644 --- a/DialogflowCx/samples/V3/SessionEntityTypesClient/delete_session_entity_type.php +++ b/DialogflowCx/samples/V3/SessionEntityTypesClient/delete_session_entity_type.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_SessionEntityTypes_DeleteSessionEntityType_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\SessionEntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionEntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\DeleteSessionEntityTypeRequest; /** * Deletes the specified session entity type. @@ -43,9 +44,13 @@ function delete_session_entity_type_sample(string $formattedName): void // Create a client. $sessionEntityTypesClient = new SessionEntityTypesClient(); + // Prepare the request message. + $request = (new DeleteSessionEntityTypeRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $sessionEntityTypesClient->deleteSessionEntityType($formattedName); + $sessionEntityTypesClient->deleteSessionEntityType($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SessionEntityTypesClient/get_location.php b/DialogflowCx/samples/V3/SessionEntityTypesClient/get_location.php index c598855fc003..b19a64414652 100644 --- a/DialogflowCx/samples/V3/SessionEntityTypesClient/get_location.php +++ b/DialogflowCx/samples/V3/SessionEntityTypesClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_SessionEntityTypes_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\SessionEntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionEntityTypesClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $sessionEntityTypesClient = new SessionEntityTypesClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $sessionEntityTypesClient->getLocation(); + $response = $sessionEntityTypesClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SessionEntityTypesClient/get_session_entity_type.php b/DialogflowCx/samples/V3/SessionEntityTypesClient/get_session_entity_type.php index b4f5b704c660..d760f41f8e9c 100644 --- a/DialogflowCx/samples/V3/SessionEntityTypesClient/get_session_entity_type.php +++ b/DialogflowCx/samples/V3/SessionEntityTypesClient/get_session_entity_type.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_SessionEntityTypes_GetSessionEntityType_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionEntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\GetSessionEntityTypeRequest; use Google\Cloud\Dialogflow\Cx\V3\SessionEntityType; -use Google\Cloud\Dialogflow\Cx\V3\SessionEntityTypesClient; /** * Retrieves the specified session entity type. @@ -44,10 +45,14 @@ function get_session_entity_type_sample(string $formattedName): void // Create a client. $sessionEntityTypesClient = new SessionEntityTypesClient(); + // Prepare the request message. + $request = (new GetSessionEntityTypeRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var SessionEntityType $response */ - $response = $sessionEntityTypesClient->getSessionEntityType($formattedName); + $response = $sessionEntityTypesClient->getSessionEntityType($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SessionEntityTypesClient/list_locations.php b/DialogflowCx/samples/V3/SessionEntityTypesClient/list_locations.php index fa8045a3c9f1..660e3ccd0cbd 100644 --- a/DialogflowCx/samples/V3/SessionEntityTypesClient/list_locations.php +++ b/DialogflowCx/samples/V3/SessionEntityTypesClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_SessionEntityTypes_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\SessionEntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionEntityTypesClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $sessionEntityTypesClient = new SessionEntityTypesClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $sessionEntityTypesClient->listLocations(); + $response = $sessionEntityTypesClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/SessionEntityTypesClient/list_session_entity_types.php b/DialogflowCx/samples/V3/SessionEntityTypesClient/list_session_entity_types.php index b1dff0ca02c3..85f5e86a8079 100644 --- a/DialogflowCx/samples/V3/SessionEntityTypesClient/list_session_entity_types.php +++ b/DialogflowCx/samples/V3/SessionEntityTypesClient/list_session_entity_types.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_SessionEntityTypes_ListSessionEntityTypes_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionEntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\ListSessionEntityTypesRequest; use Google\Cloud\Dialogflow\Cx\V3\SessionEntityType; -use Google\Cloud\Dialogflow\Cx\V3\SessionEntityTypesClient; /** * Returns the list of all session entity types in the specified session. @@ -44,10 +45,14 @@ function list_session_entity_types_sample(string $formattedParent): void // Create a client. $sessionEntityTypesClient = new SessionEntityTypesClient(); + // Prepare the request message. + $request = (new ListSessionEntityTypesRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $sessionEntityTypesClient->listSessionEntityTypes($formattedParent); + $response = $sessionEntityTypesClient->listSessionEntityTypes($request); /** @var SessionEntityType $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/SessionEntityTypesClient/update_session_entity_type.php b/DialogflowCx/samples/V3/SessionEntityTypesClient/update_session_entity_type.php index c5a04bbb01ab..4cf2e0e726f8 100644 --- a/DialogflowCx/samples/V3/SessionEntityTypesClient/update_session_entity_type.php +++ b/DialogflowCx/samples/V3/SessionEntityTypesClient/update_session_entity_type.php @@ -24,10 +24,11 @@ // [START dialogflow_v3_generated_SessionEntityTypes_UpdateSessionEntityType_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionEntityTypesClient; use Google\Cloud\Dialogflow\Cx\V3\EntityType\Entity; use Google\Cloud\Dialogflow\Cx\V3\SessionEntityType; use Google\Cloud\Dialogflow\Cx\V3\SessionEntityType\EntityOverrideMode; -use Google\Cloud\Dialogflow\Cx\V3\SessionEntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateSessionEntityTypeRequest; /** * Updates the specified session entity type. @@ -70,7 +71,7 @@ function update_session_entity_type_sample( // Create a client. $sessionEntityTypesClient = new SessionEntityTypesClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $sessionEntityTypeEntitiesSynonyms = [$sessionEntityTypeEntitiesSynonymsElement,]; $entity = (new Entity()) ->setValue($sessionEntityTypeEntitiesValue) @@ -80,11 +81,13 @@ function update_session_entity_type_sample( ->setName($sessionEntityTypeName) ->setEntityOverrideMode($sessionEntityTypeEntityOverrideMode) ->setEntities($sessionEntityTypeEntities); + $request = (new UpdateSessionEntityTypeRequest()) + ->setSessionEntityType($sessionEntityType); // Call the API and handle any network failures. try { /** @var SessionEntityType $response */ - $response = $sessionEntityTypesClient->updateSessionEntityType($sessionEntityType); + $response = $sessionEntityTypesClient->updateSessionEntityType($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SessionsClient/detect_intent.php b/DialogflowCx/samples/V3/SessionsClient/detect_intent.php index 4e61757c9581..761d1bae5d1e 100644 --- a/DialogflowCx/samples/V3/SessionsClient/detect_intent.php +++ b/DialogflowCx/samples/V3/SessionsClient/detect_intent.php @@ -24,9 +24,10 @@ // [START dialogflow_v3_generated_Sessions_DetectIntent_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionsClient; +use Google\Cloud\Dialogflow\Cx\V3\DetectIntentRequest; use Google\Cloud\Dialogflow\Cx\V3\DetectIntentResponse; use Google\Cloud\Dialogflow\Cx\V3\QueryInput; -use Google\Cloud\Dialogflow\Cx\V3\SessionsClient; /** * Processes a natural language query and returns structured, actionable data @@ -65,14 +66,17 @@ function detect_intent_sample(string $formattedSession, string $queryInputLangua // Create a client. $sessionsClient = new SessionsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $queryInput = (new QueryInput()) ->setLanguageCode($queryInputLanguageCode); + $request = (new DetectIntentRequest()) + ->setSession($formattedSession) + ->setQueryInput($queryInput); // Call the API and handle any network failures. try { /** @var DetectIntentResponse $response */ - $response = $sessionsClient->detectIntent($formattedSession, $queryInput); + $response = $sessionsClient->detectIntent($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SessionsClient/fulfill_intent.php b/DialogflowCx/samples/V3/SessionsClient/fulfill_intent.php index 99d06a70da02..5f01de768aea 100644 --- a/DialogflowCx/samples/V3/SessionsClient/fulfill_intent.php +++ b/DialogflowCx/samples/V3/SessionsClient/fulfill_intent.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Sessions_FulfillIntent_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionsClient; +use Google\Cloud\Dialogflow\Cx\V3\FulfillIntentRequest; use Google\Cloud\Dialogflow\Cx\V3\FulfillIntentResponse; -use Google\Cloud\Dialogflow\Cx\V3\SessionsClient; /** * Fulfills a matched intent returned by @@ -47,10 +48,13 @@ function fulfill_intent_sample(): void // Create a client. $sessionsClient = new SessionsClient(); + // Prepare the request message. + $request = new FulfillIntentRequest(); + // Call the API and handle any network failures. try { /** @var FulfillIntentResponse $response */ - $response = $sessionsClient->fulfillIntent(); + $response = $sessionsClient->fulfillIntent($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SessionsClient/get_location.php b/DialogflowCx/samples/V3/SessionsClient/get_location.php index f5d5625ccef2..e29204ecaa0c 100644 --- a/DialogflowCx/samples/V3/SessionsClient/get_location.php +++ b/DialogflowCx/samples/V3/SessionsClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Sessions_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\SessionsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionsClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $sessionsClient = new SessionsClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $sessionsClient->getLocation(); + $response = $sessionsClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SessionsClient/list_locations.php b/DialogflowCx/samples/V3/SessionsClient/list_locations.php index f1464e5d2e77..1288feafb0df 100644 --- a/DialogflowCx/samples/V3/SessionsClient/list_locations.php +++ b/DialogflowCx/samples/V3/SessionsClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Sessions_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\SessionsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionsClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $sessionsClient = new SessionsClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $sessionsClient->listLocations(); + $response = $sessionsClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/SessionsClient/match_intent.php b/DialogflowCx/samples/V3/SessionsClient/match_intent.php index 233acf36a2bc..9d5b2a7e6d8f 100644 --- a/DialogflowCx/samples/V3/SessionsClient/match_intent.php +++ b/DialogflowCx/samples/V3/SessionsClient/match_intent.php @@ -24,9 +24,10 @@ // [START dialogflow_v3_generated_Sessions_MatchIntent_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionsClient; +use Google\Cloud\Dialogflow\Cx\V3\MatchIntentRequest; use Google\Cloud\Dialogflow\Cx\V3\MatchIntentResponse; use Google\Cloud\Dialogflow\Cx\V3\QueryInput; -use Google\Cloud\Dialogflow\Cx\V3\SessionsClient; /** * Returns preliminary intent match results, doesn't change the session @@ -55,14 +56,17 @@ function match_intent_sample(string $formattedSession, string $queryInputLanguag // Create a client. $sessionsClient = new SessionsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $queryInput = (new QueryInput()) ->setLanguageCode($queryInputLanguageCode); + $request = (new MatchIntentRequest()) + ->setSession($formattedSession) + ->setQueryInput($queryInput); // Call the API and handle any network failures. try { /** @var MatchIntentResponse $response */ - $response = $sessionsClient->matchIntent($formattedSession, $queryInput); + $response = $sessionsClient->matchIntent($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/SessionsClient/streaming_detect_intent.php b/DialogflowCx/samples/V3/SessionsClient/streaming_detect_intent.php index e0d917aedff7..772820000189 100644 --- a/DialogflowCx/samples/V3/SessionsClient/streaming_detect_intent.php +++ b/DialogflowCx/samples/V3/SessionsClient/streaming_detect_intent.php @@ -25,8 +25,8 @@ // [START dialogflow_v3_generated_Sessions_StreamingDetectIntent_sync] use Google\ApiCore\ApiException; use Google\ApiCore\BidiStream; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionsClient; use Google\Cloud\Dialogflow\Cx\V3\QueryInput; -use Google\Cloud\Dialogflow\Cx\V3\SessionsClient; use Google\Cloud\Dialogflow\Cx\V3\StreamingDetectIntentRequest; use Google\Cloud\Dialogflow\Cx\V3\StreamingDetectIntentResponse; @@ -49,7 +49,7 @@ function streaming_detect_intent_sample(string $queryInputLanguageCode): void // Create a client. $sessionsClient = new SessionsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $queryInput = (new QueryInput()) ->setLanguageCode($queryInputLanguageCode); $request = (new StreamingDetectIntentRequest()) diff --git a/DialogflowCx/samples/V3/SessionsClient/submit_answer_feedback.php b/DialogflowCx/samples/V3/SessionsClient/submit_answer_feedback.php index a4a14136991d..327ead33eae1 100644 --- a/DialogflowCx/samples/V3/SessionsClient/submit_answer_feedback.php +++ b/DialogflowCx/samples/V3/SessionsClient/submit_answer_feedback.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Sessions_SubmitAnswerFeedback_sync] use Google\ApiCore\ApiException; use Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback; -use Google\Cloud\Dialogflow\Cx\V3\SessionsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionsClient; +use Google\Cloud\Dialogflow\Cx\V3\SubmitAnswerFeedbackRequest; /** * Updates the feedback received from the user for a single turn of the bot @@ -41,13 +42,17 @@ function submit_answer_feedback_sample(string $formattedSession, string $respons // Create a client. $sessionsClient = new SessionsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $answerFeedback = new AnswerFeedback(); + $request = (new SubmitAnswerFeedbackRequest()) + ->setSession($formattedSession) + ->setResponseId($responseId) + ->setAnswerFeedback($answerFeedback); // Call the API and handle any network failures. try { /** @var AnswerFeedback $response */ - $response = $sessionsClient->submitAnswerFeedback($formattedSession, $responseId, $answerFeedback); + $response = $sessionsClient->submitAnswerFeedback($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/TestCasesClient/batch_delete_test_cases.php b/DialogflowCx/samples/V3/TestCasesClient/batch_delete_test_cases.php index 57118005f019..785a700debc1 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/batch_delete_test_cases.php +++ b/DialogflowCx/samples/V3/TestCasesClient/batch_delete_test_cases.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_TestCases_BatchDeleteTestCases_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\BatchDeleteTestCasesRequest; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; /** * Batch deletes test cases. @@ -43,12 +44,15 @@ function batch_delete_test_cases_sample( // Create a client. $testCasesClient = new TestCasesClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $formattedNames = [$formattedNamesElement,]; + $request = (new BatchDeleteTestCasesRequest()) + ->setParent($formattedParent) + ->setNames($formattedNames); // Call the API and handle any network failures. try { - $testCasesClient->batchDeleteTestCases($formattedParent, $formattedNames); + $testCasesClient->batchDeleteTestCases($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/TestCasesClient/batch_run_test_cases.php b/DialogflowCx/samples/V3/TestCasesClient/batch_run_test_cases.php index 2436668c29fd..9d21bd8d8b51 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/batch_run_test_cases.php +++ b/DialogflowCx/samples/V3/TestCasesClient/batch_run_test_cases.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_TestCases_BatchRunTestCases_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; +use Google\Cloud\Dialogflow\Cx\V3\BatchRunTestCasesRequest; use Google\Cloud\Dialogflow\Cx\V3\BatchRunTestCasesResponse; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; use Google\Rpc\Status; /** @@ -55,13 +56,16 @@ function batch_run_test_cases_sample( // Create a client. $testCasesClient = new TestCasesClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $formattedTestCases = [$formattedTestCasesElement,]; + $request = (new BatchRunTestCasesRequest()) + ->setParent($formattedParent) + ->setTestCases($formattedTestCases); // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $testCasesClient->batchRunTestCases($formattedParent, $formattedTestCases); + $response = $testCasesClient->batchRunTestCases($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/TestCasesClient/calculate_coverage.php b/DialogflowCx/samples/V3/TestCasesClient/calculate_coverage.php index dc4d206aca34..b87633bd4251 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/calculate_coverage.php +++ b/DialogflowCx/samples/V3/TestCasesClient/calculate_coverage.php @@ -24,9 +24,10 @@ // [START dialogflow_v3_generated_TestCases_CalculateCoverage_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageRequest; use Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageRequest\CoverageType; use Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageResponse; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; /** * Calculates the test coverage for an agent. @@ -41,10 +42,15 @@ function calculate_coverage_sample(string $formattedAgent, int $type): void // Create a client. $testCasesClient = new TestCasesClient(); + // Prepare the request message. + $request = (new CalculateCoverageRequest()) + ->setAgent($formattedAgent) + ->setType($type); + // Call the API and handle any network failures. try { /** @var CalculateCoverageResponse $response */ - $response = $testCasesClient->calculateCoverage($formattedAgent, $type); + $response = $testCasesClient->calculateCoverage($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/TestCasesClient/create_test_case.php b/DialogflowCx/samples/V3/TestCasesClient/create_test_case.php index fe6ca56fc1a0..332dc0b308a6 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/create_test_case.php +++ b/DialogflowCx/samples/V3/TestCasesClient/create_test_case.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_TestCases_CreateTestCase_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateTestCaseRequest; use Google\Cloud\Dialogflow\Cx\V3\TestCase; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; /** * Creates a test case for the given agent. @@ -41,14 +42,17 @@ function create_test_case_sample(string $formattedParent, string $testCaseDispla // Create a client. $testCasesClient = new TestCasesClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $testCase = (new TestCase()) ->setDisplayName($testCaseDisplayName); + $request = (new CreateTestCaseRequest()) + ->setParent($formattedParent) + ->setTestCase($testCase); // Call the API and handle any network failures. try { /** @var TestCase $response */ - $response = $testCasesClient->createTestCase($formattedParent, $testCase); + $response = $testCasesClient->createTestCase($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/TestCasesClient/export_test_cases.php b/DialogflowCx/samples/V3/TestCasesClient/export_test_cases.php index 525274bfd729..b831cd6a15e3 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/export_test_cases.php +++ b/DialogflowCx/samples/V3/TestCasesClient/export_test_cases.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_TestCases_ExportTestCases_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\ExportTestCasesRequest; use Google\Cloud\Dialogflow\Cx\V3\ExportTestCasesResponse; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; use Google\Rpc\Status; /** @@ -51,10 +52,14 @@ function export_test_cases_sample(string $formattedParent): void // Create a client. $testCasesClient = new TestCasesClient(); + // Prepare the request message. + $request = (new ExportTestCasesRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $testCasesClient->exportTestCases($formattedParent); + $response = $testCasesClient->exportTestCases($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/TestCasesClient/get_location.php b/DialogflowCx/samples/V3/TestCasesClient/get_location.php index 9bf99a63c293..d5fad5a8855f 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/get_location.php +++ b/DialogflowCx/samples/V3/TestCasesClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_TestCases_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $testCasesClient = new TestCasesClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $testCasesClient->getLocation(); + $response = $testCasesClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/TestCasesClient/get_test_case.php b/DialogflowCx/samples/V3/TestCasesClient/get_test_case.php index a326c128df01..c9685a09642d 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/get_test_case.php +++ b/DialogflowCx/samples/V3/TestCasesClient/get_test_case.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_TestCases_GetTestCase_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\GetTestCaseRequest; use Google\Cloud\Dialogflow\Cx\V3\TestCase; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; /** * Gets a test case. @@ -40,10 +41,14 @@ function get_test_case_sample(string $formattedName): void // Create a client. $testCasesClient = new TestCasesClient(); + // Prepare the request message. + $request = (new GetTestCaseRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var TestCase $response */ - $response = $testCasesClient->getTestCase($formattedName); + $response = $testCasesClient->getTestCase($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/TestCasesClient/get_test_case_result.php b/DialogflowCx/samples/V3/TestCasesClient/get_test_case_result.php index 633520b18c8e..17e68d5e53a9 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/get_test_case_result.php +++ b/DialogflowCx/samples/V3/TestCasesClient/get_test_case_result.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_TestCases_GetTestCaseResult_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\GetTestCaseResultRequest; use Google\Cloud\Dialogflow\Cx\V3\TestCaseResult; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; /** * Gets a test case result. @@ -40,10 +41,14 @@ function get_test_case_result_sample(string $formattedName): void // Create a client. $testCasesClient = new TestCasesClient(); + // Prepare the request message. + $request = (new GetTestCaseResultRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var TestCaseResult $response */ - $response = $testCasesClient->getTestCaseResult($formattedName); + $response = $testCasesClient->getTestCaseResult($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/TestCasesClient/import_test_cases.php b/DialogflowCx/samples/V3/TestCasesClient/import_test_cases.php index 2a25f7fed38e..6bf451b1ddb5 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/import_test_cases.php +++ b/DialogflowCx/samples/V3/TestCasesClient/import_test_cases.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_TestCases_ImportTestCases_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\ImportTestCasesRequest; use Google\Cloud\Dialogflow\Cx\V3\ImportTestCasesResponse; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; use Google\Rpc\Status; /** @@ -52,10 +53,14 @@ function import_test_cases_sample(string $formattedParent): void // Create a client. $testCasesClient = new TestCasesClient(); + // Prepare the request message. + $request = (new ImportTestCasesRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $testCasesClient->importTestCases($formattedParent); + $response = $testCasesClient->importTestCases($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/TestCasesClient/list_locations.php b/DialogflowCx/samples/V3/TestCasesClient/list_locations.php index 6ea271acf874..671954615e23 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/list_locations.php +++ b/DialogflowCx/samples/V3/TestCasesClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_TestCases_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $testCasesClient = new TestCasesClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $testCasesClient->listLocations(); + $response = $testCasesClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/TestCasesClient/list_test_case_results.php b/DialogflowCx/samples/V3/TestCasesClient/list_test_case_results.php index 55908883caac..61ed825bc6c4 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/list_test_case_results.php +++ b/DialogflowCx/samples/V3/TestCasesClient/list_test_case_results.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_TestCases_ListTestCaseResults_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\ListTestCaseResultsRequest; use Google\Cloud\Dialogflow\Cx\V3\TestCaseResult; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; /** * Fetches the list of run results for the given test case. A maximum of 100 @@ -43,10 +44,14 @@ function list_test_case_results_sample(string $formattedParent): void // Create a client. $testCasesClient = new TestCasesClient(); + // Prepare the request message. + $request = (new ListTestCaseResultsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $testCasesClient->listTestCaseResults($formattedParent); + $response = $testCasesClient->listTestCaseResults($request); /** @var TestCaseResult $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/TestCasesClient/list_test_cases.php b/DialogflowCx/samples/V3/TestCasesClient/list_test_cases.php index 739c0ee9a032..614d3c21db23 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/list_test_cases.php +++ b/DialogflowCx/samples/V3/TestCasesClient/list_test_cases.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_TestCases_ListTestCases_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\ListTestCasesRequest; use Google\Cloud\Dialogflow\Cx\V3\TestCase; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; /** * Fetches a list of test cases for a given agent. @@ -40,10 +41,14 @@ function list_test_cases_sample(string $formattedParent): void // Create a client. $testCasesClient = new TestCasesClient(); + // Prepare the request message. + $request = (new ListTestCasesRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $testCasesClient->listTestCases($formattedParent); + $response = $testCasesClient->listTestCases($request); /** @var TestCase $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/TestCasesClient/run_test_case.php b/DialogflowCx/samples/V3/TestCasesClient/run_test_case.php index a6fb009bd584..a1553a5fdf1f 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/run_test_case.php +++ b/DialogflowCx/samples/V3/TestCasesClient/run_test_case.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_TestCases_RunTestCase_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\RunTestCaseRequest; use Google\Cloud\Dialogflow\Cx\V3\RunTestCaseResponse; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; use Google\Rpc\Status; /** @@ -50,10 +51,14 @@ function run_test_case_sample(string $formattedName): void // Create a client. $testCasesClient = new TestCasesClient(); + // Prepare the request message. + $request = (new RunTestCaseRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $testCasesClient->runTestCase($formattedName); + $response = $testCasesClient->runTestCase($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/TestCasesClient/update_test_case.php b/DialogflowCx/samples/V3/TestCasesClient/update_test_case.php index b13a42dfe883..0992d7b44209 100644 --- a/DialogflowCx/samples/V3/TestCasesClient/update_test_case.php +++ b/DialogflowCx/samples/V3/TestCasesClient/update_test_case.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_TestCases_UpdateTestCase_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; use Google\Cloud\Dialogflow\Cx\V3\TestCase; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateTestCaseRequest; use Google\Protobuf\FieldMask; /** @@ -39,15 +40,18 @@ function update_test_case_sample(string $testCaseDisplayName): void // Create a client. $testCasesClient = new TestCasesClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $testCase = (new TestCase()) ->setDisplayName($testCaseDisplayName); $updateMask = new FieldMask(); + $request = (new UpdateTestCaseRequest()) + ->setTestCase($testCase) + ->setUpdateMask($updateMask); // Call the API and handle any network failures. try { /** @var TestCase $response */ - $response = $testCasesClient->updateTestCase($testCase, $updateMask); + $response = $testCasesClient->updateTestCase($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/create_transition_route_group.php b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/create_transition_route_group.php index dd9c109be5ab..cbf61cd5587a 100644 --- a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/create_transition_route_group.php +++ b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/create_transition_route_group.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_TransitionRouteGroups_CreateTransitionRouteGroup_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\TransitionRouteGroupsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateTransitionRouteGroupRequest; use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroup; -use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroupsClient; /** * Creates an @@ -53,17 +54,17 @@ function create_transition_route_group_sample( // Create a client. $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $transitionRouteGroup = (new TransitionRouteGroup()) ->setDisplayName($transitionRouteGroupDisplayName); + $request = (new CreateTransitionRouteGroupRequest()) + ->setParent($formattedParent) + ->setTransitionRouteGroup($transitionRouteGroup); // Call the API and handle any network failures. try { /** @var TransitionRouteGroup $response */ - $response = $transitionRouteGroupsClient->createTransitionRouteGroup( - $formattedParent, - $transitionRouteGroup - ); + $response = $transitionRouteGroupsClient->createTransitionRouteGroup($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/delete_transition_route_group.php b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/delete_transition_route_group.php index dad2ce289200..93dfada3f5dd 100644 --- a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/delete_transition_route_group.php +++ b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/delete_transition_route_group.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_TransitionRouteGroups_DeleteTransitionRouteGroup_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroupsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\TransitionRouteGroupsClient; +use Google\Cloud\Dialogflow\Cx\V3\DeleteTransitionRouteGroupRequest; /** * Deletes the specified @@ -47,9 +48,13 @@ function delete_transition_route_group_sample(string $formattedName): void // Create a client. $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); + // Prepare the request message. + $request = (new DeleteTransitionRouteGroupRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $transitionRouteGroupsClient->deleteTransitionRouteGroup($formattedName); + $transitionRouteGroupsClient->deleteTransitionRouteGroup($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/get_location.php b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/get_location.php index 899f69945d3d..d6dca2770530 100644 --- a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/get_location.php +++ b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_TransitionRouteGroups_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroupsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\TransitionRouteGroupsClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $transitionRouteGroupsClient->getLocation(); + $response = $transitionRouteGroupsClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/get_transition_route_group.php b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/get_transition_route_group.php index 47e86f74badc..62d07a94e564 100644 --- a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/get_transition_route_group.php +++ b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/get_transition_route_group.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_TransitionRouteGroups_GetTransitionRouteGroup_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\TransitionRouteGroupsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetTransitionRouteGroupRequest; use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroup; -use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroupsClient; /** * Retrieves the specified @@ -44,10 +45,14 @@ function get_transition_route_group_sample(string $formattedName): void // Create a client. $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); + // Prepare the request message. + $request = (new GetTransitionRouteGroupRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var TransitionRouteGroup $response */ - $response = $transitionRouteGroupsClient->getTransitionRouteGroup($formattedName); + $response = $transitionRouteGroupsClient->getTransitionRouteGroup($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/list_locations.php b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/list_locations.php index c09e43eab405..7afe4eda2824 100644 --- a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/list_locations.php +++ b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_TransitionRouteGroups_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroupsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\TransitionRouteGroupsClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $transitionRouteGroupsClient->listLocations(); + $response = $transitionRouteGroupsClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/list_transition_route_groups.php b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/list_transition_route_groups.php index 6bd60cdca0e0..73ed12b7b060 100644 --- a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/list_transition_route_groups.php +++ b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/list_transition_route_groups.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_TransitionRouteGroups_ListTransitionRouteGroups_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\TransitionRouteGroupsClient; +use Google\Cloud\Dialogflow\Cx\V3\ListTransitionRouteGroupsRequest; use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroup; -use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroupsClient; /** * Returns the list of all transition route groups in the specified flow. @@ -42,10 +43,14 @@ function list_transition_route_groups_sample(string $formattedParent): void // Create a client. $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); + // Prepare the request message. + $request = (new ListTransitionRouteGroupsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $transitionRouteGroupsClient->listTransitionRouteGroups($formattedParent); + $response = $transitionRouteGroupsClient->listTransitionRouteGroups($request); /** @var TransitionRouteGroup $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/update_transition_route_group.php b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/update_transition_route_group.php index e0ba191204a9..1a71b2bcaf4f 100644 --- a/DialogflowCx/samples/V3/TransitionRouteGroupsClient/update_transition_route_group.php +++ b/DialogflowCx/samples/V3/TransitionRouteGroupsClient/update_transition_route_group.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_TransitionRouteGroups_UpdateTransitionRouteGroup_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\TransitionRouteGroupsClient; use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroup; -use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroupsClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateTransitionRouteGroupRequest; /** * Updates the specified @@ -43,14 +44,16 @@ function update_transition_route_group_sample(string $transitionRouteGroupDispla // Create a client. $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $transitionRouteGroup = (new TransitionRouteGroup()) ->setDisplayName($transitionRouteGroupDisplayName); + $request = (new UpdateTransitionRouteGroupRequest()) + ->setTransitionRouteGroup($transitionRouteGroup); // Call the API and handle any network failures. try { /** @var TransitionRouteGroup $response */ - $response = $transitionRouteGroupsClient->updateTransitionRouteGroup($transitionRouteGroup); + $response = $transitionRouteGroupsClient->updateTransitionRouteGroup($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/VersionsClient/compare_versions.php b/DialogflowCx/samples/V3/VersionsClient/compare_versions.php index 356b639c9c69..31e7db6932ce 100644 --- a/DialogflowCx/samples/V3/VersionsClient/compare_versions.php +++ b/DialogflowCx/samples/V3/VersionsClient/compare_versions.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Versions_CompareVersions_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\VersionsClient; +use Google\Cloud\Dialogflow\Cx\V3\CompareVersionsRequest; use Google\Cloud\Dialogflow\Cx\V3\CompareVersionsResponse; -use Google\Cloud\Dialogflow\Cx\V3\VersionsClient; /** * Compares the specified base version with target version. @@ -49,10 +50,15 @@ function compare_versions_sample( // Create a client. $versionsClient = new VersionsClient(); + // Prepare the request message. + $request = (new CompareVersionsRequest()) + ->setBaseVersion($formattedBaseVersion) + ->setTargetVersion($formattedTargetVersion); + // Call the API and handle any network failures. try { /** @var CompareVersionsResponse $response */ - $response = $versionsClient->compareVersions($formattedBaseVersion, $formattedTargetVersion); + $response = $versionsClient->compareVersions($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/VersionsClient/create_version.php b/DialogflowCx/samples/V3/VersionsClient/create_version.php index fabbe2b59f80..e9facdb2f5ea 100644 --- a/DialogflowCx/samples/V3/VersionsClient/create_version.php +++ b/DialogflowCx/samples/V3/VersionsClient/create_version.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Versions_CreateVersion_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\VersionsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateVersionRequest; use Google\Cloud\Dialogflow\Cx\V3\Version; -use Google\Cloud\Dialogflow\Cx\V3\VersionsClient; use Google\Rpc\Status; /** @@ -53,14 +54,17 @@ function create_version_sample(string $formattedParent, string $versionDisplayNa // Create a client. $versionsClient = new VersionsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $version = (new Version()) ->setDisplayName($versionDisplayName); + $request = (new CreateVersionRequest()) + ->setParent($formattedParent) + ->setVersion($version); // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $versionsClient->createVersion($formattedParent, $version); + $response = $versionsClient->createVersion($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/VersionsClient/delete_version.php b/DialogflowCx/samples/V3/VersionsClient/delete_version.php index b56e57b509e5..9fd008efe15e 100644 --- a/DialogflowCx/samples/V3/VersionsClient/delete_version.php +++ b/DialogflowCx/samples/V3/VersionsClient/delete_version.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Versions_DeleteVersion_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\VersionsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\VersionsClient; +use Google\Cloud\Dialogflow\Cx\V3\DeleteVersionRequest; /** * Deletes the specified [Version][google.cloud.dialogflow.cx.v3.Version]. @@ -39,9 +40,13 @@ function delete_version_sample(string $formattedName): void // Create a client. $versionsClient = new VersionsClient(); + // Prepare the request message. + $request = (new DeleteVersionRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $versionsClient->deleteVersion($formattedName); + $versionsClient->deleteVersion($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/VersionsClient/get_location.php b/DialogflowCx/samples/V3/VersionsClient/get_location.php index 440a5f88952c..c6b8e497fea5 100644 --- a/DialogflowCx/samples/V3/VersionsClient/get_location.php +++ b/DialogflowCx/samples/V3/VersionsClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Versions_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\VersionsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\VersionsClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $versionsClient = new VersionsClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $versionsClient->getLocation(); + $response = $versionsClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/VersionsClient/get_version.php b/DialogflowCx/samples/V3/VersionsClient/get_version.php index 26af15bde8b7..c6eb1042380a 100644 --- a/DialogflowCx/samples/V3/VersionsClient/get_version.php +++ b/DialogflowCx/samples/V3/VersionsClient/get_version.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Versions_GetVersion_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\VersionsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetVersionRequest; use Google\Cloud\Dialogflow\Cx\V3\Version; -use Google\Cloud\Dialogflow\Cx\V3\VersionsClient; /** * Retrieves the specified [Version][google.cloud.dialogflow.cx.v3.Version]. @@ -40,10 +41,14 @@ function get_version_sample(string $formattedName): void // Create a client. $versionsClient = new VersionsClient(); + // Prepare the request message. + $request = (new GetVersionRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var Version $response */ - $response = $versionsClient->getVersion($formattedName); + $response = $versionsClient->getVersion($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/VersionsClient/list_locations.php b/DialogflowCx/samples/V3/VersionsClient/list_locations.php index 777031f524f9..328988effa43 100644 --- a/DialogflowCx/samples/V3/VersionsClient/list_locations.php +++ b/DialogflowCx/samples/V3/VersionsClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Versions_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\VersionsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\VersionsClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $versionsClient = new VersionsClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $versionsClient->listLocations(); + $response = $versionsClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/VersionsClient/list_versions.php b/DialogflowCx/samples/V3/VersionsClient/list_versions.php index 7231e7b581a4..970bdb978ad8 100644 --- a/DialogflowCx/samples/V3/VersionsClient/list_versions.php +++ b/DialogflowCx/samples/V3/VersionsClient/list_versions.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Versions_ListVersions_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\VersionsClient; +use Google\Cloud\Dialogflow\Cx\V3\ListVersionsRequest; use Google\Cloud\Dialogflow\Cx\V3\Version; -use Google\Cloud\Dialogflow\Cx\V3\VersionsClient; /** * Returns the list of all versions in the specified @@ -42,10 +43,14 @@ function list_versions_sample(string $formattedParent): void // Create a client. $versionsClient = new VersionsClient(); + // Prepare the request message. + $request = (new ListVersionsRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $versionsClient->listVersions($formattedParent); + $response = $versionsClient->listVersions($request); /** @var Version $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/VersionsClient/load_version.php b/DialogflowCx/samples/V3/VersionsClient/load_version.php index b4102f309c21..4492a3be3ec0 100644 --- a/DialogflowCx/samples/V3/VersionsClient/load_version.php +++ b/DialogflowCx/samples/V3/VersionsClient/load_version.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Versions_LoadVersion_sync] use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; -use Google\Cloud\Dialogflow\Cx\V3\VersionsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\VersionsClient; +use Google\Cloud\Dialogflow\Cx\V3\LoadVersionRequest; use Google\Rpc\Status; /** @@ -50,10 +51,14 @@ function load_version_sample(string $formattedName): void // Create a client. $versionsClient = new VersionsClient(); + // Prepare the request message. + $request = (new LoadVersionRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var OperationResponse $response */ - $response = $versionsClient->loadVersion($formattedName); + $response = $versionsClient->loadVersion($request); $response->pollUntilComplete(); if ($response->operationSucceeded()) { diff --git a/DialogflowCx/samples/V3/VersionsClient/update_version.php b/DialogflowCx/samples/V3/VersionsClient/update_version.php index 743606142ab9..9913267b371a 100644 --- a/DialogflowCx/samples/V3/VersionsClient/update_version.php +++ b/DialogflowCx/samples/V3/VersionsClient/update_version.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Versions_UpdateVersion_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\VersionsClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateVersionRequest; use Google\Cloud\Dialogflow\Cx\V3\Version; -use Google\Cloud\Dialogflow\Cx\V3\VersionsClient; use Google\Protobuf\FieldMask; /** @@ -38,15 +39,18 @@ function update_version_sample(string $versionDisplayName): void // Create a client. $versionsClient = new VersionsClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $version = (new Version()) ->setDisplayName($versionDisplayName); $updateMask = new FieldMask(); + $request = (new UpdateVersionRequest()) + ->setVersion($version) + ->setUpdateMask($updateMask); // Call the API and handle any network failures. try { /** @var Version $response */ - $response = $versionsClient->updateVersion($version, $updateMask); + $response = $versionsClient->updateVersion($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/WebhooksClient/create_webhook.php b/DialogflowCx/samples/V3/WebhooksClient/create_webhook.php index 72bdc0670a54..d250cf3743e3 100644 --- a/DialogflowCx/samples/V3/WebhooksClient/create_webhook.php +++ b/DialogflowCx/samples/V3/WebhooksClient/create_webhook.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Webhooks_CreateWebhook_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\WebhooksClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateWebhookRequest; use Google\Cloud\Dialogflow\Cx\V3\Webhook; -use Google\Cloud\Dialogflow\Cx\V3\WebhooksClient; /** * Creates a webhook in the specified agent. @@ -40,14 +41,17 @@ function create_webhook_sample(string $formattedParent, string $webhookDisplayNa // Create a client. $webhooksClient = new WebhooksClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $webhook = (new Webhook()) ->setDisplayName($webhookDisplayName); + $request = (new CreateWebhookRequest()) + ->setParent($formattedParent) + ->setWebhook($webhook); // Call the API and handle any network failures. try { /** @var Webhook $response */ - $response = $webhooksClient->createWebhook($formattedParent, $webhook); + $response = $webhooksClient->createWebhook($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/WebhooksClient/delete_webhook.php b/DialogflowCx/samples/V3/WebhooksClient/delete_webhook.php index c2b898eb57c0..4a909a87c0f2 100644 --- a/DialogflowCx/samples/V3/WebhooksClient/delete_webhook.php +++ b/DialogflowCx/samples/V3/WebhooksClient/delete_webhook.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Webhooks_DeleteWebhook_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\WebhooksClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\WebhooksClient; +use Google\Cloud\Dialogflow\Cx\V3\DeleteWebhookRequest; /** * Deletes the specified webhook. @@ -39,9 +40,13 @@ function delete_webhook_sample(string $formattedName): void // Create a client. $webhooksClient = new WebhooksClient(); + // Prepare the request message. + $request = (new DeleteWebhookRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $webhooksClient->deleteWebhook($formattedName); + $webhooksClient->deleteWebhook($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/WebhooksClient/get_location.php b/DialogflowCx/samples/V3/WebhooksClient/get_location.php index 1ed4dccc7543..09e8bd0f4b51 100644 --- a/DialogflowCx/samples/V3/WebhooksClient/get_location.php +++ b/DialogflowCx/samples/V3/WebhooksClient/get_location.php @@ -24,7 +24,8 @@ // [START dialogflow_v3_generated_Webhooks_GetLocation_sync] use Google\ApiCore\ApiException; -use Google\Cloud\Dialogflow\Cx\V3\WebhooksClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\WebhooksClient; +use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\Location; /** @@ -41,10 +42,13 @@ function get_location_sample(): void // Create a client. $webhooksClient = new WebhooksClient(); + // Prepare the request message. + $request = new GetLocationRequest(); + // Call the API and handle any network failures. try { /** @var Location $response */ - $response = $webhooksClient->getLocation(); + $response = $webhooksClient->getLocation($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/WebhooksClient/get_webhook.php b/DialogflowCx/samples/V3/WebhooksClient/get_webhook.php index 450787c35bfe..28be7d6f0d3a 100644 --- a/DialogflowCx/samples/V3/WebhooksClient/get_webhook.php +++ b/DialogflowCx/samples/V3/WebhooksClient/get_webhook.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Webhooks_GetWebhook_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\WebhooksClient; +use Google\Cloud\Dialogflow\Cx\V3\GetWebhookRequest; use Google\Cloud\Dialogflow\Cx\V3\Webhook; -use Google\Cloud\Dialogflow\Cx\V3\WebhooksClient; /** * Retrieves the specified webhook. @@ -40,10 +41,14 @@ function get_webhook_sample(string $formattedName): void // Create a client. $webhooksClient = new WebhooksClient(); + // Prepare the request message. + $request = (new GetWebhookRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { /** @var Webhook $response */ - $response = $webhooksClient->getWebhook($formattedName); + $response = $webhooksClient->getWebhook($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/samples/V3/WebhooksClient/list_locations.php b/DialogflowCx/samples/V3/WebhooksClient/list_locations.php index c4d350911da0..4caf1d645cd9 100644 --- a/DialogflowCx/samples/V3/WebhooksClient/list_locations.php +++ b/DialogflowCx/samples/V3/WebhooksClient/list_locations.php @@ -25,7 +25,8 @@ // [START dialogflow_v3_generated_Webhooks_ListLocations_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; -use Google\Cloud\Dialogflow\Cx\V3\WebhooksClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\WebhooksClient; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; /** @@ -42,10 +43,13 @@ function list_locations_sample(): void // Create a client. $webhooksClient = new WebhooksClient(); + // Prepare the request message. + $request = new ListLocationsRequest(); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $webhooksClient->listLocations(); + $response = $webhooksClient->listLocations($request); /** @var Location $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/WebhooksClient/list_webhooks.php b/DialogflowCx/samples/V3/WebhooksClient/list_webhooks.php index c29d65d1cb4f..aa9aad325bac 100644 --- a/DialogflowCx/samples/V3/WebhooksClient/list_webhooks.php +++ b/DialogflowCx/samples/V3/WebhooksClient/list_webhooks.php @@ -25,8 +25,9 @@ // [START dialogflow_v3_generated_Webhooks_ListWebhooks_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\WebhooksClient; +use Google\Cloud\Dialogflow\Cx\V3\ListWebhooksRequest; use Google\Cloud\Dialogflow\Cx\V3\Webhook; -use Google\Cloud\Dialogflow\Cx\V3\WebhooksClient; /** * Returns the list of all webhooks in the specified agent. @@ -40,10 +41,14 @@ function list_webhooks_sample(string $formattedParent): void // Create a client. $webhooksClient = new WebhooksClient(); + // Prepare the request message. + $request = (new ListWebhooksRequest()) + ->setParent($formattedParent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $webhooksClient->listWebhooks($formattedParent); + $response = $webhooksClient->listWebhooks($request); /** @var Webhook $element */ foreach ($response as $element) { diff --git a/DialogflowCx/samples/V3/WebhooksClient/update_webhook.php b/DialogflowCx/samples/V3/WebhooksClient/update_webhook.php index 4520515ef93c..5b5835cf4bdc 100644 --- a/DialogflowCx/samples/V3/WebhooksClient/update_webhook.php +++ b/DialogflowCx/samples/V3/WebhooksClient/update_webhook.php @@ -24,8 +24,9 @@ // [START dialogflow_v3_generated_Webhooks_UpdateWebhook_sync] use Google\ApiCore\ApiException; +use Google\Cloud\Dialogflow\Cx\V3\Client\WebhooksClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateWebhookRequest; use Google\Cloud\Dialogflow\Cx\V3\Webhook; -use Google\Cloud\Dialogflow\Cx\V3\WebhooksClient; /** * Updates the specified webhook. @@ -37,14 +38,16 @@ function update_webhook_sample(string $webhookDisplayName): void // Create a client. $webhooksClient = new WebhooksClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $webhook = (new Webhook()) ->setDisplayName($webhookDisplayName); + $request = (new UpdateWebhookRequest()) + ->setWebhook($webhook); // Call the API and handle any network failures. try { /** @var Webhook $response */ - $response = $webhooksClient->updateWebhook($webhook); + $response = $webhooksClient->updateWebhook($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/DialogflowCx/src/V3/AgentsClient.php b/DialogflowCx/src/V3/AgentsClient.php deleted file mode 100644 index a8f41a02aaca..000000000000 --- a/DialogflowCx/src/V3/AgentsClient.php +++ /dev/null @@ -1,34 +0,0 @@ -/locations//agents/`. Please see + * {@see TestCasesClient::agentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\BatchDeleteTestCasesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ChangelogsClient.php b/DialogflowCx/src/V3/ChangelogsClient.php deleted file mode 100644 index e765ced9aeeb..000000000000 --- a/DialogflowCx/src/V3/ChangelogsClient.php +++ /dev/null @@ -1,34 +0,0 @@ - self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/agents_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/agents_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/agents_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/agents_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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(string $project, string $location, string $agent): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * agent_generative_settings resource. + * + * @param string $project + * @param string $location + * @param string $agent + * + * @return string The formatted agent_generative_settings resource. + */ + public static function agentGenerativeSettingsName(string $project, string $location, string $agent): string + { + return self::getPathTemplate('agentGenerativeSettings')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * agent_validation_result resource. + * + * @param string $project + * @param string $location + * @param string $agent + * + * @return string The formatted agent_validation_result resource. + */ + public static function agentValidationResultName(string $project, string $location, string $agent): string + { + return self::getPathTemplate('agentValidationResult')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a environment + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $environment + * + * @return string The formatted environment resource. + */ + public static function environmentName( + string $project, + string $location, + string $agent, + string $environment + ): string { + return self::getPathTemplate('environment')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'environment' => $environment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a flow + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * + * @return string The formatted flow resource. + */ + public static function flowName(string $project, string $location, string $agent, string $flow): string + { + return self::getPathTemplate('flow')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * security_settings resource. + * + * @param string $project + * @param string $location + * @param string $securitySettings + * + * @return string The formatted security_settings resource. + */ + public static function securitySettingsName(string $project, string $location, string $securitySettings): string + { + return self::getPathTemplate('securitySettings')->render([ + 'project' => $project, + 'location' => $location, + 'security_settings' => $securitySettings, + ]); + } + + /** + * 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} + * - agentGenerativeSettings: projects/{project}/locations/{location}/agents/{agent}/generativeSettings + * - agentValidationResult: projects/{project}/locations/{location}/agents/{agent}/validationResult + * - environment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment} + * - flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow} + * - location: projects/{project}/locations/{location} + * - securitySettings: projects/{project}/locations/{location}/securitySettings/{security_settings} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an agent in the specified location. + * + * Note: You should always train flows prior to sending them queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see AgentsClient::createAgentAsync()} . + * + * @example samples/V3/AgentsClient/create_agent.php + * + * @param CreateAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Agent + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAgent(CreateAgentRequest $request, array $callOptions = []): Agent + { + return $this->startApiCall('CreateAgent', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified agent. + * + * The async variant is {@see AgentsClient::deleteAgentAsync()} . + * + * @example samples/V3/AgentsClient/delete_agent.php + * + * @param DeleteAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function deleteAgent(DeleteAgentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAgent', $request, $callOptions)->wait(); + } + + /** + * Exports the specified agent to a binary file. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: + * [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse] + * + * The async variant is {@see AgentsClient::exportAgentAsync()} . + * + * @example samples/V3/AgentsClient/export_agent.php + * + * @param ExportAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportAgent(ExportAgentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportAgent', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified agent. + * + * The async variant is {@see AgentsClient::getAgentAsync()} . + * + * @example samples/V3/AgentsClient/get_agent.php + * + * @param GetAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Agent + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAgent(GetAgentRequest $request, array $callOptions = []): Agent + { + return $this->startApiCall('GetAgent', $request, $callOptions)->wait(); + } + + /** + * Gets the latest agent validation result. Agent validation is performed + * when ValidateAgent is called. + * + * The async variant is {@see AgentsClient::getAgentValidationResultAsync()} . + * + * @example samples/V3/AgentsClient/get_agent_validation_result.php + * + * @param GetAgentValidationResultRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 AgentValidationResult + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAgentValidationResult( + GetAgentValidationResultRequest $request, + array $callOptions = [] + ): AgentValidationResult { + return $this->startApiCall('GetAgentValidationResult', $request, $callOptions)->wait(); + } + + /** + * Gets the generative settings for the agent. + * + * The async variant is {@see AgentsClient::getGenerativeSettingsAsync()} . + * + * @example samples/V3/AgentsClient/get_generative_settings.php + * + * @param GetGenerativeSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 GenerativeSettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function getGenerativeSettings( + GetGenerativeSettingsRequest $request, + array $callOptions = [] + ): GenerativeSettings { + return $this->startApiCall('GetGenerativeSettings', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all agents in the specified location. + * + * The async variant is {@see AgentsClient::listAgentsAsync()} . + * + * @example samples/V3/AgentsClient/list_agents.php + * + * @param ListAgentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAgents(ListAgentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAgents', $request, $callOptions); + } + + /** + * Restores the specified agent from a binary file. + * + * Replaces the current agent with a new one. Note that all existing resources + * in agent (e.g. intents, entity types, flows) will be removed. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * Note: You should always train flows prior to sending them queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see AgentsClient::restoreAgentAsync()} . + * + * @example samples/V3/AgentsClient/restore_agent.php + * + * @param RestoreAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restoreAgent(RestoreAgentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RestoreAgent', $request, $callOptions)->wait(); + } + + /** + * Updates the specified agent. + * + * Note: You should always train flows prior to sending them queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see AgentsClient::updateAgentAsync()} . + * + * @example samples/V3/AgentsClient/update_agent.php + * + * @param UpdateAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Agent + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAgent(UpdateAgentRequest $request, array $callOptions = []): Agent + { + return $this->startApiCall('UpdateAgent', $request, $callOptions)->wait(); + } + + /** + * Updates the generative settings for the agent. + * + * The async variant is {@see AgentsClient::updateGenerativeSettingsAsync()} . + * + * @example samples/V3/AgentsClient/update_generative_settings.php + * + * @param UpdateGenerativeSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 GenerativeSettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateGenerativeSettings( + UpdateGenerativeSettingsRequest $request, + array $callOptions = [] + ): GenerativeSettings { + return $this->startApiCall('UpdateGenerativeSettings', $request, $callOptions)->wait(); + } + + /** + * Validates the specified agent and creates or updates validation results. + * The agent in draft version is validated. Please call this API after the + * training is completed to get the complete validation results. + * + * The async variant is {@see AgentsClient::validateAgentAsync()} . + * + * @example samples/V3/AgentsClient/validate_agent.php + * + * @param ValidateAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 AgentValidationResult + * + * @throws ApiException Thrown if the API call fails. + */ + public function validateAgent(ValidateAgentRequest $request, array $callOptions = []): AgentValidationResult + { + return $this->startApiCall('ValidateAgent', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see AgentsClient::getLocationAsync()} . + * + * @example samples/V3/AgentsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see AgentsClient::listLocationsAsync()} . + * + * @example samples/V3/AgentsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/ChangelogsClient.php b/DialogflowCx/src/V3/Client/ChangelogsClient.php new file mode 100644 index 000000000000..b7111e93a19c --- /dev/null +++ b/DialogflowCx/src/V3/Client/ChangelogsClient.php @@ -0,0 +1,348 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/changelogs_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/changelogs_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/changelogs_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/changelogs_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $project, string $location, string $agent): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a changelog + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $changelog + * + * @return string The formatted changelog resource. + */ + public static function changelogName(string $project, string $location, string $agent, string $changelog): string + { + return self::getPathTemplate('changelog')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'changelog' => $changelog, + ]); + } + + /** + * 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} + * - changelog: projects/{project}/locations/{location}/agents/{agent}/changelogs/{changelog} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the specified Changelog. + * + * The async variant is {@see ChangelogsClient::getChangelogAsync()} . + * + * @example samples/V3/ChangelogsClient/get_changelog.php + * + * @param GetChangelogRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Changelog + * + * @throws ApiException Thrown if the API call fails. + */ + public function getChangelog(GetChangelogRequest $request, array $callOptions = []): Changelog + { + return $this->startApiCall('GetChangelog', $request, $callOptions)->wait(); + } + + /** + * Returns the list of Changelogs. + * + * The async variant is {@see ChangelogsClient::listChangelogsAsync()} . + * + * @example samples/V3/ChangelogsClient/list_changelogs.php + * + * @param ListChangelogsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listChangelogs(ListChangelogsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListChangelogs', $request, $callOptions); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ChangelogsClient::getLocationAsync()} . + * + * @example samples/V3/ChangelogsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ChangelogsClient::listLocationsAsync()} . + * + * @example samples/V3/ChangelogsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/DeploymentsClient.php b/DialogflowCx/src/V3/Client/DeploymentsClient.php new file mode 100644 index 000000000000..7f3af796b52a --- /dev/null +++ b/DialogflowCx/src/V3/Client/DeploymentsClient.php @@ -0,0 +1,363 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/deployments_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/deployments_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/deployments_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/deployments_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a deployment + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $environment + * @param string $deployment + * + * @return string The formatted deployment resource. + */ + public static function deploymentName( + string $project, + string $location, + string $agent, + string $environment, + string $deployment + ): string { + return self::getPathTemplate('deployment')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'environment' => $environment, + 'deployment' => $deployment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a environment + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $environment + * + * @return string The formatted environment resource. + */ + public static function environmentName( + string $project, + string $location, + string $agent, + string $environment + ): string { + return self::getPathTemplate('environment')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'environment' => $environment, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - deployment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/deployments/{deployment} + * - environment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the specified + * [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. + * + * The async variant is {@see DeploymentsClient::getDeploymentAsync()} . + * + * @example samples/V3/DeploymentsClient/get_deployment.php + * + * @param GetDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Deployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDeployment(GetDeploymentRequest $request, array $callOptions = []): Deployment + { + return $this->startApiCall('GetDeployment', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all deployments in the specified + * [Environment][google.cloud.dialogflow.cx.v3.Environment]. + * + * The async variant is {@see DeploymentsClient::listDeploymentsAsync()} . + * + * @example samples/V3/DeploymentsClient/list_deployments.php + * + * @param ListDeploymentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDeployments(ListDeploymentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDeployments', $request, $callOptions); + } + + /** + * Gets information about a location. + * + * The async variant is {@see DeploymentsClient::getLocationAsync()} . + * + * @example samples/V3/DeploymentsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see DeploymentsClient::listLocationsAsync()} . + * + * @example samples/V3/DeploymentsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/EntityTypesClient.php b/DialogflowCx/src/V3/Client/EntityTypesClient.php new file mode 100644 index 000000000000..3b4615389740 --- /dev/null +++ b/DialogflowCx/src/V3/Client/EntityTypesClient.php @@ -0,0 +1,442 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/entity_types_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/entity_types_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/entity_types_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/entity_types_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $project, string $location, string $agent): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a entity_type + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $entityType + * + * @return string The formatted entity_type resource. + */ + public static function entityTypeName(string $project, string $location, string $agent, string $entityType): string + { + return self::getPathTemplate('entityType')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'entity_type' => $entityType, + ]); + } + + /** + * 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} + * - entityType: projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an entity type in the specified agent. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see EntityTypesClient::createEntityTypeAsync()} . + * + * @example samples/V3/EntityTypesClient/create_entity_type.php + * + * @param CreateEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 EntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEntityType(CreateEntityTypeRequest $request, array $callOptions = []): EntityType + { + return $this->startApiCall('CreateEntityType', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified entity type. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see EntityTypesClient::deleteEntityTypeAsync()} . + * + * @example samples/V3/EntityTypesClient/delete_entity_type.php + * + * @param DeleteEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function deleteEntityType(DeleteEntityTypeRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteEntityType', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified entity type. + * + * The async variant is {@see EntityTypesClient::getEntityTypeAsync()} . + * + * @example samples/V3/EntityTypesClient/get_entity_type.php + * + * @param GetEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 EntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEntityType(GetEntityTypeRequest $request, array $callOptions = []): EntityType + { + return $this->startApiCall('GetEntityType', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all entity types in the specified agent. + * + * The async variant is {@see EntityTypesClient::listEntityTypesAsync()} . + * + * @example samples/V3/EntityTypesClient/list_entity_types.php + * + * @param ListEntityTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEntityTypes(ListEntityTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEntityTypes', $request, $callOptions); + } + + /** + * Updates the specified entity type. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see EntityTypesClient::updateEntityTypeAsync()} . + * + * @example samples/V3/EntityTypesClient/update_entity_type.php + * + * @param UpdateEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 EntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEntityType(UpdateEntityTypeRequest $request, array $callOptions = []): EntityType + { + return $this->startApiCall('UpdateEntityType', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see EntityTypesClient::getLocationAsync()} . + * + * @example samples/V3/EntityTypesClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see EntityTypesClient::listLocationsAsync()} . + * + * @example samples/V3/EntityTypesClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/EnvironmentsClient.php b/DialogflowCx/src/V3/Client/EnvironmentsClient.php new file mode 100644 index 000000000000..6b7fa9d2dd74 --- /dev/null +++ b/DialogflowCx/src/V3/Client/EnvironmentsClient.php @@ -0,0 +1,732 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/environments_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/environments_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/environments_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/environments_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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(string $project, string $location, string $agent): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a environment + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $environment + * + * @return string The formatted environment resource. + */ + public static function environmentName( + string $project, + string $location, + string $agent, + string $environment + ): string { + return self::getPathTemplate('environment')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'environment' => $environment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $namespace + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $namespace, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'namespace' => $namespace, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a test_case + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $testCase + * + * @return string The formatted test_case resource. + */ + public static function testCaseName(string $project, string $location, string $agent, string $testCase): string + { + return self::getPathTemplate('testCase')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'test_case' => $testCase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a version + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $version + * + * @return string The formatted version resource. + */ + public static function versionName( + string $project, + string $location, + string $agent, + string $flow, + string $version + ): string { + return self::getPathTemplate('version')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'version' => $version, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a webhook + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $webhook + * + * @return string The formatted webhook resource. + */ + public static function webhookName(string $project, string $location, string $agent, string $webhook): string + { + return self::getPathTemplate('webhook')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'webhook' => $webhook, + ]); + } + + /** + * 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} + * - environment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment} + * - service: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service} + * - testCase: projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case} + * - version: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version} + * - webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an [Environment][google.cloud.dialogflow.cx.v3.Environment] in the + * specified [Agent][google.cloud.dialogflow.cx.v3.Agent]. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: [Environment][google.cloud.dialogflow.cx.v3.Environment] + * + * The async variant is {@see EnvironmentsClient::createEnvironmentAsync()} . + * + * @example samples/V3/EnvironmentsClient/create_environment.php + * + * @param CreateEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEnvironment(CreateEnvironmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateEnvironment', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified + * [Environment][google.cloud.dialogflow.cx.v3.Environment]. + * + * The async variant is {@see EnvironmentsClient::deleteEnvironmentAsync()} . + * + * @example samples/V3/EnvironmentsClient/delete_environment.php + * + * @param DeleteEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function deleteEnvironment(DeleteEnvironmentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteEnvironment', $request, $callOptions)->wait(); + } + + /** + * Deploys a flow to the specified + * [Environment][google.cloud.dialogflow.cx.v3.Environment]. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [DeployFlowMetadata][google.cloud.dialogflow.cx.v3.DeployFlowMetadata] + * - `response`: + * [DeployFlowResponse][google.cloud.dialogflow.cx.v3.DeployFlowResponse] + * + * The async variant is {@see EnvironmentsClient::deployFlowAsync()} . + * + * @example samples/V3/EnvironmentsClient/deploy_flow.php + * + * @param DeployFlowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deployFlow(DeployFlowRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeployFlow', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified + * [Environment][google.cloud.dialogflow.cx.v3.Environment]. + * + * The async variant is {@see EnvironmentsClient::getEnvironmentAsync()} . + * + * @example samples/V3/EnvironmentsClient/get_environment.php + * + * @param GetEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Environment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEnvironment(GetEnvironmentRequest $request, array $callOptions = []): Environment + { + return $this->startApiCall('GetEnvironment', $request, $callOptions)->wait(); + } + + /** + * Fetches a list of continuous test results for a given environment. + * + * The async variant is {@see EnvironmentsClient::listContinuousTestResultsAsync()} + * . + * + * @example samples/V3/EnvironmentsClient/list_continuous_test_results.php + * + * @param ListContinuousTestResultsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listContinuousTestResults( + ListContinuousTestResultsRequest $request, + array $callOptions = [] + ): PagedListResponse { + return $this->startApiCall('ListContinuousTestResults', $request, $callOptions); + } + + /** + * Returns the list of all environments in the specified + * [Agent][google.cloud.dialogflow.cx.v3.Agent]. + * + * The async variant is {@see EnvironmentsClient::listEnvironmentsAsync()} . + * + * @example samples/V3/EnvironmentsClient/list_environments.php + * + * @param ListEnvironmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEnvironments(ListEnvironmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEnvironments', $request, $callOptions); + } + + /** + * Looks up the history of the specified + * [Environment][google.cloud.dialogflow.cx.v3.Environment]. + * + * The async variant is {@see EnvironmentsClient::lookupEnvironmentHistoryAsync()} + * . + * + * @example samples/V3/EnvironmentsClient/lookup_environment_history.php + * + * @param LookupEnvironmentHistoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function lookupEnvironmentHistory( + LookupEnvironmentHistoryRequest $request, + array $callOptions = [] + ): PagedListResponse { + return $this->startApiCall('LookupEnvironmentHistory', $request, $callOptions); + } + + /** + * Kicks off a continuous test under the specified + * [Environment][google.cloud.dialogflow.cx.v3.Environment]. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [RunContinuousTestMetadata][google.cloud.dialogflow.cx.v3.RunContinuousTestMetadata] + * - `response`: + * [RunContinuousTestResponse][google.cloud.dialogflow.cx.v3.RunContinuousTestResponse] + * + * The async variant is {@see EnvironmentsClient::runContinuousTestAsync()} . + * + * @example samples/V3/EnvironmentsClient/run_continuous_test.php + * + * @param RunContinuousTestRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function runContinuousTest(RunContinuousTestRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RunContinuousTest', $request, $callOptions)->wait(); + } + + /** + * Updates the specified + * [Environment][google.cloud.dialogflow.cx.v3.Environment]. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: [Environment][google.cloud.dialogflow.cx.v3.Environment] + * + * The async variant is {@see EnvironmentsClient::updateEnvironmentAsync()} . + * + * @example samples/V3/EnvironmentsClient/update_environment.php + * + * @param UpdateEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEnvironment(UpdateEnvironmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateEnvironment', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see EnvironmentsClient::getLocationAsync()} . + * + * @example samples/V3/EnvironmentsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see EnvironmentsClient::listLocationsAsync()} . + * + * @example samples/V3/EnvironmentsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/ExperimentsClient.php b/DialogflowCx/src/V3/Client/ExperimentsClient.php new file mode 100644 index 000000000000..e8693b42c482 --- /dev/null +++ b/DialogflowCx/src/V3/Client/ExperimentsClient.php @@ -0,0 +1,536 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/experiments_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/experiments_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/experiments_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/experiments_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a environment + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $environment + * + * @return string The formatted environment resource. + */ + public static function environmentName( + string $project, + string $location, + string $agent, + string $environment + ): string { + return self::getPathTemplate('environment')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'environment' => $environment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a experiment + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $environment + * @param string $experiment + * + * @return string The formatted experiment resource. + */ + public static function experimentName( + string $project, + string $location, + string $agent, + string $environment, + string $experiment + ): string { + return self::getPathTemplate('experiment')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'environment' => $environment, + 'experiment' => $experiment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a version + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $version + * + * @return string The formatted version resource. + */ + public static function versionName( + string $project, + string $location, + string $agent, + string $flow, + string $version + ): string { + return self::getPathTemplate('version')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'version' => $version, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - environment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment} + * - experiment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/experiments/{experiment} + * - version: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an [Experiment][google.cloud.dialogflow.cx.v3.Experiment] in the + * specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. + * + * The async variant is {@see ExperimentsClient::createExperimentAsync()} . + * + * @example samples/V3/ExperimentsClient/create_experiment.php + * + * @param CreateExperimentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Experiment + * + * @throws ApiException Thrown if the API call fails. + */ + public function createExperiment(CreateExperimentRequest $request, array $callOptions = []): Experiment + { + return $this->startApiCall('CreateExperiment', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified + * [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. + * + * The async variant is {@see ExperimentsClient::deleteExperimentAsync()} . + * + * @example samples/V3/ExperimentsClient/delete_experiment.php + * + * @param DeleteExperimentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function deleteExperiment(DeleteExperimentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteExperiment', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified + * [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. + * + * The async variant is {@see ExperimentsClient::getExperimentAsync()} . + * + * @example samples/V3/ExperimentsClient/get_experiment.php + * + * @param GetExperimentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Experiment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getExperiment(GetExperimentRequest $request, array $callOptions = []): Experiment + { + return $this->startApiCall('GetExperiment', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all experiments in the specified + * [Environment][google.cloud.dialogflow.cx.v3.Environment]. + * + * The async variant is {@see ExperimentsClient::listExperimentsAsync()} . + * + * @example samples/V3/ExperimentsClient/list_experiments.php + * + * @param ListExperimentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listExperiments(ListExperimentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListExperiments', $request, $callOptions); + } + + /** + * Starts the specified + * [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc only + * changes the state of experiment from PENDING to RUNNING. + * + * The async variant is {@see ExperimentsClient::startExperimentAsync()} . + * + * @example samples/V3/ExperimentsClient/start_experiment.php + * + * @param StartExperimentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Experiment + * + * @throws ApiException Thrown if the API call fails. + */ + public function startExperiment(StartExperimentRequest $request, array $callOptions = []): Experiment + { + return $this->startApiCall('StartExperiment', $request, $callOptions)->wait(); + } + + /** + * Stops the specified [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. + * This rpc only changes the state of experiment from RUNNING to DONE. + * + * The async variant is {@see ExperimentsClient::stopExperimentAsync()} . + * + * @example samples/V3/ExperimentsClient/stop_experiment.php + * + * @param StopExperimentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Experiment + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopExperiment(StopExperimentRequest $request, array $callOptions = []): Experiment + { + return $this->startApiCall('StopExperiment', $request, $callOptions)->wait(); + } + + /** + * Updates the specified + * [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. + * + * The async variant is {@see ExperimentsClient::updateExperimentAsync()} . + * + * @example samples/V3/ExperimentsClient/update_experiment.php + * + * @param UpdateExperimentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Experiment + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateExperiment(UpdateExperimentRequest $request, array $callOptions = []): Experiment + { + return $this->startApiCall('UpdateExperiment', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ExperimentsClient::getLocationAsync()} . + * + * @example samples/V3/ExperimentsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ExperimentsClient::listLocationsAsync()} . + * + * @example samples/V3/ExperimentsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/FlowsClient.php b/DialogflowCx/src/V3/Client/FlowsClient.php new file mode 100644 index 000000000000..56d729704c95 --- /dev/null +++ b/DialogflowCx/src/V3/Client/FlowsClient.php @@ -0,0 +1,846 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/flows_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/flows_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/flows_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/flows_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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(string $project, string $location, string $agent): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a flow + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * + * @return string The formatted flow resource. + */ + public static function flowName(string $project, string $location, string $agent, string $flow): string + { + return self::getPathTemplate('flow')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * flow_validation_result resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * + * @return string The formatted flow_validation_result resource. + */ + public static function flowValidationResultName( + string $project, + string $location, + string $agent, + string $flow + ): string { + return self::getPathTemplate('flowValidationResult')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a intent + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $intent + * + * @return string The formatted intent resource. + */ + public static function intentName(string $project, string $location, string $agent, string $intent): string + { + return self::getPathTemplate('intent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'intent' => $intent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a page + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $page + * + * @return string The formatted page resource. + */ + public static function pageName( + string $project, + string $location, + string $agent, + string $flow, + string $page + ): string { + return self::getPathTemplate('page')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'page' => $page, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_flow_transition_route_group resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $transitionRouteGroup + * + * @return string The formatted project_location_agent_flow_transition_route_group resource. + */ + public static function projectLocationAgentFlowTransitionRouteGroupName( + string $project, + string $location, + string $agent, + string $flow, + string $transitionRouteGroup + ): string { + return self::getPathTemplate('projectLocationAgentFlowTransitionRouteGroup')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'transition_route_group' => $transitionRouteGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_transition_route_group resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $transitionRouteGroup + * + * @return string The formatted project_location_agent_transition_route_group resource. + */ + public static function projectLocationAgentTransitionRouteGroupName( + string $project, + string $location, + string $agent, + string $transitionRouteGroup + ): string { + return self::getPathTemplate('projectLocationAgentTransitionRouteGroup')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'transition_route_group' => $transitionRouteGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * transition_route_group resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $transitionRouteGroup + * + * @return string The formatted transition_route_group resource. + */ + public static function transitionRouteGroupName( + string $project, + string $location, + string $agent, + string $flow, + string $transitionRouteGroup + ): string { + return self::getPathTemplate('transitionRouteGroup')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'transition_route_group' => $transitionRouteGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a webhook + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $webhook + * + * @return string The formatted webhook resource. + */ + public static function webhookName(string $project, string $location, string $agent, string $webhook): string + { + return self::getPathTemplate('webhook')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'webhook' => $webhook, + ]); + } + + /** + * 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} + * - flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow} + * - flowValidationResult: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/validationResult + * - intent: projects/{project}/locations/{location}/agents/{agent}/intents/{intent} + * - page: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page} + * - projectLocationAgentFlowTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} + * - projectLocationAgentTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group} + * - transitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} + * - webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a flow in the specified agent. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see FlowsClient::createFlowAsync()} . + * + * @example samples/V3/FlowsClient/create_flow.php + * + * @param CreateFlowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Flow + * + * @throws ApiException Thrown if the API call fails. + */ + public function createFlow(CreateFlowRequest $request, array $callOptions = []): Flow + { + return $this->startApiCall('CreateFlow', $request, $callOptions)->wait(); + } + + /** + * Deletes a specified flow. + * + * The async variant is {@see FlowsClient::deleteFlowAsync()} . + * + * @example samples/V3/FlowsClient/delete_flow.php + * + * @param DeleteFlowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function deleteFlow(DeleteFlowRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteFlow', $request, $callOptions)->wait(); + } + + /** + * Exports the specified flow to a binary file. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: + * [ExportFlowResponse][google.cloud.dialogflow.cx.v3.ExportFlowResponse] + * + * Note that resources (e.g. intents, entities, webhooks) that the flow + * references will also be exported. + * + * The async variant is {@see FlowsClient::exportFlowAsync()} . + * + * @example samples/V3/FlowsClient/export_flow.php + * + * @param ExportFlowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportFlow(ExportFlowRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportFlow', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified flow. + * + * The async variant is {@see FlowsClient::getFlowAsync()} . + * + * @example samples/V3/FlowsClient/get_flow.php + * + * @param GetFlowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Flow + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFlow(GetFlowRequest $request, array $callOptions = []): Flow + { + return $this->startApiCall('GetFlow', $request, $callOptions)->wait(); + } + + /** + * Gets the latest flow validation result. Flow validation is performed + * when ValidateFlow is called. + * + * The async variant is {@see FlowsClient::getFlowValidationResultAsync()} . + * + * @example samples/V3/FlowsClient/get_flow_validation_result.php + * + * @param GetFlowValidationResultRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 FlowValidationResult + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFlowValidationResult( + GetFlowValidationResultRequest $request, + array $callOptions = [] + ): FlowValidationResult { + return $this->startApiCall('GetFlowValidationResult', $request, $callOptions)->wait(); + } + + /** + * Imports the specified flow to the specified agent from a binary file. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: + * [ImportFlowResponse][google.cloud.dialogflow.cx.v3.ImportFlowResponse] + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see FlowsClient::importFlowAsync()} . + * + * @example samples/V3/FlowsClient/import_flow.php + * + * @param ImportFlowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importFlow(ImportFlowRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportFlow', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all flows in the specified agent. + * + * The async variant is {@see FlowsClient::listFlowsAsync()} . + * + * @example samples/V3/FlowsClient/list_flows.php + * + * @param ListFlowsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFlows(ListFlowsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListFlows', $request, $callOptions); + } + + /** + * Trains the specified flow. Note that only the flow in 'draft' environment + * is trained. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see FlowsClient::trainFlowAsync()} . + * + * @example samples/V3/FlowsClient/train_flow.php + * + * @param TrainFlowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function trainFlow(TrainFlowRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('TrainFlow', $request, $callOptions)->wait(); + } + + /** + * Updates the specified flow. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see FlowsClient::updateFlowAsync()} . + * + * @example samples/V3/FlowsClient/update_flow.php + * + * @param UpdateFlowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Flow + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateFlow(UpdateFlowRequest $request, array $callOptions = []): Flow + { + return $this->startApiCall('UpdateFlow', $request, $callOptions)->wait(); + } + + /** + * Validates the specified flow and creates or updates validation results. + * Please call this API after the training is completed to get the complete + * validation results. + * + * The async variant is {@see FlowsClient::validateFlowAsync()} . + * + * @example samples/V3/FlowsClient/validate_flow.php + * + * @param ValidateFlowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 FlowValidationResult + * + * @throws ApiException Thrown if the API call fails. + */ + public function validateFlow(ValidateFlowRequest $request, array $callOptions = []): FlowValidationResult + { + return $this->startApiCall('ValidateFlow', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see FlowsClient::getLocationAsync()} . + * + * @example samples/V3/FlowsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see FlowsClient::listLocationsAsync()} . + * + * @example samples/V3/FlowsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/GeneratorsClient.php b/DialogflowCx/src/V3/Client/GeneratorsClient.php new file mode 100644 index 000000000000..b4811d5e107c --- /dev/null +++ b/DialogflowCx/src/V3/Client/GeneratorsClient.php @@ -0,0 +1,430 @@ + 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', + ], + ], + ]; + } + + /** + * 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(string $project, string $location, string $agent): string + { + return self::getPathTemplate('agent')->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(string $project, string $location, string $agent, string $generator): string + { + return self::getPathTemplate('generator')->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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a generator in the specified agent. + * + * The async variant is {@see GeneratorsClient::createGeneratorAsync()} . + * + * @example samples/V3/GeneratorsClient/create_generator.php + * + * @param CreateGeneratorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Generator + * + * @throws ApiException Thrown if the API call fails. + */ + public function createGenerator(CreateGeneratorRequest $request, array $callOptions = []): Generator + { + return $this->startApiCall('CreateGenerator', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified generators. + * + * The async variant is {@see GeneratorsClient::deleteGeneratorAsync()} . + * + * @example samples/V3/GeneratorsClient/delete_generator.php + * + * @param DeleteGeneratorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function deleteGenerator(DeleteGeneratorRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteGenerator', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified generator. + * + * The async variant is {@see GeneratorsClient::getGeneratorAsync()} . + * + * @example samples/V3/GeneratorsClient/get_generator.php + * + * @param GetGeneratorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Generator + * + * @throws ApiException Thrown if the API call fails. + */ + public function getGenerator(GetGeneratorRequest $request, array $callOptions = []): Generator + { + return $this->startApiCall('GetGenerator', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all generators in the specified agent. + * + * The async variant is {@see GeneratorsClient::listGeneratorsAsync()} . + * + * @example samples/V3/GeneratorsClient/list_generators.php + * + * @param ListGeneratorsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listGenerators(ListGeneratorsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListGenerators', $request, $callOptions); + } + + /** + * Update the specified generator. + * + * The async variant is {@see GeneratorsClient::updateGeneratorAsync()} . + * + * @example samples/V3/GeneratorsClient/update_generator.php + * + * @param UpdateGeneratorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Generator + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateGenerator(UpdateGeneratorRequest $request, array $callOptions = []): Generator + { + return $this->startApiCall('UpdateGenerator', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see GeneratorsClient::getLocationAsync()} . + * + * @example samples/V3/GeneratorsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see GeneratorsClient::listLocationsAsync()} . + * + * @example samples/V3/GeneratorsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/IntentsClient.php b/DialogflowCx/src/V3/Client/IntentsClient.php new file mode 100644 index 000000000000..0363a64a9589 --- /dev/null +++ b/DialogflowCx/src/V3/Client/IntentsClient.php @@ -0,0 +1,579 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/intents_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/intents_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/intents_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/intents_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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(string $project, string $location, string $agent): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a entity_type + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $entityType + * + * @return string The formatted entity_type resource. + */ + public static function entityTypeName(string $project, string $location, string $agent, string $entityType): string + { + return self::getPathTemplate('entityType')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a intent + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $intent + * + * @return string The formatted intent resource. + */ + public static function intentName(string $project, string $location, string $agent, string $intent): string + { + return self::getPathTemplate('intent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'intent' => $intent, + ]); + } + + /** + * 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} + * - entityType: projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type} + * - intent: projects/{project}/locations/{location}/agents/{agent}/intents/{intent} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an intent in the specified agent. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see IntentsClient::createIntentAsync()} . + * + * @example samples/V3/IntentsClient/create_intent.php + * + * @param CreateIntentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Intent + * + * @throws ApiException Thrown if the API call fails. + */ + public function createIntent(CreateIntentRequest $request, array $callOptions = []): Intent + { + return $this->startApiCall('CreateIntent', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified intent. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see IntentsClient::deleteIntentAsync()} . + * + * @example samples/V3/IntentsClient/delete_intent.php + * + * @param DeleteIntentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function deleteIntent(DeleteIntentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteIntent', $request, $callOptions)->wait(); + } + + /** + * Exports the selected intents. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [ExportIntentsMetadata][google.cloud.dialogflow.cx.v3.ExportIntentsMetadata] + * - `response`: + * [ExportIntentsResponse][google.cloud.dialogflow.cx.v3.ExportIntentsResponse] + * + * The async variant is {@see IntentsClient::exportIntentsAsync()} . + * + * @example samples/V3/IntentsClient/export_intents.php + * + * @param ExportIntentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportIntents(ExportIntentsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportIntents', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified intent. + * + * The async variant is {@see IntentsClient::getIntentAsync()} . + * + * @example samples/V3/IntentsClient/get_intent.php + * + * @param GetIntentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Intent + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIntent(GetIntentRequest $request, array $callOptions = []): Intent + { + return $this->startApiCall('GetIntent', $request, $callOptions)->wait(); + } + + /** + * Imports the specified intents into the agent. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [ImportIntentsMetadata][google.cloud.dialogflow.cx.v3.ImportIntentsMetadata] + * - `response`: + * [ImportIntentsResponse][google.cloud.dialogflow.cx.v3.ImportIntentsResponse] + * + * The async variant is {@see IntentsClient::importIntentsAsync()} . + * + * @example samples/V3/IntentsClient/import_intents.php + * + * @param ImportIntentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importIntents(ImportIntentsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportIntents', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all intents in the specified agent. + * + * The async variant is {@see IntentsClient::listIntentsAsync()} . + * + * @example samples/V3/IntentsClient/list_intents.php + * + * @param ListIntentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listIntents(ListIntentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListIntents', $request, $callOptions); + } + + /** + * Updates the specified intent. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see IntentsClient::updateIntentAsync()} . + * + * @example samples/V3/IntentsClient/update_intent.php + * + * @param UpdateIntentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Intent + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateIntent(UpdateIntentRequest $request, array $callOptions = []): Intent + { + return $this->startApiCall('UpdateIntent', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see IntentsClient::getLocationAsync()} . + * + * @example samples/V3/IntentsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see IntentsClient::listLocationsAsync()} . + * + * @example samples/V3/IntentsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/PagesClient.php b/DialogflowCx/src/V3/Client/PagesClient.php new file mode 100644 index 000000000000..010c5a819fbe --- /dev/null +++ b/DialogflowCx/src/V3/Client/PagesClient.php @@ -0,0 +1,601 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/pages_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/pages_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/pages_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/pages_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a entity_type + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $entityType + * + * @return string The formatted entity_type resource. + */ + public static function entityTypeName(string $project, string $location, string $agent, string $entityType): string + { + return self::getPathTemplate('entityType')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a flow + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * + * @return string The formatted flow resource. + */ + public static function flowName(string $project, string $location, string $agent, string $flow): string + { + return self::getPathTemplate('flow')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a intent + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $intent + * + * @return string The formatted intent resource. + */ + public static function intentName(string $project, string $location, string $agent, string $intent): string + { + return self::getPathTemplate('intent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'intent' => $intent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a page + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $page + * + * @return string The formatted page resource. + */ + public static function pageName( + string $project, + string $location, + string $agent, + string $flow, + string $page + ): string { + return self::getPathTemplate('page')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'page' => $page, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_flow_transition_route_group resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $transitionRouteGroup + * + * @return string The formatted project_location_agent_flow_transition_route_group resource. + */ + public static function projectLocationAgentFlowTransitionRouteGroupName( + string $project, + string $location, + string $agent, + string $flow, + string $transitionRouteGroup + ): string { + return self::getPathTemplate('projectLocationAgentFlowTransitionRouteGroup')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'transition_route_group' => $transitionRouteGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_transition_route_group resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $transitionRouteGroup + * + * @return string The formatted project_location_agent_transition_route_group resource. + */ + public static function projectLocationAgentTransitionRouteGroupName( + string $project, + string $location, + string $agent, + string $transitionRouteGroup + ): string { + return self::getPathTemplate('projectLocationAgentTransitionRouteGroup')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'transition_route_group' => $transitionRouteGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * transition_route_group resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $transitionRouteGroup + * + * @return string The formatted transition_route_group resource. + */ + public static function transitionRouteGroupName( + string $project, + string $location, + string $agent, + string $flow, + string $transitionRouteGroup + ): string { + return self::getPathTemplate('transitionRouteGroup')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'transition_route_group' => $transitionRouteGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a webhook + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $webhook + * + * @return string The formatted webhook resource. + */ + public static function webhookName(string $project, string $location, string $agent, string $webhook): string + { + return self::getPathTemplate('webhook')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'webhook' => $webhook, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - entityType: projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type} + * - flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow} + * - intent: projects/{project}/locations/{location}/agents/{agent}/intents/{intent} + * - page: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page} + * - projectLocationAgentFlowTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} + * - projectLocationAgentTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group} + * - transitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} + * - webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a page in the specified flow. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see PagesClient::createPageAsync()} . + * + * @example samples/V3/PagesClient/create_page.php + * + * @param CreatePageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Page + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPage(CreatePageRequest $request, array $callOptions = []): Page + { + return $this->startApiCall('CreatePage', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified page. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see PagesClient::deletePageAsync()} . + * + * @example samples/V3/PagesClient/delete_page.php + * + * @param DeletePageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function deletePage(DeletePageRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeletePage', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified page. + * + * The async variant is {@see PagesClient::getPageAsync()} . + * + * @example samples/V3/PagesClient/get_page.php + * + * @param GetPageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Page + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPage(GetPageRequest $request, array $callOptions = []): Page + { + return $this->startApiCall('GetPage', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all pages in the specified flow. + * + * The async variant is {@see PagesClient::listPagesAsync()} . + * + * @example samples/V3/PagesClient/list_pages.php + * + * @param ListPagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPages(ListPagesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPages', $request, $callOptions); + } + + /** + * Updates the specified page. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is {@see PagesClient::updatePageAsync()} . + * + * @example samples/V3/PagesClient/update_page.php + * + * @param UpdatePageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Page + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePage(UpdatePageRequest $request, array $callOptions = []): Page + { + return $this->startApiCall('UpdatePage', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see PagesClient::getLocationAsync()} . + * + * @example samples/V3/PagesClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see PagesClient::listLocationsAsync()} . + * + * @example samples/V3/PagesClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/SecuritySettingsServiceClient.php b/DialogflowCx/src/V3/Client/SecuritySettingsServiceClient.php new file mode 100644 index 000000000000..bfb249c70ebf --- /dev/null +++ b/DialogflowCx/src/V3/Client/SecuritySettingsServiceClient.php @@ -0,0 +1,578 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/security_settings_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/security_settings_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/security_settings_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => + __DIR__ . '/../resources/security_settings_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * deidentify_template resource. + * + * @param string $organization + * @param string $location + * @param string $deidentifyTemplate + * + * @return string The formatted deidentify_template resource. + */ + public static function deidentifyTemplateName( + string $organization, + string $location, + string $deidentifyTemplate + ): string { + return self::getPathTemplate('deidentifyTemplate')->render([ + 'organization' => $organization, + 'location' => $location, + 'deidentify_template' => $deidentifyTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * inspect_template resource. + * + * @param string $organization + * @param string $location + * @param string $inspectTemplate + * + * @return string The formatted inspect_template resource. + */ + public static function inspectTemplateName(string $organization, string $location, string $inspectTemplate): string + { + return self::getPathTemplate('inspectTemplate')->render([ + 'organization' => $organization, + 'location' => $location, + 'inspect_template' => $inspectTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_deidentify_template resource. + * + * @param string $organization + * @param string $location + * @param string $deidentifyTemplate + * + * @return string The formatted organization_location_deidentify_template resource. + */ + public static function organizationLocationDeidentifyTemplateName( + string $organization, + string $location, + string $deidentifyTemplate + ): string { + return self::getPathTemplate('organizationLocationDeidentifyTemplate')->render([ + 'organization' => $organization, + 'location' => $location, + 'deidentify_template' => $deidentifyTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_inspect_template resource. + * + * @param string $organization + * @param string $location + * @param string $inspectTemplate + * + * @return string The formatted organization_location_inspect_template resource. + */ + public static function organizationLocationInspectTemplateName( + string $organization, + string $location, + string $inspectTemplate + ): string { + return self::getPathTemplate('organizationLocationInspectTemplate')->render([ + 'organization' => $organization, + 'location' => $location, + 'inspect_template' => $inspectTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_deidentify_template resource. + * + * @param string $project + * @param string $location + * @param string $deidentifyTemplate + * + * @return string The formatted project_location_deidentify_template resource. + */ + public static function projectLocationDeidentifyTemplateName( + string $project, + string $location, + string $deidentifyTemplate + ): string { + return self::getPathTemplate('projectLocationDeidentifyTemplate')->render([ + 'project' => $project, + 'location' => $location, + 'deidentify_template' => $deidentifyTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_inspect_template resource. + * + * @param string $project + * @param string $location + * @param string $inspectTemplate + * + * @return string The formatted project_location_inspect_template resource. + */ + public static function projectLocationInspectTemplateName( + string $project, + string $location, + string $inspectTemplate + ): string { + return self::getPathTemplate('projectLocationInspectTemplate')->render([ + 'project' => $project, + 'location' => $location, + 'inspect_template' => $inspectTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * security_settings resource. + * + * @param string $project + * @param string $location + * @param string $securitySettings + * + * @return string The formatted security_settings resource. + */ + public static function securitySettingsName(string $project, string $location, string $securitySettings): string + { + return self::getPathTemplate('securitySettings')->render([ + 'project' => $project, + 'location' => $location, + 'security_settings' => $securitySettings, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - deidentifyTemplate: organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template} + * - inspectTemplate: organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template} + * - location: projects/{project}/locations/{location} + * - organizationLocationDeidentifyTemplate: organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template} + * - organizationLocationInspectTemplate: organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template} + * - projectLocationDeidentifyTemplate: projects/{project}/locations/{location}/deidentifyTemplates/{deidentify_template} + * - projectLocationInspectTemplate: projects/{project}/locations/{location}/inspectTemplates/{inspect_template} + * - securitySettings: projects/{project}/locations/{location}/securitySettings/{security_settings} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Create security settings in the specified location. + * + * The async variant is + * {@see SecuritySettingsServiceClient::createSecuritySettingsAsync()} . + * + * @example samples/V3/SecuritySettingsServiceClient/create_security_settings.php + * + * @param CreateSecuritySettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 SecuritySettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSecuritySettings( + CreateSecuritySettingsRequest $request, + array $callOptions = [] + ): SecuritySettings { + return $this->startApiCall('CreateSecuritySettings', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified + * [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. + * + * The async variant is + * {@see SecuritySettingsServiceClient::deleteSecuritySettingsAsync()} . + * + * @example samples/V3/SecuritySettingsServiceClient/delete_security_settings.php + * + * @param DeleteSecuritySettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function deleteSecuritySettings(DeleteSecuritySettingsRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSecuritySettings', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified + * [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. The + * returned settings may be stale by up to 1 minute. + * + * The async variant is + * {@see SecuritySettingsServiceClient::getSecuritySettingsAsync()} . + * + * @example samples/V3/SecuritySettingsServiceClient/get_security_settings.php + * + * @param GetSecuritySettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 SecuritySettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSecuritySettings(GetSecuritySettingsRequest $request, array $callOptions = []): SecuritySettings + { + return $this->startApiCall('GetSecuritySettings', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all security settings in the specified location. + * + * The async variant is + * {@see SecuritySettingsServiceClient::listSecuritySettingsAsync()} . + * + * @example samples/V3/SecuritySettingsServiceClient/list_security_settings.php + * + * @param ListSecuritySettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSecuritySettings( + ListSecuritySettingsRequest $request, + array $callOptions = [] + ): PagedListResponse { + return $this->startApiCall('ListSecuritySettings', $request, $callOptions); + } + + /** + * Updates the specified + * [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. + * + * The async variant is + * {@see SecuritySettingsServiceClient::updateSecuritySettingsAsync()} . + * + * @example samples/V3/SecuritySettingsServiceClient/update_security_settings.php + * + * @param UpdateSecuritySettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 SecuritySettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSecuritySettings( + UpdateSecuritySettingsRequest $request, + array $callOptions = [] + ): SecuritySettings { + return $this->startApiCall('UpdateSecuritySettings', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see SecuritySettingsServiceClient::getLocationAsync()} . + * + * @example samples/V3/SecuritySettingsServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see SecuritySettingsServiceClient::listLocationsAsync()} + * . + * + * @example samples/V3/SecuritySettingsServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/SessionEntityTypesClient.php b/DialogflowCx/src/V3/Client/SessionEntityTypesClient.php new file mode 100644 index 000000000000..0b94fa6a15b3 --- /dev/null +++ b/DialogflowCx/src/V3/Client/SessionEntityTypesClient.php @@ -0,0 +1,569 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/session_entity_types_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/session_entity_types_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/session_entity_types_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/session_entity_types_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_environment_session resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $environment + * @param string $session + * + * @return string The formatted project_location_agent_environment_session resource. + */ + public static function projectLocationAgentEnvironmentSessionName( + string $project, + string $location, + string $agent, + string $environment, + string $session + ): string { + return self::getPathTemplate('projectLocationAgentEnvironmentSession')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'environment' => $environment, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_environment_session_entity_type resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $environment + * @param string $session + * @param string $entityType + * + * @return string The formatted project_location_agent_environment_session_entity_type resource. + */ + public static function projectLocationAgentEnvironmentSessionEntityTypeName( + string $project, + string $location, + string $agent, + string $environment, + string $session, + string $entityType + ): string { + return self::getPathTemplate('projectLocationAgentEnvironmentSessionEntityType')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'environment' => $environment, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_session resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $session + * + * @return string The formatted project_location_agent_session resource. + */ + public static function projectLocationAgentSessionName( + string $project, + string $location, + string $agent, + string $session + ): string { + return self::getPathTemplate('projectLocationAgentSession')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_session_entity_type resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $session + * @param string $entityType + * + * @return string The formatted project_location_agent_session_entity_type resource. + */ + public static function projectLocationAgentSessionEntityTypeName( + string $project, + string $location, + string $agent, + string $session, + string $entityType + ): string { + return self::getPathTemplate('projectLocationAgentSessionEntityType')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a session + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $session + * + * @return string The formatted session resource. + */ + public static function sessionName(string $project, string $location, string $agent, string $session): string + { + return self::getPathTemplate('session')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * session_entity_type resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $session + * @param string $entityType + * + * @return string The formatted session_entity_type resource. + */ + public static function sessionEntityTypeName( + string $project, + string $location, + string $agent, + string $session, + string $entityType + ): string { + return self::getPathTemplate('sessionEntityType')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - projectLocationAgentEnvironmentSession: projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/sessions/{session} + * - 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} + * - session: projects/{project}/locations/{location}/agents/{agent}/sessions/{session} + * - sessionEntityType: projects/{project}/locations/{location}/agents/{agent}/sessions/{session}/entityTypes/{entity_type} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a session entity type. + * + * The async variant is + * {@see SessionEntityTypesClient::createSessionEntityTypeAsync()} . + * + * @example samples/V3/SessionEntityTypesClient/create_session_entity_type.php + * + * @param CreateSessionEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 SessionEntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSessionEntityType( + CreateSessionEntityTypeRequest $request, + array $callOptions = [] + ): SessionEntityType { + return $this->startApiCall('CreateSessionEntityType', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified session entity type. + * + * The async variant is + * {@see SessionEntityTypesClient::deleteSessionEntityTypeAsync()} . + * + * @example samples/V3/SessionEntityTypesClient/delete_session_entity_type.php + * + * @param DeleteSessionEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function deleteSessionEntityType(DeleteSessionEntityTypeRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSessionEntityType', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified session entity type. + * + * The async variant is + * {@see SessionEntityTypesClient::getSessionEntityTypeAsync()} . + * + * @example samples/V3/SessionEntityTypesClient/get_session_entity_type.php + * + * @param GetSessionEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 SessionEntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSessionEntityType( + GetSessionEntityTypeRequest $request, + array $callOptions = [] + ): SessionEntityType { + return $this->startApiCall('GetSessionEntityType', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all session entity types in the specified session. + * + * The async variant is + * {@see SessionEntityTypesClient::listSessionEntityTypesAsync()} . + * + * @example samples/V3/SessionEntityTypesClient/list_session_entity_types.php + * + * @param ListSessionEntityTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSessionEntityTypes( + ListSessionEntityTypesRequest $request, + array $callOptions = [] + ): PagedListResponse { + return $this->startApiCall('ListSessionEntityTypes', $request, $callOptions); + } + + /** + * Updates the specified session entity type. + * + * The async variant is + * {@see SessionEntityTypesClient::updateSessionEntityTypeAsync()} . + * + * @example samples/V3/SessionEntityTypesClient/update_session_entity_type.php + * + * @param UpdateSessionEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 SessionEntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSessionEntityType( + UpdateSessionEntityTypeRequest $request, + array $callOptions = [] + ): SessionEntityType { + return $this->startApiCall('UpdateSessionEntityType', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see SessionEntityTypesClient::getLocationAsync()} . + * + * @example samples/V3/SessionEntityTypesClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see SessionEntityTypesClient::listLocationsAsync()} . + * + * @example samples/V3/SessionEntityTypesClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/SessionsClient.php b/DialogflowCx/src/V3/Client/SessionsClient.php new file mode 100644 index 000000000000..72d31f1aac41 --- /dev/null +++ b/DialogflowCx/src/V3/Client/SessionsClient.php @@ -0,0 +1,766 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sessions_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sessions_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sessions_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sessions_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $project, string $location, string $agent): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $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(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('dataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a entity_type + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $entityType + * + * @return string The formatted entity_type resource. + */ + public static function entityTypeName(string $project, string $location, string $agent, string $entityType): string + { + return self::getPathTemplate('entityType')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a intent + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $intent + * + * @return string The formatted intent resource. + */ + public static function intentName(string $project, string $location, string $agent, string $intent): string + { + return self::getPathTemplate('intent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'intent' => $intent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a page + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $page + * + * @return string The formatted page resource. + */ + public static function pageName( + string $project, + string $location, + string $agent, + string $flow, + string $page + ): string { + return self::getPathTemplate('page')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'page' => $page, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_environment_session resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $environment + * @param string $session + * + * @return string The formatted project_location_agent_environment_session resource. + */ + public static function projectLocationAgentEnvironmentSessionName( + string $project, + string $location, + string $agent, + string $environment, + string $session + ): string { + return self::getPathTemplate('projectLocationAgentEnvironmentSession')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'environment' => $environment, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_environment_session_entity_type resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $environment + * @param string $session + * @param string $entityType + * + * @return string The formatted project_location_agent_environment_session_entity_type resource. + */ + public static function projectLocationAgentEnvironmentSessionEntityTypeName( + string $project, + string $location, + string $agent, + string $environment, + string $session, + string $entityType + ): string { + return self::getPathTemplate('projectLocationAgentEnvironmentSessionEntityType')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'environment' => $environment, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_session resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $session + * + * @return string The formatted project_location_agent_session resource. + */ + public static function projectLocationAgentSessionName( + string $project, + string $location, + string $agent, + string $session + ): string { + return self::getPathTemplate('projectLocationAgentSession')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_session_entity_type resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $session + * @param string $entityType + * + * @return string The formatted project_location_agent_session_entity_type resource. + */ + public static function projectLocationAgentSessionEntityTypeName( + string $project, + string $location, + string $agent, + string $session, + string $entityType + ): string { + return self::getPathTemplate('projectLocationAgentSessionEntityType')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * 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( + string $project, + string $location, + string $collection, + string $dataStore + ): string { + return self::getPathTemplate('projectLocationCollectionDataStore')->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(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('projectLocationDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a session + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $session + * + * @return string The formatted session resource. + */ + public static function sessionName(string $project, string $location, string $agent, string $session): string + { + return self::getPathTemplate('session')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * session_entity_type resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $session + * @param string $entityType + * + * @return string The formatted session_entity_type resource. + */ + public static function sessionEntityTypeName( + string $project, + string $location, + string $agent, + string $session, + string $entityType + ): string { + return self::getPathTemplate('sessionEntityType')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a version + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $version + * + * @return string The formatted version resource. + */ + public static function versionName( + string $project, + string $location, + string $agent, + string $flow, + string $version + ): string { + return self::getPathTemplate('version')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'version' => $version, + ]); + } + + /** + * 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} + * - 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} + * - projectLocationAgentEnvironmentSession: projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/sessions/{session} + * - 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} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Processes a natural language query and returns structured, actionable data + * as a result. This method is not idempotent, because it may cause session + * entity types to be updated, which in turn might affect results of future + * queries. + * + * Note: Always use agent versions for production traffic. + * See [Versions and + * environments](https://cloud.google.com/dialogflow/cx/docs/concept/version). + * + * The async variant is {@see SessionsClient::detectIntentAsync()} . + * + * @example samples/V3/SessionsClient/detect_intent.php + * + * @param DetectIntentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 DetectIntentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function detectIntent(DetectIntentRequest $request, array $callOptions = []): DetectIntentResponse + { + return $this->startApiCall('DetectIntent', $request, $callOptions)->wait(); + } + + /** + * Fulfills a matched intent returned by + * [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent]. Must be + * called after + * [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent], with + * input from + * [MatchIntentResponse][google.cloud.dialogflow.cx.v3.MatchIntentResponse]. + * Otherwise, the behavior is undefined. + * + * The async variant is {@see SessionsClient::fulfillIntentAsync()} . + * + * @example samples/V3/SessionsClient/fulfill_intent.php + * + * @param FulfillIntentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 FulfillIntentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function fulfillIntent(FulfillIntentRequest $request, array $callOptions = []): FulfillIntentResponse + { + return $this->startApiCall('FulfillIntent', $request, $callOptions)->wait(); + } + + /** + * Returns preliminary intent match results, doesn't change the session + * status. + * + * The async variant is {@see SessionsClient::matchIntentAsync()} . + * + * @example samples/V3/SessionsClient/match_intent.php + * + * @param MatchIntentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 MatchIntentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function matchIntent(MatchIntentRequest $request, array $callOptions = []): MatchIntentResponse + { + return $this->startApiCall('MatchIntent', $request, $callOptions)->wait(); + } + + /** + * Processes a natural language query in audio format in a streaming fashion + * and returns structured, actionable data as a result. This method is only + * available via the gRPC API (not REST). + * + * Note: Always use agent versions for production traffic. + * See [Versions and + * environments](https://cloud.google.com/dialogflow/cx/docs/concept/version). + * + * @example samples/V3/SessionsClient/streaming_detect_intent.php + * + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return BidiStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function streamingDetectIntent(array $callOptions = []): BidiStream + { + return $this->startApiCall('StreamingDetectIntent', null, $callOptions); + } + + /** + * Updates the feedback received from the user for a single turn of the bot + * response. + * + * The async variant is {@see SessionsClient::submitAnswerFeedbackAsync()} . + * + * @example samples/V3/SessionsClient/submit_answer_feedback.php + * + * @param SubmitAnswerFeedbackRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 AnswerFeedback + * + * @throws ApiException Thrown if the API call fails. + */ + public function submitAnswerFeedback(SubmitAnswerFeedbackRequest $request, array $callOptions = []): AnswerFeedback + { + return $this->startApiCall('SubmitAnswerFeedback', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see SessionsClient::getLocationAsync()} . + * + * @example samples/V3/SessionsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see SessionsClient::listLocationsAsync()} . + * + * @example samples/V3/SessionsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/TestCasesClient.php b/DialogflowCx/src/V3/Client/TestCasesClient.php new file mode 100644 index 000000000000..aced424625d3 --- /dev/null +++ b/DialogflowCx/src/V3/Client/TestCasesClient.php @@ -0,0 +1,972 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/test_cases_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/test_cases_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/test_cases_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/test_cases_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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(string $project, string $location, string $agent): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a entity_type + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $entityType + * + * @return string The formatted entity_type resource. + */ + public static function entityTypeName(string $project, string $location, string $agent, string $entityType): string + { + return self::getPathTemplate('entityType')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a environment + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $environment + * + * @return string The formatted environment resource. + */ + public static function environmentName( + string $project, + string $location, + string $agent, + string $environment + ): string { + return self::getPathTemplate('environment')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'environment' => $environment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a flow + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * + * @return string The formatted flow resource. + */ + public static function flowName(string $project, string $location, string $agent, string $flow): string + { + return self::getPathTemplate('flow')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a intent + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $intent + * + * @return string The formatted intent resource. + */ + public static function intentName(string $project, string $location, string $agent, string $intent): string + { + return self::getPathTemplate('intent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'intent' => $intent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a page + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $page + * + * @return string The formatted page resource. + */ + public static function pageName( + string $project, + string $location, + string $agent, + string $flow, + string $page + ): string { + return self::getPathTemplate('page')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'page' => $page, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_flow_transition_route_group resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $transitionRouteGroup + * + * @return string The formatted project_location_agent_flow_transition_route_group resource. + */ + public static function projectLocationAgentFlowTransitionRouteGroupName( + string $project, + string $location, + string $agent, + string $flow, + string $transitionRouteGroup + ): string { + return self::getPathTemplate('projectLocationAgentFlowTransitionRouteGroup')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'transition_route_group' => $transitionRouteGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_transition_route_group resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $transitionRouteGroup + * + * @return string The formatted project_location_agent_transition_route_group resource. + */ + public static function projectLocationAgentTransitionRouteGroupName( + string $project, + string $location, + string $agent, + string $transitionRouteGroup + ): string { + return self::getPathTemplate('projectLocationAgentTransitionRouteGroup')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'transition_route_group' => $transitionRouteGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a test_case + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $testCase + * + * @return string The formatted test_case resource. + */ + public static function testCaseName(string $project, string $location, string $agent, string $testCase): string + { + return self::getPathTemplate('testCase')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'test_case' => $testCase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * test_case_result resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $testCase + * @param string $result + * + * @return string The formatted test_case_result resource. + */ + public static function testCaseResultName( + string $project, + string $location, + string $agent, + string $testCase, + string $result + ): string { + return self::getPathTemplate('testCaseResult')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'test_case' => $testCase, + 'result' => $result, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * transition_route_group resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $transitionRouteGroup + * + * @return string The formatted transition_route_group resource. + */ + public static function transitionRouteGroupName( + string $project, + string $location, + string $agent, + string $flow, + string $transitionRouteGroup + ): string { + return self::getPathTemplate('transitionRouteGroup')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'transition_route_group' => $transitionRouteGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a webhook + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $webhook + * + * @return string The formatted webhook resource. + */ + public static function webhookName(string $project, string $location, string $agent, string $webhook): string + { + return self::getPathTemplate('webhook')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'webhook' => $webhook, + ]); + } + + /** + * 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} + * - entityType: projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type} + * - environment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment} + * - flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow} + * - intent: projects/{project}/locations/{location}/agents/{agent}/intents/{intent} + * - page: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page} + * - projectLocationAgentFlowTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} + * - projectLocationAgentTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group} + * - testCase: projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case} + * - testCaseResult: projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}/results/{result} + * - transitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} + * - webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Batch deletes test cases. + * + * The async variant is {@see TestCasesClient::batchDeleteTestCasesAsync()} . + * + * @example samples/V3/TestCasesClient/batch_delete_test_cases.php + * + * @param BatchDeleteTestCasesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function batchDeleteTestCases(BatchDeleteTestCasesRequest $request, array $callOptions = []): void + { + $this->startApiCall('BatchDeleteTestCases', $request, $callOptions)->wait(); + } + + /** + * Kicks off a batch run of test cases. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [BatchRunTestCasesMetadata][google.cloud.dialogflow.cx.v3.BatchRunTestCasesMetadata] + * - `response`: + * [BatchRunTestCasesResponse][google.cloud.dialogflow.cx.v3.BatchRunTestCasesResponse] + * + * The async variant is {@see TestCasesClient::batchRunTestCasesAsync()} . + * + * @example samples/V3/TestCasesClient/batch_run_test_cases.php + * + * @param BatchRunTestCasesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchRunTestCases(BatchRunTestCasesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchRunTestCases', $request, $callOptions)->wait(); + } + + /** + * Calculates the test coverage for an agent. + * + * The async variant is {@see TestCasesClient::calculateCoverageAsync()} . + * + * @example samples/V3/TestCasesClient/calculate_coverage.php + * + * @param CalculateCoverageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 CalculateCoverageResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function calculateCoverage( + CalculateCoverageRequest $request, + array $callOptions = [] + ): CalculateCoverageResponse { + return $this->startApiCall('CalculateCoverage', $request, $callOptions)->wait(); + } + + /** + * Creates a test case for the given agent. + * + * The async variant is {@see TestCasesClient::createTestCaseAsync()} . + * + * @example samples/V3/TestCasesClient/create_test_case.php + * + * @param CreateTestCaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 TestCase + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTestCase(CreateTestCaseRequest $request, array $callOptions = []): TestCase + { + return $this->startApiCall('CreateTestCase', $request, $callOptions)->wait(); + } + + /** + * Exports the test cases under the agent to a Cloud Storage bucket or a local + * file. Filter can be applied to export a subset of test cases. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [ExportTestCasesMetadata][google.cloud.dialogflow.cx.v3.ExportTestCasesMetadata] + * - `response`: + * [ExportTestCasesResponse][google.cloud.dialogflow.cx.v3.ExportTestCasesResponse] + * + * The async variant is {@see TestCasesClient::exportTestCasesAsync()} . + * + * @example samples/V3/TestCasesClient/export_test_cases.php + * + * @param ExportTestCasesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportTestCases(ExportTestCasesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportTestCases', $request, $callOptions)->wait(); + } + + /** + * Gets a test case. + * + * The async variant is {@see TestCasesClient::getTestCaseAsync()} . + * + * @example samples/V3/TestCasesClient/get_test_case.php + * + * @param GetTestCaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 TestCase + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTestCase(GetTestCaseRequest $request, array $callOptions = []): TestCase + { + return $this->startApiCall('GetTestCase', $request, $callOptions)->wait(); + } + + /** + * Gets a test case result. + * + * The async variant is {@see TestCasesClient::getTestCaseResultAsync()} . + * + * @example samples/V3/TestCasesClient/get_test_case_result.php + * + * @param GetTestCaseResultRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 TestCaseResult + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTestCaseResult(GetTestCaseResultRequest $request, array $callOptions = []): TestCaseResult + { + return $this->startApiCall('GetTestCaseResult', $request, $callOptions)->wait(); + } + + /** + * Imports the test cases from a Cloud Storage bucket or a local file. It + * always creates new test cases and won't overwrite any existing ones. The + * provided ID in the imported test case is neglected. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [ImportTestCasesMetadata][google.cloud.dialogflow.cx.v3.ImportTestCasesMetadata] + * - `response`: + * [ImportTestCasesResponse][google.cloud.dialogflow.cx.v3.ImportTestCasesResponse] + * + * The async variant is {@see TestCasesClient::importTestCasesAsync()} . + * + * @example samples/V3/TestCasesClient/import_test_cases.php + * + * @param ImportTestCasesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importTestCases(ImportTestCasesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportTestCases', $request, $callOptions)->wait(); + } + + /** + * Fetches the list of run results for the given test case. A maximum of 100 + * results are kept for each test case. + * + * The async variant is {@see TestCasesClient::listTestCaseResultsAsync()} . + * + * @example samples/V3/TestCasesClient/list_test_case_results.php + * + * @param ListTestCaseResultsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTestCaseResults(ListTestCaseResultsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTestCaseResults', $request, $callOptions); + } + + /** + * Fetches a list of test cases for a given agent. + * + * The async variant is {@see TestCasesClient::listTestCasesAsync()} . + * + * @example samples/V3/TestCasesClient/list_test_cases.php + * + * @param ListTestCasesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTestCases(ListTestCasesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTestCases', $request, $callOptions); + } + + /** + * Kicks off a test case run. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [RunTestCaseMetadata][google.cloud.dialogflow.cx.v3.RunTestCaseMetadata] + * - `response`: + * [RunTestCaseResponse][google.cloud.dialogflow.cx.v3.RunTestCaseResponse] + * + * The async variant is {@see TestCasesClient::runTestCaseAsync()} . + * + * @example samples/V3/TestCasesClient/run_test_case.php + * + * @param RunTestCaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function runTestCase(RunTestCaseRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RunTestCase', $request, $callOptions)->wait(); + } + + /** + * Updates the specified test case. + * + * The async variant is {@see TestCasesClient::updateTestCaseAsync()} . + * + * @example samples/V3/TestCasesClient/update_test_case.php + * + * @param UpdateTestCaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 TestCase + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTestCase(UpdateTestCaseRequest $request, array $callOptions = []): TestCase + { + return $this->startApiCall('UpdateTestCase', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see TestCasesClient::getLocationAsync()} . + * + * @example samples/V3/TestCasesClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see TestCasesClient::listLocationsAsync()} . + * + * @example samples/V3/TestCasesClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/TransitionRouteGroupsClient.php b/DialogflowCx/src/V3/Client/TransitionRouteGroupsClient.php new file mode 100644 index 000000000000..5d467d41cfd3 --- /dev/null +++ b/DialogflowCx/src/V3/Client/TransitionRouteGroupsClient.php @@ -0,0 +1,620 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/transition_route_groups_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/transition_route_groups_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/transition_route_groups_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/transition_route_groups_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $project, string $location, string $agent): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a flow + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * + * @return string The formatted flow resource. + */ + public static function flowName(string $project, string $location, string $agent, string $flow): string + { + return self::getPathTemplate('flow')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a intent + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $intent + * + * @return string The formatted intent resource. + */ + public static function intentName(string $project, string $location, string $agent, string $intent): string + { + return self::getPathTemplate('intent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'intent' => $intent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a page + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $page + * + * @return string The formatted page resource. + */ + public static function pageName( + string $project, + string $location, + string $agent, + string $flow, + string $page + ): string { + return self::getPathTemplate('page')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'page' => $page, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_flow_transition_route_group resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $transitionRouteGroup + * + * @return string The formatted project_location_agent_flow_transition_route_group resource. + */ + public static function projectLocationAgentFlowTransitionRouteGroupName( + string $project, + string $location, + string $agent, + string $flow, + string $transitionRouteGroup + ): string { + return self::getPathTemplate('projectLocationAgentFlowTransitionRouteGroup')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'transition_route_group' => $transitionRouteGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent_transition_route_group resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $transitionRouteGroup + * + * @return string The formatted project_location_agent_transition_route_group resource. + */ + public static function projectLocationAgentTransitionRouteGroupName( + string $project, + string $location, + string $agent, + string $transitionRouteGroup + ): string { + return self::getPathTemplate('projectLocationAgentTransitionRouteGroup')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'transition_route_group' => $transitionRouteGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * transition_route_group resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $transitionRouteGroup + * + * @return string The formatted transition_route_group resource. + */ + public static function transitionRouteGroupName( + string $project, + string $location, + string $agent, + string $flow, + string $transitionRouteGroup + ): string { + return self::getPathTemplate('transitionRouteGroup')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'transition_route_group' => $transitionRouteGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a webhook + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $webhook + * + * @return string The formatted webhook resource. + */ + public static function webhookName(string $project, string $location, string $agent, string $webhook): string + { + return self::getPathTemplate('webhook')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'webhook' => $webhook, + ]); + } + + /** + * 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} + * - flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow} + * - intent: projects/{project}/locations/{location}/agents/{agent}/intents/{intent} + * - page: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page} + * - projectLocationAgentFlowTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} + * - projectLocationAgentTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group} + * - transitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} + * - webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an + * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] + * in the specified flow. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is + * {@see TransitionRouteGroupsClient::createTransitionRouteGroupAsync()} . + * + * @example samples/V3/TransitionRouteGroupsClient/create_transition_route_group.php + * + * @param CreateTransitionRouteGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 TransitionRouteGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTransitionRouteGroup( + CreateTransitionRouteGroupRequest $request, + array $callOptions = [] + ): TransitionRouteGroup { + return $this->startApiCall('CreateTransitionRouteGroup', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified + * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is + * {@see TransitionRouteGroupsClient::deleteTransitionRouteGroupAsync()} . + * + * @example samples/V3/TransitionRouteGroupsClient/delete_transition_route_group.php + * + * @param DeleteTransitionRouteGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function deleteTransitionRouteGroup( + DeleteTransitionRouteGroupRequest $request, + array $callOptions = [] + ): void { + $this->startApiCall('DeleteTransitionRouteGroup', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified + * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. + * + * The async variant is + * {@see TransitionRouteGroupsClient::getTransitionRouteGroupAsync()} . + * + * @example samples/V3/TransitionRouteGroupsClient/get_transition_route_group.php + * + * @param GetTransitionRouteGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 TransitionRouteGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTransitionRouteGroup( + GetTransitionRouteGroupRequest $request, + array $callOptions = [] + ): TransitionRouteGroup { + return $this->startApiCall('GetTransitionRouteGroup', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all transition route groups in the specified flow. + * + * The async variant is + * {@see TransitionRouteGroupsClient::listTransitionRouteGroupsAsync()} . + * + * @example samples/V3/TransitionRouteGroupsClient/list_transition_route_groups.php + * + * @param ListTransitionRouteGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTransitionRouteGroups( + ListTransitionRouteGroupsRequest $request, + array $callOptions = [] + ): PagedListResponse { + return $this->startApiCall('ListTransitionRouteGroups', $request, $callOptions); + } + + /** + * Updates the specified + * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. + * + * Note: You should always train a flow prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). + * + * The async variant is + * {@see TransitionRouteGroupsClient::updateTransitionRouteGroupAsync()} . + * + * @example samples/V3/TransitionRouteGroupsClient/update_transition_route_group.php + * + * @param UpdateTransitionRouteGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 TransitionRouteGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTransitionRouteGroup( + UpdateTransitionRouteGroupRequest $request, + array $callOptions = [] + ): TransitionRouteGroup { + return $this->startApiCall('UpdateTransitionRouteGroup', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see TransitionRouteGroupsClient::getLocationAsync()} . + * + * @example samples/V3/TransitionRouteGroupsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see TransitionRouteGroupsClient::listLocationsAsync()} . + * + * @example samples/V3/TransitionRouteGroupsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/VersionsClient.php b/DialogflowCx/src/V3/Client/VersionsClient.php new file mode 100644 index 000000000000..d87262632fd0 --- /dev/null +++ b/DialogflowCx/src/V3/Client/VersionsClient.php @@ -0,0 +1,554 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/versions_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/versions_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/versions_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/versions_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) + ? $this->descriptors[$methodName]['longRunning'] + : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a flow + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * + * @return string The formatted flow resource. + */ + public static function flowName(string $project, string $location, string $agent, string $flow): string + { + return self::getPathTemplate('flow')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a version + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $flow + * @param string $version + * + * @return string The formatted version resource. + */ + public static function versionName( + string $project, + string $location, + string $agent, + string $flow, + string $version + ): string { + return self::getPathTemplate('version')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'flow' => $flow, + 'version' => $version, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow} + * - version: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Compares the specified base version with target version. + * + * The async variant is {@see VersionsClient::compareVersionsAsync()} . + * + * @example samples/V3/VersionsClient/compare_versions.php + * + * @param CompareVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 CompareVersionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function compareVersions(CompareVersionsRequest $request, array $callOptions = []): CompareVersionsResponse + { + return $this->startApiCall('CompareVersions', $request, $callOptions)->wait(); + } + + /** + * Creates a [Version][google.cloud.dialogflow.cx.v3.Version] in the specified + * [Flow][google.cloud.dialogflow.cx.v3.Flow]. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [CreateVersionOperationMetadata][google.cloud.dialogflow.cx.v3.CreateVersionOperationMetadata] + * - `response`: [Version][google.cloud.dialogflow.cx.v3.Version] + * + * The async variant is {@see VersionsClient::createVersionAsync()} . + * + * @example samples/V3/VersionsClient/create_version.php + * + * @param CreateVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createVersion(CreateVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateVersion', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified [Version][google.cloud.dialogflow.cx.v3.Version]. + * + * The async variant is {@see VersionsClient::deleteVersionAsync()} . + * + * @example samples/V3/VersionsClient/delete_version.php + * + * @param DeleteVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function deleteVersion(DeleteVersionRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteVersion', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified [Version][google.cloud.dialogflow.cx.v3.Version]. + * + * The async variant is {@see VersionsClient::getVersionAsync()} . + * + * @example samples/V3/VersionsClient/get_version.php + * + * @param GetVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Version + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVersion(GetVersionRequest $request, array $callOptions = []): Version + { + return $this->startApiCall('GetVersion', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all versions in the specified + * [Flow][google.cloud.dialogflow.cx.v3.Flow]. + * + * The async variant is {@see VersionsClient::listVersionsAsync()} . + * + * @example samples/V3/VersionsClient/list_versions.php + * + * @param ListVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVersions(ListVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListVersions', $request, $callOptions); + } + + /** + * Loads resources in the specified version to the draft flow. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * The async variant is {@see VersionsClient::loadVersionAsync()} . + * + * @example samples/V3/VersionsClient/load_version.php + * + * @param LoadVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function loadVersion(LoadVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('LoadVersion', $request, $callOptions)->wait(); + } + + /** + * Updates the specified [Version][google.cloud.dialogflow.cx.v3.Version]. + * + * The async variant is {@see VersionsClient::updateVersionAsync()} . + * + * @example samples/V3/VersionsClient/update_version.php + * + * @param UpdateVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Version + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateVersion(UpdateVersionRequest $request, array $callOptions = []): Version + { + return $this->startApiCall('UpdateVersion', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see VersionsClient::getLocationAsync()} . + * + * @example samples/V3/VersionsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see VersionsClient::listLocationsAsync()} . + * + * @example samples/V3/VersionsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/Client/WebhooksClient.php b/DialogflowCx/src/V3/Client/WebhooksClient.php new file mode 100644 index 000000000000..ef05bd419f50 --- /dev/null +++ b/DialogflowCx/src/V3/Client/WebhooksClient.php @@ -0,0 +1,452 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/webhooks_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/webhooks_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/webhooks_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/webhooks_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $project, string $location, string $agent): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $namespace + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $namespace, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'namespace' => $namespace, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a webhook + * resource. + * + * @param string $project + * @param string $location + * @param string $agent + * @param string $webhook + * + * @return string The formatted webhook resource. + */ + public static function webhookName(string $project, string $location, string $agent, string $webhook): string + { + return self::getPathTemplate('webhook')->render([ + 'project' => $project, + 'location' => $location, + 'agent' => $agent, + 'webhook' => $webhook, + ]); + } + + /** + * 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} + * - service: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service} + * - webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a webhook in the specified agent. + * + * The async variant is {@see WebhooksClient::createWebhookAsync()} . + * + * @example samples/V3/WebhooksClient/create_webhook.php + * + * @param CreateWebhookRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Webhook + * + * @throws ApiException Thrown if the API call fails. + */ + public function createWebhook(CreateWebhookRequest $request, array $callOptions = []): Webhook + { + return $this->startApiCall('CreateWebhook', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified webhook. + * + * The async variant is {@see WebhooksClient::deleteWebhookAsync()} . + * + * @example samples/V3/WebhooksClient/delete_webhook.php + * + * @param DeleteWebhookRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Thrown if the API call fails. + */ + public function deleteWebhook(DeleteWebhookRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteWebhook', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified webhook. + * + * The async variant is {@see WebhooksClient::getWebhookAsync()} . + * + * @example samples/V3/WebhooksClient/get_webhook.php + * + * @param GetWebhookRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Webhook + * + * @throws ApiException Thrown if the API call fails. + */ + public function getWebhook(GetWebhookRequest $request, array $callOptions = []): Webhook + { + return $this->startApiCall('GetWebhook', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all webhooks in the specified agent. + * + * The async variant is {@see WebhooksClient::listWebhooksAsync()} . + * + * @example samples/V3/WebhooksClient/list_webhooks.php + * + * @param ListWebhooksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listWebhooks(ListWebhooksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListWebhooks', $request, $callOptions); + } + + /** + * Updates the specified webhook. + * + * The async variant is {@see WebhooksClient::updateWebhookAsync()} . + * + * @example samples/V3/WebhooksClient/update_webhook.php + * + * @param UpdateWebhookRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Webhook + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateWebhook(UpdateWebhookRequest $request, array $callOptions = []): Webhook + { + return $this->startApiCall('UpdateWebhook', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see WebhooksClient::getLocationAsync()} . + * + * @example samples/V3/WebhooksClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see WebhooksClient::listLocationsAsync()} . + * + * @example samples/V3/WebhooksClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } +} diff --git a/DialogflowCx/src/V3/CompareVersionsRequest.php b/DialogflowCx/src/V3/CompareVersionsRequest.php index ff7103a9c48c..c645cb60f55b 100644 --- a/DialogflowCx/src/V3/CompareVersionsRequest.php +++ b/DialogflowCx/src/V3/CompareVersionsRequest.php @@ -46,6 +46,24 @@ class CompareVersionsRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $baseVersion Required. Name of the base flow version to compare with the target version. + * Use version ID `0` to indicate the draft version of the specified flow. + * + * Format: `projects//locations//agents/ + * /flows//versions/`. Please see + * {@see VersionsClient::versionName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CompareVersionsRequest + * + * @experimental + */ + public static function build(string $baseVersion): self + { + return (new self()) + ->setBaseVersion($baseVersion); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreateAgentRequest.php b/DialogflowCx/src/V3/CreateAgentRequest.php index a1c16ee0edb7..7be5e9586186 100644 --- a/DialogflowCx/src/V3/CreateAgentRequest.php +++ b/DialogflowCx/src/V3/CreateAgentRequest.php @@ -30,6 +30,23 @@ class CreateAgentRequest extends \Google\Protobuf\Internal\Message */ protected $agent = null; + /** + * @param string $parent Required. The location to create a agent for. + * Format: `projects//locations/`. Please see + * {@see AgentsClient::locationName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\Agent $agent Required. The agent to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreateAgentRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\Agent $agent): self + { + return (new self()) + ->setParent($parent) + ->setAgent($agent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreateEntityTypeRequest.php b/DialogflowCx/src/V3/CreateEntityTypeRequest.php index 5a4351fad6db..1b76d3915df2 100644 --- a/DialogflowCx/src/V3/CreateEntityTypeRequest.php +++ b/DialogflowCx/src/V3/CreateEntityTypeRequest.php @@ -44,6 +44,23 @@ class CreateEntityTypeRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $parent Required. The agent to create a entity type for. + * Format: `projects//locations//agents/`. Please see + * {@see EntityTypesClient::agentName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\EntityType $entityType Required. The entity type to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreateEntityTypeRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\EntityType $entityType): self + { + return (new self()) + ->setParent($parent) + ->setEntityType($entityType); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreateEnvironmentRequest.php b/DialogflowCx/src/V3/CreateEnvironmentRequest.php index 61930b27a0f0..6c56a2331c9f 100644 --- a/DialogflowCx/src/V3/CreateEnvironmentRequest.php +++ b/DialogflowCx/src/V3/CreateEnvironmentRequest.php @@ -31,6 +31,24 @@ class CreateEnvironmentRequest extends \Google\Protobuf\Internal\Message */ protected $environment = null; + /** + * @param string $parent Required. The [Agent][google.cloud.dialogflow.cx.v3.Agent] to create an + * [Environment][google.cloud.dialogflow.cx.v3.Environment] for. Format: + * `projects//locations//agents/`. Please see + * {@see EnvironmentsClient::agentName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\Environment $environment Required. The environment to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreateEnvironmentRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\Environment $environment): self + { + return (new self()) + ->setParent($parent) + ->setEnvironment($environment); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreateExperimentRequest.php b/DialogflowCx/src/V3/CreateExperimentRequest.php index 14d2dd16108c..7f5b6dcbdf95 100644 --- a/DialogflowCx/src/V3/CreateExperimentRequest.php +++ b/DialogflowCx/src/V3/CreateExperimentRequest.php @@ -32,6 +32,25 @@ class CreateExperimentRequest extends \Google\Protobuf\Internal\Message */ protected $experiment = null; + /** + * @param string $parent Required. The [Agent][google.cloud.dialogflow.cx.v3.Agent] to create an + * [Environment][google.cloud.dialogflow.cx.v3.Environment] for. Format: + * `projects//locations//agents//environments/`. Please see + * {@see ExperimentsClient::environmentName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\Experiment $experiment Required. The experiment to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreateExperimentRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\Experiment $experiment): self + { + return (new self()) + ->setParent($parent) + ->setExperiment($experiment); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreateFlowRequest.php b/DialogflowCx/src/V3/CreateFlowRequest.php index f6055b014a9e..53af33b52af0 100644 --- a/DialogflowCx/src/V3/CreateFlowRequest.php +++ b/DialogflowCx/src/V3/CreateFlowRequest.php @@ -45,6 +45,23 @@ class CreateFlowRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $parent Required. The agent to create a flow for. + * Format: `projects//locations//agents/`. Please see + * {@see FlowsClient::agentName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\Flow $flow Required. The flow to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreateFlowRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\Flow $flow): self + { + return (new self()) + ->setParent($parent) + ->setFlow($flow); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreateGeneratorRequest.php b/DialogflowCx/src/V3/CreateGeneratorRequest.php index 25c823bb5d60..d2afe49dc0d2 100644 --- a/DialogflowCx/src/V3/CreateGeneratorRequest.php +++ b/DialogflowCx/src/V3/CreateGeneratorRequest.php @@ -38,6 +38,23 @@ class CreateGeneratorRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $parent Required. The agent to create a generator for. + * Format: `projects//locations//agents/`. Please see + * {@see GeneratorsClient::agentName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\Generator $generator Required. The generator to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreateGeneratorRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\Generator $generator): self + { + return (new self()) + ->setParent($parent) + ->setGenerator($generator); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreateIntentRequest.php b/DialogflowCx/src/V3/CreateIntentRequest.php index 0c07af9e311a..63bb4b62e097 100644 --- a/DialogflowCx/src/V3/CreateIntentRequest.php +++ b/DialogflowCx/src/V3/CreateIntentRequest.php @@ -42,6 +42,23 @@ class CreateIntentRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $parent Required. The agent to create an intent for. + * Format: `projects//locations//agents/`. Please see + * {@see IntentsClient::agentName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\Intent $intent Required. The intent to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreateIntentRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\Intent $intent): self + { + return (new self()) + ->setParent($parent) + ->setIntent($intent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreatePageRequest.php b/DialogflowCx/src/V3/CreatePageRequest.php index d3ff27427c39..59875695b930 100644 --- a/DialogflowCx/src/V3/CreatePageRequest.php +++ b/DialogflowCx/src/V3/CreatePageRequest.php @@ -54,6 +54,24 @@ class CreatePageRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $parent Required. The flow to create a page for. + * Format: `projects//locations//agents//flows/`. Please see + * {@see PagesClient::flowName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\Page $page Required. The page to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreatePageRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\Page $page): self + { + return (new self()) + ->setParent($parent) + ->setPage($page); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreateSecuritySettingsRequest.php b/DialogflowCx/src/V3/CreateSecuritySettingsRequest.php index e12d78240fad..777208ede0d6 100644 --- a/DialogflowCx/src/V3/CreateSecuritySettingsRequest.php +++ b/DialogflowCx/src/V3/CreateSecuritySettingsRequest.php @@ -30,6 +30,24 @@ class CreateSecuritySettingsRequest extends \Google\Protobuf\Internal\Message */ protected $security_settings = null; + /** + * @param string $parent Required. The location to create an + * [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings] for. + * Format: `projects//locations/`. Please see + * {@see SecuritySettingsServiceClient::locationName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\SecuritySettings $securitySettings Required. The security settings to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreateSecuritySettingsRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\SecuritySettings $securitySettings): self + { + return (new self()) + ->setParent($parent) + ->setSecuritySettings($securitySettings); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreateSessionEntityTypeRequest.php b/DialogflowCx/src/V3/CreateSessionEntityTypeRequest.php index 8ef5a57e6131..e41a9eb4ab0a 100644 --- a/DialogflowCx/src/V3/CreateSessionEntityTypeRequest.php +++ b/DialogflowCx/src/V3/CreateSessionEntityTypeRequest.php @@ -34,6 +34,27 @@ class CreateSessionEntityTypeRequest extends \Google\Protobuf\Internal\Message */ protected $session_entity_type = null; + /** + * @param string $parent Required. The session to create a session entity type for. + * Format: `projects//locations//agents//sessions/` or `projects//locations//agents//environments//sessions/`. + * If `Environment ID` is not specified, we assume default 'draft' + * environment. Please see + * {@see SessionEntityTypesClient::sessionName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\SessionEntityType $sessionEntityType Required. The session entity type to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreateSessionEntityTypeRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\SessionEntityType $sessionEntityType): self + { + return (new self()) + ->setParent($parent) + ->setSessionEntityType($sessionEntityType); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreateTestCaseRequest.php b/DialogflowCx/src/V3/CreateTestCaseRequest.php index 538a6cf128ab..7b4e376c5211 100644 --- a/DialogflowCx/src/V3/CreateTestCaseRequest.php +++ b/DialogflowCx/src/V3/CreateTestCaseRequest.php @@ -30,6 +30,23 @@ class CreateTestCaseRequest extends \Google\Protobuf\Internal\Message */ protected $test_case = null; + /** + * @param string $parent Required. The agent to create the test case for. + * Format: `projects//locations//agents/`. Please see + * {@see TestCasesClient::agentName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\TestCase $testCase Required. The test case to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreateTestCaseRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\TestCase $testCase): self + { + return (new self()) + ->setParent($parent) + ->setTestCase($testCase); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreateTransitionRouteGroupRequest.php b/DialogflowCx/src/V3/CreateTransitionRouteGroupRequest.php index 93bb1b1ff772..f05e99e79ea1 100644 --- a/DialogflowCx/src/V3/CreateTransitionRouteGroupRequest.php +++ b/DialogflowCx/src/V3/CreateTransitionRouteGroupRequest.php @@ -48,6 +48,27 @@ class CreateTransitionRouteGroupRequest extends \Google\Protobuf\Internal\Messag */ protected $language_code = ''; + /** + * @param string $parent Required. The flow to create an + * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] + * for. Format: `projects//locations//agents//flows/` + * or `projects//locations//agents/` + * for agent-level groups. Please see + * {@see TransitionRouteGroupsClient::flowName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroup $transitionRouteGroup Required. The transition route group to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreateTransitionRouteGroupRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroup $transitionRouteGroup): self + { + return (new self()) + ->setParent($parent) + ->setTransitionRouteGroup($transitionRouteGroup); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreateVersionRequest.php b/DialogflowCx/src/V3/CreateVersionRequest.php index 8498d1665598..c2c9e74f224e 100644 --- a/DialogflowCx/src/V3/CreateVersionRequest.php +++ b/DialogflowCx/src/V3/CreateVersionRequest.php @@ -32,6 +32,25 @@ class CreateVersionRequest extends \Google\Protobuf\Internal\Message */ protected $version = null; + /** + * @param string $parent Required. The [Flow][google.cloud.dialogflow.cx.v3.Flow] to create an + * [Version][google.cloud.dialogflow.cx.v3.Version] for. Format: + * `projects//locations//agents//flows/`. Please see + * {@see VersionsClient::flowName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\Version $version Required. The version to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreateVersionRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\Version $version): self + { + return (new self()) + ->setParent($parent) + ->setVersion($version); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/CreateWebhookRequest.php b/DialogflowCx/src/V3/CreateWebhookRequest.php index 5672e1590cff..cfd10cdb2cf2 100644 --- a/DialogflowCx/src/V3/CreateWebhookRequest.php +++ b/DialogflowCx/src/V3/CreateWebhookRequest.php @@ -30,6 +30,23 @@ class CreateWebhookRequest extends \Google\Protobuf\Internal\Message */ protected $webhook = null; + /** + * @param string $parent Required. The agent to create a webhook for. + * Format: `projects//locations//agents/`. Please see + * {@see WebhooksClient::agentName()} for help formatting this field. + * @param \Google\Cloud\Dialogflow\Cx\V3\Webhook $webhook Required. The webhook to create. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\CreateWebhookRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Dialogflow\Cx\V3\Webhook $webhook): self + { + return (new self()) + ->setParent($parent) + ->setWebhook($webhook); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeleteAgentRequest.php b/DialogflowCx/src/V3/DeleteAgentRequest.php index d13f53c8bd81..46233ee2ba36 100644 --- a/DialogflowCx/src/V3/DeleteAgentRequest.php +++ b/DialogflowCx/src/V3/DeleteAgentRequest.php @@ -24,6 +24,21 @@ class DeleteAgentRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the agent to delete. + * Format: `projects//locations//agents/`. Please see + * {@see AgentsClient::agentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\DeleteAgentRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeleteEntityTypeRequest.php b/DialogflowCx/src/V3/DeleteEntityTypeRequest.php index c149c11be8b7..dbb5302b1ee9 100644 --- a/DialogflowCx/src/V3/DeleteEntityTypeRequest.php +++ b/DialogflowCx/src/V3/DeleteEntityTypeRequest.php @@ -41,6 +41,22 @@ class DeleteEntityTypeRequest extends \Google\Protobuf\Internal\Message */ protected $force = false; + /** + * @param string $name Required. The name of the entity type to delete. + * Format: `projects//locations//agents//entityTypes/`. Please see + * {@see EntityTypesClient::entityTypeName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\DeleteEntityTypeRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeleteEnvironmentRequest.php b/DialogflowCx/src/V3/DeleteEnvironmentRequest.php index 47bbb5c83aa7..7f2a2ed73b0a 100644 --- a/DialogflowCx/src/V3/DeleteEnvironmentRequest.php +++ b/DialogflowCx/src/V3/DeleteEnvironmentRequest.php @@ -26,6 +26,23 @@ class DeleteEnvironmentRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the + * [Environment][google.cloud.dialogflow.cx.v3.Environment] to delete. Format: + * `projects//locations//agents//environments/`. Please see + * {@see EnvironmentsClient::environmentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\DeleteEnvironmentRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeleteExperimentRequest.php b/DialogflowCx/src/V3/DeleteExperimentRequest.php index 1e46e010e975..f716a89b61d2 100644 --- a/DialogflowCx/src/V3/DeleteExperimentRequest.php +++ b/DialogflowCx/src/V3/DeleteExperimentRequest.php @@ -26,6 +26,23 @@ class DeleteExperimentRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the + * [Environment][google.cloud.dialogflow.cx.v3.Environment] to delete. Format: + * `projects//locations//agents//environments//experiments/`. Please see + * {@see ExperimentsClient::experimentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\DeleteExperimentRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeleteFlowRequest.php b/DialogflowCx/src/V3/DeleteFlowRequest.php index 6ce38982ee88..574851eb24f4 100644 --- a/DialogflowCx/src/V3/DeleteFlowRequest.php +++ b/DialogflowCx/src/V3/DeleteFlowRequest.php @@ -39,6 +39,22 @@ class DeleteFlowRequest extends \Google\Protobuf\Internal\Message */ protected $force = false; + /** + * @param string $name Required. The name of the flow to delete. + * Format: `projects//locations//agents//flows/`. Please see + * {@see FlowsClient::flowName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\DeleteFlowRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeleteGeneratorRequest.php b/DialogflowCx/src/V3/DeleteGeneratorRequest.php index 4e4232cc9df6..88a4d7873ad0 100644 --- a/DialogflowCx/src/V3/DeleteGeneratorRequest.php +++ b/DialogflowCx/src/V3/DeleteGeneratorRequest.php @@ -37,6 +37,22 @@ class DeleteGeneratorRequest extends \Google\Protobuf\Internal\Message */ protected $force = false; + /** + * @param string $name Required. The name of the generator to delete. + * Format: `projects//locations//agents//generators/`. Please see + * {@see GeneratorsClient::generatorName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\DeleteGeneratorRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeleteIntentRequest.php b/DialogflowCx/src/V3/DeleteIntentRequest.php index 1bb15005f590..e13d235b6c88 100644 --- a/DialogflowCx/src/V3/DeleteIntentRequest.php +++ b/DialogflowCx/src/V3/DeleteIntentRequest.php @@ -25,6 +25,22 @@ class DeleteIntentRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the intent to delete. + * Format: `projects//locations//agents//intents/`. Please see + * {@see IntentsClient::intentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\DeleteIntentRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeletePageRequest.php b/DialogflowCx/src/V3/DeletePageRequest.php index cecbb7c1e989..6a68eab0089f 100644 --- a/DialogflowCx/src/V3/DeletePageRequest.php +++ b/DialogflowCx/src/V3/DeletePageRequest.php @@ -39,6 +39,22 @@ class DeletePageRequest extends \Google\Protobuf\Internal\Message */ protected $force = false; + /** + * @param string $name Required. The name of the page to delete. + * Format: `projects//locations//agents//Flows//pages/`. Please see + * {@see PagesClient::pageName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\DeletePageRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeleteSecuritySettingsRequest.php b/DialogflowCx/src/V3/DeleteSecuritySettingsRequest.php index 4a3a10911622..405087966090 100644 --- a/DialogflowCx/src/V3/DeleteSecuritySettingsRequest.php +++ b/DialogflowCx/src/V3/DeleteSecuritySettingsRequest.php @@ -25,6 +25,23 @@ class DeleteSecuritySettingsRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the + * [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings] to + * delete. Format: `projects//locations//securitySettings/`. Please see + * {@see SecuritySettingsServiceClient::securitySettingsName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\DeleteSecuritySettingsRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeleteSessionEntityTypeRequest.php b/DialogflowCx/src/V3/DeleteSessionEntityTypeRequest.php index 4cfa73e74853..9e1a38fbcdcf 100644 --- a/DialogflowCx/src/V3/DeleteSessionEntityTypeRequest.php +++ b/DialogflowCx/src/V3/DeleteSessionEntityTypeRequest.php @@ -29,6 +29,26 @@ class DeleteSessionEntityTypeRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the session entity type to delete. + * Format: `projects//locations//agents//sessions//entityTypes/` or + * `projects//locations//agents//environments//sessions//entityTypes/`. If `Environment ID` is not specified, we assume default 'draft' + * environment. Please see + * {@see SessionEntityTypesClient::sessionEntityTypeName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\DeleteSessionEntityTypeRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeleteTransitionRouteGroupRequest.php b/DialogflowCx/src/V3/DeleteTransitionRouteGroupRequest.php index 611d4f800359..78c42e93f8a7 100644 --- a/DialogflowCx/src/V3/DeleteTransitionRouteGroupRequest.php +++ b/DialogflowCx/src/V3/DeleteTransitionRouteGroupRequest.php @@ -39,6 +39,25 @@ class DeleteTransitionRouteGroupRequest extends \Google\Protobuf\Internal\Messag */ protected $force = false; + /** + * @param string $name Required. The name of the + * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] + * to delete. Format: `projects//locations//agents//flows//transitionRouteGroups/` or `projects//locations//agents//transitionRouteGroups/`. Please see + * {@see TransitionRouteGroupsClient::transitionRouteGroupName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\DeleteTransitionRouteGroupRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeleteVersionRequest.php b/DialogflowCx/src/V3/DeleteVersionRequest.php index 64730cc67445..4491f17a9db7 100644 --- a/DialogflowCx/src/V3/DeleteVersionRequest.php +++ b/DialogflowCx/src/V3/DeleteVersionRequest.php @@ -25,6 +25,22 @@ class DeleteVersionRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the [Version][google.cloud.dialogflow.cx.v3.Version] + * to delete. Format: `projects//locations//agents//flows//versions/`. Please see + * {@see VersionsClient::versionName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\DeleteVersionRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeleteWebhookRequest.php b/DialogflowCx/src/V3/DeleteWebhookRequest.php index 9a5eaf264e25..2c6616c283e5 100644 --- a/DialogflowCx/src/V3/DeleteWebhookRequest.php +++ b/DialogflowCx/src/V3/DeleteWebhookRequest.php @@ -39,6 +39,22 @@ class DeleteWebhookRequest extends \Google\Protobuf\Internal\Message */ protected $force = false; + /** + * @param string $name Required. The name of the webhook to delete. + * Format: `projects//locations//agents//webhooks/`. Please see + * {@see WebhooksClient::webhookName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\DeleteWebhookRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/DeploymentsClient.php b/DialogflowCx/src/V3/DeploymentsClient.php deleted file mode 100644 index 0af1b1212cf7..000000000000 --- a/DialogflowCx/src/V3/DeploymentsClient.php +++ /dev/null @@ -1,34 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $agent = new Agent(); - * $response = $agentsClient->createAgent($formattedParent, $agent); - * } finally { - * $agentsClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class AgentsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.Agents'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $agentGenerativeSettingsNameTemplate; - - private static $agentValidationResultNameTemplate; - - private static $environmentNameTemplate; - - private static $flowNameTemplate; - - private static $locationNameTemplate; - - private static $securitySettingsNameTemplate; - - private static $pathTemplateMap; - - private $operationsClient; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/agents_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/agents_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/agents_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/agents_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 getAgentGenerativeSettingsNameTemplate() - { - if (self::$agentGenerativeSettingsNameTemplate == null) { - self::$agentGenerativeSettingsNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/generativeSettings'); - } - - return self::$agentGenerativeSettingsNameTemplate; - } - - private static function getAgentValidationResultNameTemplate() - { - if (self::$agentValidationResultNameTemplate == null) { - self::$agentValidationResultNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/validationResult'); - } - - return self::$agentValidationResultNameTemplate; - } - - private static function getEnvironmentNameTemplate() - { - if (self::$environmentNameTemplate == null) { - self::$environmentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/environments/{environment}'); - } - - return self::$environmentNameTemplate; - } - - private static function getFlowNameTemplate() - { - if (self::$flowNameTemplate == null) { - self::$flowNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}'); - } - - return self::$flowNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); - } - - return self::$locationNameTemplate; - } - - private static function getSecuritySettingsNameTemplate() - { - if (self::$securitySettingsNameTemplate == null) { - self::$securitySettingsNameTemplate = new PathTemplate('projects/{project}/locations/{location}/securitySettings/{security_settings}'); - } - - return self::$securitySettingsNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'agent' => self::getAgentNameTemplate(), - 'agentGenerativeSettings' => self::getAgentGenerativeSettingsNameTemplate(), - 'agentValidationResult' => self::getAgentValidationResultNameTemplate(), - 'environment' => self::getEnvironmentNameTemplate(), - 'flow' => self::getFlowNameTemplate(), - 'location' => self::getLocationNameTemplate(), - 'securitySettings' => self::getSecuritySettingsNameTemplate(), - ]; - } - - 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 - * agent_generative_settings resource. - * - * @param string $project - * @param string $location - * @param string $agent - * - * @return string The formatted agent_generative_settings resource. - */ - public static function agentGenerativeSettingsName($project, $location, $agent) - { - return self::getAgentGenerativeSettingsNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * agent_validation_result resource. - * - * @param string $project - * @param string $location - * @param string $agent - * - * @return string The formatted agent_validation_result resource. - */ - public static function agentValidationResultName($project, $location, $agent) - { - return self::getAgentValidationResultNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a environment - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $environment - * - * @return string The formatted environment resource. - */ - public static function environmentName($project, $location, $agent, $environment) - { - return self::getEnvironmentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'environment' => $environment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a flow - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * - * @return string The formatted flow resource. - */ - public static function flowName($project, $location, $agent, $flow) - { - return self::getFlowNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName($project, $location) - { - return self::getLocationNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * security_settings resource. - * - * @param string $project - * @param string $location - * @param string $securitySettings - * - * @return string The formatted security_settings resource. - */ - public static function securitySettingsName($project, $location, $securitySettings) - { - return self::getSecuritySettingsNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'security_settings' => $securitySettings, - ]); - } - - /** - * 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} - * - agentGenerativeSettings: projects/{project}/locations/{location}/agents/{agent}/generativeSettings - * - agentValidationResult: projects/{project}/locations/{location}/agents/{agent}/validationResult - * - environment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment} - * - flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow} - * - location: projects/{project}/locations/{location} - * - securitySettings: projects/{project}/locations/{location}/securitySettings/{security_settings} - * - * 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"); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** - * Creates an agent in the specified location. - * - * Note: You should always train flows prior to sending them queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $agentsClient = new AgentsClient(); - * try { - * $formattedParent = $agentsClient->locationName('[PROJECT]', '[LOCATION]'); - * $agent = new Agent(); - * $response = $agentsClient->createAgent($formattedParent, $agent); - * } finally { - * $agentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The location to create a agent for. - * Format: `projects//locations/`. - * @param Agent $agent Required. The agent to create. - * @param array $optionalArgs { - * Optional. - * - * @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\Agent - * - * @throws ApiException if the remote call fails - */ - public function createAgent($parent, $agent, array $optionalArgs = []) - { - $request = new CreateAgentRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setAgent($agent); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateAgent', Agent::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes the specified agent. - * - * Sample code: - * ``` - * $agentsClient = new AgentsClient(); - * try { - * $formattedName = $agentsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $agentsClient->deleteAgent($formattedName); - * } finally { - * $agentsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the agent to delete. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @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 deleteAgent($name, array $optionalArgs = []) - { - $request = new DeleteAgentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteAgent', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Exports the specified agent to a binary file. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: - * [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse] - * - * Sample code: - * ``` - * $agentsClient = new AgentsClient(); - * try { - * $formattedName = $agentsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $operationResponse = $agentsClient->exportAgent($formattedName); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $agentsClient->exportAgent($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $agentsClient->resumeOperation($operationName, 'exportAgent'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $agentsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the agent to export. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $agentUri - * Optional. The [Google Cloud - * Storage](https://cloud.google.com/storage/docs/) URI to export the agent - * to. The format of this URI must be `gs:///`. If - * left unspecified, the serialized agent is returned inline. - * - * Dialogflow performs a write operation for the Cloud Storage object - * on the caller's behalf, so your request authentication must - * have write permissions for the object. For more information, see - * [Dialogflow access - * control](https://cloud.google.com/dialogflow/cx/docs/concept/access-control#storage). - * @type int $dataFormat - * Optional. The data format of the exported agent. If not specified, `BLOB` - * is assumed. - * For allowed values, use constants defined on {@see \Google\Cloud\Dialogflow\Cx\V3\ExportAgentRequest\DataFormat} - * @type string $environment - * Optional. Environment name. If not set, draft environment is assumed. - * Format: `projects//locations//agents//environments/`. - * @type GitDestination $gitDestination - * Optional. The Git branch to export the agent to. - * @type bool $includeBigqueryExportSettings - * Optional. Whether to include BigQuery Export setting. - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function exportAgent($name, array $optionalArgs = []) - { - $request = new ExportAgentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['agentUri'])) { - $request->setAgentUri($optionalArgs['agentUri']); - } - - if (isset($optionalArgs['dataFormat'])) { - $request->setDataFormat($optionalArgs['dataFormat']); - } - - if (isset($optionalArgs['environment'])) { - $request->setEnvironment($optionalArgs['environment']); - } - - if (isset($optionalArgs['gitDestination'])) { - $request->setGitDestination($optionalArgs['gitDestination']); - } - - if (isset($optionalArgs['includeBigqueryExportSettings'])) { - $request->setIncludeBigqueryExportSettings($optionalArgs['includeBigqueryExportSettings']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ExportAgent', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Retrieves the specified agent. - * - * Sample code: - * ``` - * $agentsClient = new AgentsClient(); - * try { - * $formattedName = $agentsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $response = $agentsClient->getAgent($formattedName); - * } finally { - * $agentsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the agent. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @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\Agent - * - * @throws ApiException if the remote call fails - */ - public function getAgent($name, array $optionalArgs = []) - { - $request = new GetAgentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetAgent', Agent::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets the latest agent validation result. Agent validation is performed - * when ValidateAgent is called. - * - * Sample code: - * ``` - * $agentsClient = new AgentsClient(); - * try { - * $formattedName = $agentsClient->agentValidationResultName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $response = $agentsClient->getAgentValidationResult($formattedName); - * } finally { - * $agentsClient->close(); - * } - * ``` - * - * @param string $name Required. The agent name. - * Format: `projects//locations//agents//validationResult`. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * 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\AgentValidationResult - * - * @throws ApiException if the remote call fails - */ - public function getAgentValidationResult($name, array $optionalArgs = []) - { - $request = new GetAgentValidationResultRequest(); - $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('GetAgentValidationResult', AgentValidationResult::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets the generative settings for the agent. - * - * Sample code: - * ``` - * $agentsClient = new AgentsClient(); - * try { - * $formattedName = $agentsClient->agentGenerativeSettingsName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $languageCode = 'language_code'; - * $response = $agentsClient->getGenerativeSettings($formattedName, $languageCode); - * } finally { - * $agentsClient->close(); - * } - * ``` - * - * @param string $name Required. Format: `projects//locations//agents//generativeSettings`. - * @param string $languageCode Required. Language code of the generative settings. - * @param array $optionalArgs { - * Optional. - * - * @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\GenerativeSettings - * - * @throws ApiException if the remote call fails - */ - public function getGenerativeSettings($name, $languageCode, array $optionalArgs = []) - { - $request = new GetGenerativeSettingsRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setLanguageCode($languageCode); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetGenerativeSettings', GenerativeSettings::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns the list of all agents in the specified location. - * - * Sample code: - * ``` - * $agentsClient = new AgentsClient(); - * try { - * $formattedParent = $agentsClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $agentsClient->listAgents($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $agentsClient->listAgents($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $agentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The location to list all agents for. - * Format: `projects//locations/`. - * @param array $optionalArgs { - * Optional. - * - * @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 listAgents($parent, array $optionalArgs = []) - { - $request = new ListAgentsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - 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('ListAgents', $optionalArgs, ListAgentsResponse::class, $request); - } - - /** - * Restores the specified agent from a binary file. - * - * Replaces the current agent with a new one. Note that all existing resources - * in agent (e.g. intents, entity types, flows) will be removed. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * Note: You should always train flows prior to sending them queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $agentsClient = new AgentsClient(); - * try { - * $formattedName = $agentsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $operationResponse = $agentsClient->restoreAgent($formattedName); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $agentsClient->restoreAgent($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $agentsClient->resumeOperation($operationName, 'restoreAgent'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $agentsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the agent to restore into. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $agentUri - * The [Google Cloud Storage](https://cloud.google.com/storage/docs/) URI - * to restore agent from. The format of this URI must be - * `gs:///`. - * - * Dialogflow performs a read operation for the Cloud Storage object - * on the caller's behalf, so your request authentication must - * have read permissions for the object. For more information, see - * [Dialogflow access - * control](https://cloud.google.com/dialogflow/cx/docs/concept/access-control#storage). - * @type string $agentContent - * Uncompressed raw byte content for agent. - * @type GitSource $gitSource - * Setting for restoring from a git branch - * @type int $restoreOption - * Agent restore mode. If not specified, `KEEP` is assumed. - * For allowed values, use constants defined on {@see \Google\Cloud\Dialogflow\Cx\V3\RestoreAgentRequest\RestoreOption} - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function restoreAgent($name, array $optionalArgs = []) - { - $request = new RestoreAgentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['agentUri'])) { - $request->setAgentUri($optionalArgs['agentUri']); - } - - if (isset($optionalArgs['agentContent'])) { - $request->setAgentContent($optionalArgs['agentContent']); - } - - if (isset($optionalArgs['gitSource'])) { - $request->setGitSource($optionalArgs['gitSource']); - } - - if (isset($optionalArgs['restoreOption'])) { - $request->setRestoreOption($optionalArgs['restoreOption']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('RestoreAgent', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Updates the specified agent. - * - * Note: You should always train flows prior to sending them queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $agentsClient = new AgentsClient(); - * try { - * $agent = new Agent(); - * $response = $agentsClient->updateAgent($agent); - * } finally { - * $agentsClient->close(); - * } - * ``` - * - * @param Agent $agent Required. The agent to update. - * @param array $optionalArgs { - * Optional. - * - * @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\Agent - * - * @throws ApiException if the remote call fails - */ - public function updateAgent($agent, array $optionalArgs = []) - { - $request = new UpdateAgentRequest(); - $requestParamHeaders = []; - $request->setAgent($agent); - $requestParamHeaders['agent.name'] = $agent->getName(); - 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('UpdateAgent', Agent::class, $optionalArgs, $request)->wait(); - } - - /** - * Updates the generative settings for the agent. - * - * Sample code: - * ``` - * $agentsClient = new AgentsClient(); - * try { - * $generativeSettings = new GenerativeSettings(); - * $response = $agentsClient->updateGenerativeSettings($generativeSettings); - * } finally { - * $agentsClient->close(); - * } - * ``` - * - * @param GenerativeSettings $generativeSettings Required. Generative settings to update. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Optional. 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\GenerativeSettings - * - * @throws ApiException if the remote call fails - */ - public function updateGenerativeSettings($generativeSettings, array $optionalArgs = []) - { - $request = new UpdateGenerativeSettingsRequest(); - $requestParamHeaders = []; - $request->setGenerativeSettings($generativeSettings); - $requestParamHeaders['generative_settings.name'] = $generativeSettings->getName(); - 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('UpdateGenerativeSettings', GenerativeSettings::class, $optionalArgs, $request)->wait(); - } - - /** - * Validates the specified agent and creates or updates validation results. - * The agent in draft version is validated. Please call this API after the - * training is completed to get the complete validation results. - * - * Sample code: - * ``` - * $agentsClient = new AgentsClient(); - * try { - * $formattedName = $agentsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $response = $agentsClient->validateAgent($formattedName); - * } finally { - * $agentsClient->close(); - * } - * ``` - * - * @param string $name Required. The agent to validate. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * 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\AgentValidationResult - * - * @throws ApiException if the remote call fails - */ - public function validateAgent($name, array $optionalArgs = []) - { - $request = new ValidateAgentRequest(); - $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('ValidateAgent', AgentValidationResult::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $agentsClient = new AgentsClient(); - * try { - * $response = $agentsClient->getLocation(); - * } finally { - * $agentsClient->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: - * ``` - * $agentsClient = new AgentsClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $agentsClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $agentsClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $agentsClient->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/ChangelogsGapicClient.php b/DialogflowCx/src/V3/Gapic/ChangelogsGapicClient.php deleted file mode 100644 index d2c338e2b854..000000000000 --- a/DialogflowCx/src/V3/Gapic/ChangelogsGapicClient.php +++ /dev/null @@ -1,548 +0,0 @@ -changelogName('[PROJECT]', '[LOCATION]', '[AGENT]', '[CHANGELOG]'); - * $response = $changelogsClient->getChangelog($formattedName); - * } finally { - * $changelogsClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class ChangelogsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.Changelogs'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $changelogNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/changelogs_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/changelogs_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/changelogs_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/changelogs_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 getChangelogNameTemplate() - { - if (self::$changelogNameTemplate == null) { - self::$changelogNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/changelogs/{changelog}'); - } - - return self::$changelogNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'agent' => self::getAgentNameTemplate(), - 'changelog' => self::getChangelogNameTemplate(), - ]; - } - - 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 changelog - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $changelog - * - * @return string The formatted changelog resource. - */ - public static function changelogName($project, $location, $agent, $changelog) - { - return self::getChangelogNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'changelog' => $changelog, - ]); - } - - /** - * 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} - * - changelog: projects/{project}/locations/{location}/agents/{agent}/changelogs/{changelog} - * - * 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); - } - - /** - * Retrieves the specified Changelog. - * - * Sample code: - * ``` - * $changelogsClient = new ChangelogsClient(); - * try { - * $formattedName = $changelogsClient->changelogName('[PROJECT]', '[LOCATION]', '[AGENT]', '[CHANGELOG]'); - * $response = $changelogsClient->getChangelog($formattedName); - * } finally { - * $changelogsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the changelog to get. - * Format: `projects//locations//agents//changelogs/`. - * @param array $optionalArgs { - * Optional. - * - * @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\Changelog - * - * @throws ApiException if the remote call fails - */ - public function getChangelog($name, array $optionalArgs = []) - { - $request = new GetChangelogRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetChangelog', Changelog::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns the list of Changelogs. - * - * Sample code: - * ``` - * $changelogsClient = new ChangelogsClient(); - * try { - * $formattedParent = $changelogsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * // Iterate over pages of elements - * $pagedResponse = $changelogsClient->listChangelogs($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $changelogsClient->listChangelogs($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $changelogsClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent containing the changelogs. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $filter - * The filter string. Supports filter by user_email, resource, type and - * create_time. Some examples: - * 1. By user email: - * user_email = "someone@google.com" - * 2. By resource name: - * resource = "projects/123/locations/global/agents/456/flows/789" - * 3. By resource display name: - * display_name = "my agent" - * 4. By action: - * action = "Create" - * 5. By type: - * type = "flows" - * 6. By create time. Currently predicates on `create_time` and - * `create_time_epoch_seconds` are supported: - * create_time_epoch_seconds > 1551790877 AND create_time <= - * 2017-01-15T01:30:15.01Z - * 7. Combination of above filters: - * resource = "projects/123/locations/global/agents/456/flows/789" - * AND user_email = "someone@google.com" - * AND create_time <= 2017-01-15T01:30:15.01Z - * @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 listChangelogs($parent, array $optionalArgs = []) - { - $request = new ListChangelogsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - 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('ListChangelogs', $optionalArgs, ListChangelogsResponse::class, $request); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $changelogsClient = new ChangelogsClient(); - * try { - * $response = $changelogsClient->getLocation(); - * } finally { - * $changelogsClient->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: - * ``` - * $changelogsClient = new ChangelogsClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $changelogsClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $changelogsClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $changelogsClient->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/DeploymentsGapicClient.php b/DialogflowCx/src/V3/Gapic/DeploymentsGapicClient.php deleted file mode 100644 index 28e209f06385..000000000000 --- a/DialogflowCx/src/V3/Gapic/DeploymentsGapicClient.php +++ /dev/null @@ -1,532 +0,0 @@ -deploymentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[DEPLOYMENT]'); - * $response = $deploymentsClient->getDeployment($formattedName); - * } finally { - * $deploymentsClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class DeploymentsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.Deployments'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $deploymentNameTemplate; - - private static $environmentNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/deployments_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/deployments_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/deployments_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/deployments_rest_client_config.php', - ], - ], - ]; - } - - private static function getDeploymentNameTemplate() - { - if (self::$deploymentNameTemplate == null) { - self::$deploymentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/deployments/{deployment}'); - } - - return self::$deploymentNameTemplate; - } - - private static function getEnvironmentNameTemplate() - { - if (self::$environmentNameTemplate == null) { - self::$environmentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/environments/{environment}'); - } - - return self::$environmentNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'deployment' => self::getDeploymentNameTemplate(), - 'environment' => self::getEnvironmentNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a deployment - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $environment - * @param string $deployment - * - * @return string The formatted deployment resource. - */ - public static function deploymentName($project, $location, $agent, $environment, $deployment) - { - return self::getDeploymentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'environment' => $environment, - 'deployment' => $deployment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a environment - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $environment - * - * @return string The formatted environment resource. - */ - public static function environmentName($project, $location, $agent, $environment) - { - return self::getEnvironmentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'environment' => $environment, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - deployment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/deployments/{deployment} - * - environment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment} - * - * 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); - } - - /** - * Retrieves the specified - * [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. - * - * Sample code: - * ``` - * $deploymentsClient = new DeploymentsClient(); - * try { - * $formattedName = $deploymentsClient->deploymentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[DEPLOYMENT]'); - * $response = $deploymentsClient->getDeployment($formattedName); - * } finally { - * $deploymentsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the - * [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. Format: - * `projects//locations//agents//environments//deployments/`. - * @param array $optionalArgs { - * Optional. - * - * @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\Deployment - * - * @throws ApiException if the remote call fails - */ - public function getDeployment($name, array $optionalArgs = []) - { - $request = new GetDeploymentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetDeployment', Deployment::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns the list of all deployments in the specified - * [Environment][google.cloud.dialogflow.cx.v3.Environment]. - * - * Sample code: - * ``` - * $deploymentsClient = new DeploymentsClient(); - * try { - * $formattedParent = $deploymentsClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - * // Iterate over pages of elements - * $pagedResponse = $deploymentsClient->listDeployments($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $deploymentsClient->listDeployments($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $deploymentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The [Environment][google.cloud.dialogflow.cx.v3.Environment] to - * list all environments for. Format: `projects//locations//agents//environments/`. - * @param array $optionalArgs { - * Optional. - * - * @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 listDeployments($parent, array $optionalArgs = []) - { - $request = new ListDeploymentsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - 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('ListDeployments', $optionalArgs, ListDeploymentsResponse::class, $request); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $deploymentsClient = new DeploymentsClient(); - * try { - * $response = $deploymentsClient->getLocation(); - * } finally { - * $deploymentsClient->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: - * ``` - * $deploymentsClient = new DeploymentsClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $deploymentsClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $deploymentsClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $deploymentsClient->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/EntityTypesGapicClient.php b/DialogflowCx/src/V3/Gapic/EntityTypesGapicClient.php deleted file mode 100644 index cada896f8c76..000000000000 --- a/DialogflowCx/src/V3/Gapic/EntityTypesGapicClient.php +++ /dev/null @@ -1,751 +0,0 @@ -agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $entityType = new EntityType(); - * $response = $entityTypesClient->createEntityType($formattedParent, $entityType); - * } finally { - * $entityTypesClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class EntityTypesGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.EntityTypes'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $entityTypeNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/entity_types_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/entity_types_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/entity_types_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/entity_types_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 getEntityTypeNameTemplate() - { - if (self::$entityTypeNameTemplate == null) { - self::$entityTypeNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}'); - } - - return self::$entityTypeNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'agent' => self::getAgentNameTemplate(), - 'entityType' => self::getEntityTypeNameTemplate(), - ]; - } - - 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 entity_type - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $entityType - * - * @return string The formatted entity_type resource. - */ - public static function entityTypeName($project, $location, $agent, $entityType) - { - return self::getEntityTypeNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'entity_type' => $entityType, - ]); - } - - /** - * 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} - * - entityType: projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type} - * - * 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 an entity type in the specified agent. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $entityTypesClient = new EntityTypesClient(); - * try { - * $formattedParent = $entityTypesClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $entityType = new EntityType(); - * $response = $entityTypesClient->createEntityType($formattedParent, $entityType); - * } finally { - * $entityTypesClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent to create a entity type for. - * Format: `projects//locations//agents/`. - * @param EntityType $entityType Required. The entity type to create. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language of the following fields in `entity_type`: - * - * * `EntityType.entities.value` - * * `EntityType.entities.synonyms` - * * `EntityType.excluded_phrases.value` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\EntityType - * - * @throws ApiException if the remote call fails - */ - public function createEntityType($parent, $entityType, array $optionalArgs = []) - { - $request = new CreateEntityTypeRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setEntityType($entityType); - $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('CreateEntityType', EntityType::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes the specified entity type. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $entityTypesClient = new EntityTypesClient(); - * try { - * $formattedName = $entityTypesClient->entityTypeName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENTITY_TYPE]'); - * $entityTypesClient->deleteEntityType($formattedName); - * } finally { - * $entityTypesClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the entity type to delete. - * Format: `projects//locations//agents//entityTypes/`. - * @param array $optionalArgs { - * Optional. - * - * @type bool $force - * This field has no effect for entity type not being used. - * For entity types that are used by intents or pages: - * - * * If `force` is set to false, an error will be returned with message - * indicating the referencing resources. - * * If `force` is set to true, Dialogflow will remove the entity type, as - * well as any references to the entity type (i.e. Page - * [parameter][google.cloud.dialogflow.cx.v3.Form.Parameter] of the entity - * type will be changed to - * '@sys.any' and intent - * [parameter][google.cloud.dialogflow.cx.v3.Intent.Parameter] of the - * entity type will be removed). - * @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 deleteEntityType($name, array $optionalArgs = []) - { - $request = new DeleteEntityTypeRequest(); - $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('DeleteEntityType', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Retrieves the specified entity type. - * - * Sample code: - * ``` - * $entityTypesClient = new EntityTypesClient(); - * try { - * $formattedName = $entityTypesClient->entityTypeName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENTITY_TYPE]'); - * $response = $entityTypesClient->getEntityType($formattedName); - * } finally { - * $entityTypesClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the entity type. - * Format: `projects//locations//agents//entityTypes/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language to retrieve the entity type for. The following fields are - * language dependent: - * - * * `EntityType.entities.value` - * * `EntityType.entities.synonyms` - * * `EntityType.excluded_phrases.value` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\EntityType - * - * @throws ApiException if the remote call fails - */ - public function getEntityType($name, array $optionalArgs = []) - { - $request = new GetEntityTypeRequest(); - $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('GetEntityType', EntityType::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns the list of all entity types in the specified agent. - * - * Sample code: - * ``` - * $entityTypesClient = new EntityTypesClient(); - * try { - * $formattedParent = $entityTypesClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * // Iterate over pages of elements - * $pagedResponse = $entityTypesClient->listEntityTypes($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $entityTypesClient->listEntityTypes($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $entityTypesClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent to list all entity types for. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language to list entity types for. The following fields are language - * dependent: - * - * * `EntityType.entities.value` - * * `EntityType.entities.synonyms` - * * `EntityType.excluded_phrases.value` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be used. - * @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 listEntityTypes($parent, array $optionalArgs = []) - { - $request = new ListEntityTypesRequest(); - $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('ListEntityTypes', $optionalArgs, ListEntityTypesResponse::class, $request); - } - - /** - * Updates the specified entity type. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $entityTypesClient = new EntityTypesClient(); - * try { - * $entityType = new EntityType(); - * $response = $entityTypesClient->updateEntityType($entityType); - * } finally { - * $entityTypesClient->close(); - * } - * ``` - * - * @param EntityType $entityType Required. The entity type to update. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language of the following fields in `entity_type`: - * - * * `EntityType.entities.value` - * * `EntityType.entities.synonyms` - * * `EntityType.excluded_phrases.value` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be used. - * @type FieldMask $updateMask - * The mask to control which fields get 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\EntityType - * - * @throws ApiException if the remote call fails - */ - public function updateEntityType($entityType, array $optionalArgs = []) - { - $request = new UpdateEntityTypeRequest(); - $requestParamHeaders = []; - $request->setEntityType($entityType); - $requestParamHeaders['entity_type.name'] = $entityType->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('UpdateEntityType', EntityType::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $entityTypesClient = new EntityTypesClient(); - * try { - * $response = $entityTypesClient->getLocation(); - * } finally { - * $entityTypesClient->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: - * ``` - * $entityTypesClient = new EntityTypesClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $entityTypesClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $entityTypesClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $entityTypesClient->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/EnvironmentsGapicClient.php b/DialogflowCx/src/V3/Gapic/EnvironmentsGapicClient.php deleted file mode 100644 index fa480908fa14..000000000000 --- a/DialogflowCx/src/V3/Gapic/EnvironmentsGapicClient.php +++ /dev/null @@ -1,1235 +0,0 @@ -agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $environment = new Environment(); - * $operationResponse = $environmentsClient->createEnvironment($formattedParent, $environment); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $environmentsClient->createEnvironment($formattedParent, $environment); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $environmentsClient->resumeOperation($operationName, 'createEnvironment'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $environmentsClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class EnvironmentsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.Environments'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $environmentNameTemplate; - - private static $serviceNameTemplate; - - private static $testCaseNameTemplate; - - private static $versionNameTemplate; - - private static $webhookNameTemplate; - - private static $pathTemplateMap; - - private $operationsClient; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/environments_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/environments_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/environments_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/environments_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 getEnvironmentNameTemplate() - { - if (self::$environmentNameTemplate == null) { - self::$environmentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/environments/{environment}'); - } - - return self::$environmentNameTemplate; - } - - private static function getServiceNameTemplate() - { - if (self::$serviceNameTemplate == null) { - self::$serviceNameTemplate = new PathTemplate('projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}'); - } - - return self::$serviceNameTemplate; - } - - private static function getTestCaseNameTemplate() - { - if (self::$testCaseNameTemplate == null) { - self::$testCaseNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}'); - } - - return self::$testCaseNameTemplate; - } - - private static function getVersionNameTemplate() - { - if (self::$versionNameTemplate == null) { - self::$versionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}'); - } - - return self::$versionNameTemplate; - } - - private static function getWebhookNameTemplate() - { - if (self::$webhookNameTemplate == null) { - self::$webhookNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}'); - } - - return self::$webhookNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'agent' => self::getAgentNameTemplate(), - 'environment' => self::getEnvironmentNameTemplate(), - 'service' => self::getServiceNameTemplate(), - 'testCase' => self::getTestCaseNameTemplate(), - 'version' => self::getVersionNameTemplate(), - 'webhook' => self::getWebhookNameTemplate(), - ]; - } - - 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 environment - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $environment - * - * @return string The formatted environment resource. - */ - public static function environmentName($project, $location, $agent, $environment) - { - return self::getEnvironmentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'environment' => $environment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $location - * @param string $namespace - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName($project, $location, $namespace, $service) - { - return self::getServiceNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'namespace' => $namespace, - 'service' => $service, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a test_case - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $testCase - * - * @return string The formatted test_case resource. - */ - public static function testCaseName($project, $location, $agent, $testCase) - { - return self::getTestCaseNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'test_case' => $testCase, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a version - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $version - * - * @return string The formatted version resource. - */ - public static function versionName($project, $location, $agent, $flow, $version) - { - return self::getVersionNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'version' => $version, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a webhook - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $webhook - * - * @return string The formatted webhook resource. - */ - public static function webhookName($project, $location, $agent, $webhook) - { - return self::getWebhookNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'webhook' => $webhook, - ]); - } - - /** - * 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} - * - environment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment} - * - service: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service} - * - testCase: projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case} - * - version: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version} - * - webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook} - * - * 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"); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** - * Creates an [Environment][google.cloud.dialogflow.cx.v3.Environment] in the - * specified [Agent][google.cloud.dialogflow.cx.v3.Agent]. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: [Environment][google.cloud.dialogflow.cx.v3.Environment] - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedParent = $environmentsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $environment = new Environment(); - * $operationResponse = $environmentsClient->createEnvironment($formattedParent, $environment); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $environmentsClient->createEnvironment($formattedParent, $environment); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $environmentsClient->resumeOperation($operationName, 'createEnvironment'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The [Agent][google.cloud.dialogflow.cx.v3.Agent] to create an - * [Environment][google.cloud.dialogflow.cx.v3.Environment] for. Format: - * `projects//locations//agents/`. - * @param Environment $environment Required. The environment to create. - * @param array $optionalArgs { - * Optional. - * - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function createEnvironment($parent, $environment, array $optionalArgs = []) - { - $request = new CreateEnvironmentRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setEnvironment($environment); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreateEnvironment', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Deletes the specified - * [Environment][google.cloud.dialogflow.cx.v3.Environment]. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedName = $environmentsClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - * $environmentsClient->deleteEnvironment($formattedName); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the - * [Environment][google.cloud.dialogflow.cx.v3.Environment] to delete. Format: - * `projects//locations//agents//environments/`. - * @param array $optionalArgs { - * Optional. - * - * @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 deleteEnvironment($name, array $optionalArgs = []) - { - $request = new DeleteEnvironmentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteEnvironment', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Deploys a flow to the specified - * [Environment][google.cloud.dialogflow.cx.v3.Environment]. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [DeployFlowMetadata][google.cloud.dialogflow.cx.v3.DeployFlowMetadata] - * - `response`: - * [DeployFlowResponse][google.cloud.dialogflow.cx.v3.DeployFlowResponse] - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedEnvironment = $environmentsClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - * $formattedFlowVersion = $environmentsClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - * $operationResponse = $environmentsClient->deployFlow($formattedEnvironment, $formattedFlowVersion); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $environmentsClient->deployFlow($formattedEnvironment, $formattedFlowVersion); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $environmentsClient->resumeOperation($operationName, 'deployFlow'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $environment Required. The environment to deploy the flow to. - * Format: `projects//locations//agents// - * environments/`. - * @param string $flowVersion Required. The flow version to deploy. - * Format: `projects//locations//agents// - * flows//versions/`. - * @param array $optionalArgs { - * Optional. - * - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function deployFlow($environment, $flowVersion, array $optionalArgs = []) - { - $request = new DeployFlowRequest(); - $requestParamHeaders = []; - $request->setEnvironment($environment); - $request->setFlowVersion($flowVersion); - $requestParamHeaders['environment'] = $environment; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('DeployFlow', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Retrieves the specified - * [Environment][google.cloud.dialogflow.cx.v3.Environment]. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedName = $environmentsClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - * $response = $environmentsClient->getEnvironment($formattedName); - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the - * [Environment][google.cloud.dialogflow.cx.v3.Environment]. Format: - * `projects//locations//agents//environments/`. - * @param array $optionalArgs { - * Optional. - * - * @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\Environment - * - * @throws ApiException if the remote call fails - */ - public function getEnvironment($name, array $optionalArgs = []) - { - $request = new GetEnvironmentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetEnvironment', Environment::class, $optionalArgs, $request)->wait(); - } - - /** - * Fetches a list of continuous test results for a given environment. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedParent = $environmentsClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - * // Iterate over pages of elements - * $pagedResponse = $environmentsClient->listContinuousTestResults($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $environmentsClient->listContinuousTestResults($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The environment to list results for. - * Format: `projects//locations//agents// - * environments/`. - * @param array $optionalArgs { - * Optional. - * - * @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 listContinuousTestResults($parent, array $optionalArgs = []) - { - $request = new ListContinuousTestResultsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - 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('ListContinuousTestResults', $optionalArgs, ListContinuousTestResultsResponse::class, $request); - } - - /** - * Returns the list of all environments in the specified - * [Agent][google.cloud.dialogflow.cx.v3.Agent]. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedParent = $environmentsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * // Iterate over pages of elements - * $pagedResponse = $environmentsClient->listEnvironments($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $environmentsClient->listEnvironments($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The [Agent][google.cloud.dialogflow.cx.v3.Agent] to list all - * environments for. Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @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 listEnvironments($parent, array $optionalArgs = []) - { - $request = new ListEnvironmentsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - 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('ListEnvironments', $optionalArgs, ListEnvironmentsResponse::class, $request); - } - - /** - * Looks up the history of the specified - * [Environment][google.cloud.dialogflow.cx.v3.Environment]. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedName = $environmentsClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - * // Iterate over pages of elements - * $pagedResponse = $environmentsClient->lookupEnvironmentHistory($formattedName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $environmentsClient->lookupEnvironmentHistory($formattedName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the environment to look up the history for. - * Format: `projects//locations//agents//environments/`. - * @param array $optionalArgs { - * Optional. - * - * @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 lookupEnvironmentHistory($name, array $optionalArgs = []) - { - $request = new LookupEnvironmentHistoryRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - 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('LookupEnvironmentHistory', $optionalArgs, LookupEnvironmentHistoryResponse::class, $request); - } - - /** - * Kicks off a continuous test under the specified - * [Environment][google.cloud.dialogflow.cx.v3.Environment]. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [RunContinuousTestMetadata][google.cloud.dialogflow.cx.v3.RunContinuousTestMetadata] - * - `response`: - * [RunContinuousTestResponse][google.cloud.dialogflow.cx.v3.RunContinuousTestResponse] - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $formattedEnvironment = $environmentsClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - * $operationResponse = $environmentsClient->runContinuousTest($formattedEnvironment); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $environmentsClient->runContinuousTest($formattedEnvironment); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $environmentsClient->resumeOperation($operationName, 'runContinuousTest'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param string $environment Required. Format: `projects//locations//agents//environments/`. - * @param array $optionalArgs { - * Optional. - * - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function runContinuousTest($environment, array $optionalArgs = []) - { - $request = new RunContinuousTestRequest(); - $requestParamHeaders = []; - $request->setEnvironment($environment); - $requestParamHeaders['environment'] = $environment; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('RunContinuousTest', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Updates the specified - * [Environment][google.cloud.dialogflow.cx.v3.Environment]. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: [Environment][google.cloud.dialogflow.cx.v3.Environment] - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $environment = new Environment(); - * $updateMask = new FieldMask(); - * $operationResponse = $environmentsClient->updateEnvironment($environment, $updateMask); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $environmentsClient->updateEnvironment($environment, $updateMask); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $environmentsClient->resumeOperation($operationName, 'updateEnvironment'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $environmentsClient->close(); - * } - * ``` - * - * @param Environment $environment Required. The environment to update. - * @param FieldMask $updateMask Required. The mask to control which fields get updated. - * @param array $optionalArgs { - * Optional. - * - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function updateEnvironment($environment, $updateMask, array $optionalArgs = []) - { - $request = new UpdateEnvironmentRequest(); - $requestParamHeaders = []; - $request->setEnvironment($environment); - $request->setUpdateMask($updateMask); - $requestParamHeaders['environment.name'] = $environment->getName(); - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('UpdateEnvironment', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * $response = $environmentsClient->getLocation(); - * } finally { - * $environmentsClient->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: - * ``` - * $environmentsClient = new EnvironmentsClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $environmentsClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $environmentsClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $environmentsClient->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/ExperimentsGapicClient.php b/DialogflowCx/src/V3/Gapic/ExperimentsGapicClient.php deleted file mode 100644 index 29a2475d9aa3..000000000000 --- a/DialogflowCx/src/V3/Gapic/ExperimentsGapicClient.php +++ /dev/null @@ -1,791 +0,0 @@ -environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - * $experiment = new Experiment(); - * $response = $experimentsClient->createExperiment($formattedParent, $experiment); - * } finally { - * $experimentsClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class ExperimentsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.Experiments'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $environmentNameTemplate; - - private static $experimentNameTemplate; - - private static $versionNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/experiments_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/experiments_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/experiments_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/experiments_rest_client_config.php', - ], - ], - ]; - } - - private static function getEnvironmentNameTemplate() - { - if (self::$environmentNameTemplate == null) { - self::$environmentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/environments/{environment}'); - } - - return self::$environmentNameTemplate; - } - - private static function getExperimentNameTemplate() - { - if (self::$experimentNameTemplate == null) { - self::$experimentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/experiments/{experiment}'); - } - - return self::$experimentNameTemplate; - } - - private static function getVersionNameTemplate() - { - if (self::$versionNameTemplate == null) { - self::$versionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}'); - } - - return self::$versionNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'environment' => self::getEnvironmentNameTemplate(), - 'experiment' => self::getExperimentNameTemplate(), - 'version' => self::getVersionNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a environment - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $environment - * - * @return string The formatted environment resource. - */ - public static function environmentName($project, $location, $agent, $environment) - { - return self::getEnvironmentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'environment' => $environment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a experiment - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $environment - * @param string $experiment - * - * @return string The formatted experiment resource. - */ - public static function experimentName($project, $location, $agent, $environment, $experiment) - { - return self::getExperimentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'environment' => $environment, - 'experiment' => $experiment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a version - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $version - * - * @return string The formatted version resource. - */ - public static function versionName($project, $location, $agent, $flow, $version) - { - return self::getVersionNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'version' => $version, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - environment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment} - * - experiment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/experiments/{experiment} - * - version: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version} - * - * 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 an [Experiment][google.cloud.dialogflow.cx.v3.Experiment] in the - * specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. - * - * Sample code: - * ``` - * $experimentsClient = new ExperimentsClient(); - * try { - * $formattedParent = $experimentsClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - * $experiment = new Experiment(); - * $response = $experimentsClient->createExperiment($formattedParent, $experiment); - * } finally { - * $experimentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The [Agent][google.cloud.dialogflow.cx.v3.Agent] to create an - * [Environment][google.cloud.dialogflow.cx.v3.Environment] for. Format: - * `projects//locations//agents//environments/`. - * @param Experiment $experiment Required. The experiment to create. - * @param array $optionalArgs { - * Optional. - * - * @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\Experiment - * - * @throws ApiException if the remote call fails - */ - public function createExperiment($parent, $experiment, array $optionalArgs = []) - { - $request = new CreateExperimentRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setExperiment($experiment); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateExperiment', Experiment::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes the specified - * [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - * - * Sample code: - * ``` - * $experimentsClient = new ExperimentsClient(); - * try { - * $formattedName = $experimentsClient->experimentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[EXPERIMENT]'); - * $experimentsClient->deleteExperiment($formattedName); - * } finally { - * $experimentsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the - * [Environment][google.cloud.dialogflow.cx.v3.Environment] to delete. Format: - * `projects//locations//agents//environments//experiments/`. - * @param array $optionalArgs { - * Optional. - * - * @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 deleteExperiment($name, array $optionalArgs = []) - { - $request = new DeleteExperimentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteExperiment', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Retrieves the specified - * [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - * - * Sample code: - * ``` - * $experimentsClient = new ExperimentsClient(); - * try { - * $formattedName = $experimentsClient->experimentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[EXPERIMENT]'); - * $response = $experimentsClient->getExperiment($formattedName); - * } finally { - * $experimentsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the - * [Environment][google.cloud.dialogflow.cx.v3.Environment]. Format: - * `projects//locations//agents//environments//experiments/`. - * @param array $optionalArgs { - * Optional. - * - * @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\Experiment - * - * @throws ApiException if the remote call fails - */ - public function getExperiment($name, array $optionalArgs = []) - { - $request = new GetExperimentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetExperiment', Experiment::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns the list of all experiments in the specified - * [Environment][google.cloud.dialogflow.cx.v3.Environment]. - * - * Sample code: - * ``` - * $experimentsClient = new ExperimentsClient(); - * try { - * $formattedParent = $experimentsClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - * // Iterate over pages of elements - * $pagedResponse = $experimentsClient->listExperiments($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $experimentsClient->listExperiments($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $experimentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The [Environment][google.cloud.dialogflow.cx.v3.Environment] to - * list all environments for. Format: `projects//locations//agents//environments/`. - * @param array $optionalArgs { - * Optional. - * - * @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 listExperiments($parent, array $optionalArgs = []) - { - $request = new ListExperimentsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - 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('ListExperiments', $optionalArgs, ListExperimentsResponse::class, $request); - } - - /** - * Starts the specified - * [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc only - * changes the state of experiment from PENDING to RUNNING. - * - * Sample code: - * ``` - * $experimentsClient = new ExperimentsClient(); - * try { - * $formattedName = $experimentsClient->experimentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[EXPERIMENT]'); - * $response = $experimentsClient->startExperiment($formattedName); - * } finally { - * $experimentsClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the experiment to start. - * Format: `projects//locations//agents//environments//experiments/`. - * @param array $optionalArgs { - * Optional. - * - * @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\Experiment - * - * @throws ApiException if the remote call fails - */ - public function startExperiment($name, array $optionalArgs = []) - { - $request = new StartExperimentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('StartExperiment', Experiment::class, $optionalArgs, $request)->wait(); - } - - /** - * Stops the specified [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - * This rpc only changes the state of experiment from RUNNING to DONE. - * - * Sample code: - * ``` - * $experimentsClient = new ExperimentsClient(); - * try { - * $formattedName = $experimentsClient->experimentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[EXPERIMENT]'); - * $response = $experimentsClient->stopExperiment($formattedName); - * } finally { - * $experimentsClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the experiment to stop. - * Format: `projects//locations//agents//environments//experiments/`. - * @param array $optionalArgs { - * Optional. - * - * @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\Experiment - * - * @throws ApiException if the remote call fails - */ - public function stopExperiment($name, array $optionalArgs = []) - { - $request = new StopExperimentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('StopExperiment', Experiment::class, $optionalArgs, $request)->wait(); - } - - /** - * Updates the specified - * [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - * - * Sample code: - * ``` - * $experimentsClient = new ExperimentsClient(); - * try { - * $experiment = new Experiment(); - * $updateMask = new FieldMask(); - * $response = $experimentsClient->updateExperiment($experiment, $updateMask); - * } finally { - * $experimentsClient->close(); - * } - * ``` - * - * @param Experiment $experiment Required. The experiment to update. - * @param FieldMask $updateMask Required. The mask to control which fields get updated. - * @param array $optionalArgs { - * Optional. - * - * @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\Experiment - * - * @throws ApiException if the remote call fails - */ - public function updateExperiment($experiment, $updateMask, array $optionalArgs = []) - { - $request = new UpdateExperimentRequest(); - $requestParamHeaders = []; - $request->setExperiment($experiment); - $request->setUpdateMask($updateMask); - $requestParamHeaders['experiment.name'] = $experiment->getName(); - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('UpdateExperiment', Experiment::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $experimentsClient = new ExperimentsClient(); - * try { - * $response = $experimentsClient->getLocation(); - * } finally { - * $experimentsClient->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: - * ``` - * $experimentsClient = new ExperimentsClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $experimentsClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $experimentsClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $experimentsClient->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/FlowsGapicClient.php b/DialogflowCx/src/V3/Gapic/FlowsGapicClient.php deleted file mode 100644 index 86a54fc496d0..000000000000 --- a/DialogflowCx/src/V3/Gapic/FlowsGapicClient.php +++ /dev/null @@ -1,1425 +0,0 @@ -agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $flow = new Flow(); - * $response = $flowsClient->createFlow($formattedParent, $flow); - * } finally { - * $flowsClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class FlowsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.Flows'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $flowNameTemplate; - - private static $flowValidationResultNameTemplate; - - private static $intentNameTemplate; - - private static $pageNameTemplate; - - private static $projectLocationAgentFlowTransitionRouteGroupNameTemplate; - - private static $projectLocationAgentTransitionRouteGroupNameTemplate; - - private static $transitionRouteGroupNameTemplate; - - private static $webhookNameTemplate; - - private static $pathTemplateMap; - - private $operationsClient; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/flows_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/flows_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/flows_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/flows_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 getFlowNameTemplate() - { - if (self::$flowNameTemplate == null) { - self::$flowNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}'); - } - - return self::$flowNameTemplate; - } - - private static function getFlowValidationResultNameTemplate() - { - if (self::$flowValidationResultNameTemplate == null) { - self::$flowValidationResultNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/validationResult'); - } - - return self::$flowValidationResultNameTemplate; - } - - private static function getIntentNameTemplate() - { - if (self::$intentNameTemplate == null) { - self::$intentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/intents/{intent}'); - } - - return self::$intentNameTemplate; - } - - private static function getPageNameTemplate() - { - if (self::$pageNameTemplate == null) { - self::$pageNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}'); - } - - return self::$pageNameTemplate; - } - - private static function getProjectLocationAgentFlowTransitionRouteGroupNameTemplate() - { - if (self::$projectLocationAgentFlowTransitionRouteGroupNameTemplate == null) { - self::$projectLocationAgentFlowTransitionRouteGroupNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}'); - } - - return self::$projectLocationAgentFlowTransitionRouteGroupNameTemplate; - } - - private static function getProjectLocationAgentTransitionRouteGroupNameTemplate() - { - if (self::$projectLocationAgentTransitionRouteGroupNameTemplate == null) { - self::$projectLocationAgentTransitionRouteGroupNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group}'); - } - - return self::$projectLocationAgentTransitionRouteGroupNameTemplate; - } - - private static function getTransitionRouteGroupNameTemplate() - { - if (self::$transitionRouteGroupNameTemplate == null) { - self::$transitionRouteGroupNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}'); - } - - return self::$transitionRouteGroupNameTemplate; - } - - private static function getWebhookNameTemplate() - { - if (self::$webhookNameTemplate == null) { - self::$webhookNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}'); - } - - return self::$webhookNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'agent' => self::getAgentNameTemplate(), - 'flow' => self::getFlowNameTemplate(), - 'flowValidationResult' => self::getFlowValidationResultNameTemplate(), - 'intent' => self::getIntentNameTemplate(), - 'page' => self::getPageNameTemplate(), - 'projectLocationAgentFlowTransitionRouteGroup' => self::getProjectLocationAgentFlowTransitionRouteGroupNameTemplate(), - 'projectLocationAgentTransitionRouteGroup' => self::getProjectLocationAgentTransitionRouteGroupNameTemplate(), - 'transitionRouteGroup' => self::getTransitionRouteGroupNameTemplate(), - 'webhook' => self::getWebhookNameTemplate(), - ]; - } - - 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 flow - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * - * @return string The formatted flow resource. - */ - public static function flowName($project, $location, $agent, $flow) - { - return self::getFlowNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * flow_validation_result resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * - * @return string The formatted flow_validation_result resource. - */ - public static function flowValidationResultName($project, $location, $agent, $flow) - { - return self::getFlowValidationResultNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a intent - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $intent - * - * @return string The formatted intent resource. - */ - public static function intentName($project, $location, $agent, $intent) - { - return self::getIntentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'intent' => $intent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a page - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $page - * - * @return string The formatted page resource. - */ - public static function pageName($project, $location, $agent, $flow, $page) - { - return self::getPageNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'page' => $page, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_flow_transition_route_group resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $transitionRouteGroup - * - * @return string The formatted project_location_agent_flow_transition_route_group resource. - */ - public static function projectLocationAgentFlowTransitionRouteGroupName($project, $location, $agent, $flow, $transitionRouteGroup) - { - return self::getProjectLocationAgentFlowTransitionRouteGroupNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'transition_route_group' => $transitionRouteGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_transition_route_group resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $transitionRouteGroup - * - * @return string The formatted project_location_agent_transition_route_group resource. - */ - public static function projectLocationAgentTransitionRouteGroupName($project, $location, $agent, $transitionRouteGroup) - { - return self::getProjectLocationAgentTransitionRouteGroupNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'transition_route_group' => $transitionRouteGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * transition_route_group resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $transitionRouteGroup - * - * @return string The formatted transition_route_group resource. - */ - public static function transitionRouteGroupName($project, $location, $agent, $flow, $transitionRouteGroup) - { - return self::getTransitionRouteGroupNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'transition_route_group' => $transitionRouteGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a webhook - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $webhook - * - * @return string The formatted webhook resource. - */ - public static function webhookName($project, $location, $agent, $webhook) - { - return self::getWebhookNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'webhook' => $webhook, - ]); - } - - /** - * 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} - * - flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow} - * - flowValidationResult: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/validationResult - * - intent: projects/{project}/locations/{location}/agents/{agent}/intents/{intent} - * - page: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page} - * - projectLocationAgentFlowTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} - * - projectLocationAgentTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group} - * - transitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} - * - webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook} - * - * 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"); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** - * Creates a flow in the specified agent. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $flowsClient = new FlowsClient(); - * try { - * $formattedParent = $flowsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $flow = new Flow(); - * $response = $flowsClient->createFlow($formattedParent, $flow); - * } finally { - * $flowsClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent to create a flow for. - * Format: `projects//locations//agents/`. - * @param Flow $flow Required. The flow to create. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language of the following fields in `flow`: - * - * * `Flow.event_handlers.trigger_fulfillment.messages` - * * `Flow.event_handlers.trigger_fulfillment.conditional_cases` - * * `Flow.transition_routes.trigger_fulfillment.messages` - * * `Flow.transition_routes.trigger_fulfillment.conditional_cases` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\Flow - * - * @throws ApiException if the remote call fails - */ - public function createFlow($parent, $flow, array $optionalArgs = []) - { - $request = new CreateFlowRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setFlow($flow); - $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('CreateFlow', Flow::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes a specified flow. - * - * Sample code: - * ``` - * $flowsClient = new FlowsClient(); - * try { - * $formattedName = $flowsClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * $flowsClient->deleteFlow($formattedName); - * } finally { - * $flowsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the flow to delete. - * Format: `projects//locations//agents//flows/`. - * @param array $optionalArgs { - * Optional. - * - * @type bool $force - * This field has no effect for flows with no incoming transitions. - * For flows with incoming transitions: - * - * * If `force` is set to false, an error will be returned with message - * indicating the incoming transitions. - * * If `force` is set to true, Dialogflow will remove the flow, as well as - * any transitions to the flow (i.e. [Target - * flow][EventHandler.target_flow] in event handlers or [Target - * flow][TransitionRoute.target_flow] in transition routes that point to - * this flow will be cleared). - * @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 deleteFlow($name, array $optionalArgs = []) - { - $request = new DeleteFlowRequest(); - $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('DeleteFlow', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Exports the specified flow to a binary file. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: - * [ExportFlowResponse][google.cloud.dialogflow.cx.v3.ExportFlowResponse] - * - * Note that resources (e.g. intents, entities, webhooks) that the flow - * references will also be exported. - * - * Sample code: - * ``` - * $flowsClient = new FlowsClient(); - * try { - * $formattedName = $flowsClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * $operationResponse = $flowsClient->exportFlow($formattedName); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $flowsClient->exportFlow($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $flowsClient->resumeOperation($operationName, 'exportFlow'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $flowsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the flow to export. - * Format: `projects//locations//agents//flows/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $flowUri - * Optional. The [Google Cloud - * Storage](https://cloud.google.com/storage/docs/) URI to export the flow to. - * The format of this URI must be `gs:///`. If left - * unspecified, the serialized flow is returned inline. - * - * Dialogflow performs a write operation for the Cloud Storage object - * on the caller's behalf, so your request authentication must - * have write permissions for the object. For more information, see - * [Dialogflow access - * control](https://cloud.google.com/dialogflow/cx/docs/concept/access-control#storage). - * @type bool $includeReferencedFlows - * Optional. Whether to export flows referenced by the specified flow. - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function exportFlow($name, array $optionalArgs = []) - { - $request = new ExportFlowRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['flowUri'])) { - $request->setFlowUri($optionalArgs['flowUri']); - } - - if (isset($optionalArgs['includeReferencedFlows'])) { - $request->setIncludeReferencedFlows($optionalArgs['includeReferencedFlows']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ExportFlow', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Retrieves the specified flow. - * - * Sample code: - * ``` - * $flowsClient = new FlowsClient(); - * try { - * $formattedName = $flowsClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * $response = $flowsClient->getFlow($formattedName); - * } finally { - * $flowsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the flow to get. - * Format: `projects//locations//agents//flows/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language to retrieve the flow for. The following fields are language - * dependent: - * - * * `Flow.event_handlers.trigger_fulfillment.messages` - * * `Flow.event_handlers.trigger_fulfillment.conditional_cases` - * * `Flow.transition_routes.trigger_fulfillment.messages` - * * `Flow.transition_routes.trigger_fulfillment.conditional_cases` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\Flow - * - * @throws ApiException if the remote call fails - */ - public function getFlow($name, array $optionalArgs = []) - { - $request = new GetFlowRequest(); - $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('GetFlow', Flow::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets the latest flow validation result. Flow validation is performed - * when ValidateFlow is called. - * - * Sample code: - * ``` - * $flowsClient = new FlowsClient(); - * try { - * $formattedName = $flowsClient->flowValidationResultName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * $response = $flowsClient->getFlowValidationResult($formattedName); - * } finally { - * $flowsClient->close(); - * } - * ``` - * - * @param string $name Required. The flow name. - * Format: `projects//locations//agents//flows//validationResult`. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * 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\FlowValidationResult - * - * @throws ApiException if the remote call fails - */ - public function getFlowValidationResult($name, array $optionalArgs = []) - { - $request = new GetFlowValidationResultRequest(); - $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('GetFlowValidationResult', FlowValidationResult::class, $optionalArgs, $request)->wait(); - } - - /** - * Imports the specified flow to the specified agent from a binary file. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: - * [ImportFlowResponse][google.cloud.dialogflow.cx.v3.ImportFlowResponse] - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $flowsClient = new FlowsClient(); - * try { - * $formattedParent = $flowsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $operationResponse = $flowsClient->importFlow($formattedParent); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $flowsClient->importFlow($formattedParent); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $flowsClient->resumeOperation($operationName, 'importFlow'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $flowsClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent to import the flow into. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $flowUri - * The [Google Cloud Storage](https://cloud.google.com/storage/docs/) URI - * to import flow from. The format of this URI must be - * `gs:///`. - * - * Dialogflow performs a read operation for the Cloud Storage object - * on the caller's behalf, so your request authentication must - * have read permissions for the object. For more information, see - * [Dialogflow access - * control](https://cloud.google.com/dialogflow/cx/docs/concept/access-control#storage). - * @type string $flowContent - * Uncompressed raw byte content for flow. - * @type int $importOption - * Flow import mode. If not specified, `KEEP` is assumed. - * For allowed values, use constants defined on {@see \Google\Cloud\Dialogflow\Cx\V3\ImportFlowRequest\ImportOption} - * @type FlowImportStrategy $flowImportStrategy - * Optional. Specifies the import strategy used when resolving resource - * conflicts. - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function importFlow($parent, array $optionalArgs = []) - { - $request = new ImportFlowRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['flowUri'])) { - $request->setFlowUri($optionalArgs['flowUri']); - } - - if (isset($optionalArgs['flowContent'])) { - $request->setFlowContent($optionalArgs['flowContent']); - } - - if (isset($optionalArgs['importOption'])) { - $request->setImportOption($optionalArgs['importOption']); - } - - if (isset($optionalArgs['flowImportStrategy'])) { - $request->setFlowImportStrategy($optionalArgs['flowImportStrategy']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ImportFlow', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Returns the list of all flows in the specified agent. - * - * Sample code: - * ``` - * $flowsClient = new FlowsClient(); - * try { - * $formattedParent = $flowsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * // Iterate over pages of elements - * $pagedResponse = $flowsClient->listFlows($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $flowsClient->listFlows($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $flowsClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent containing the flows. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @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 string $languageCode - * The language to list flows for. The following fields are language - * dependent: - * - * * `Flow.event_handlers.trigger_fulfillment.messages` - * * `Flow.event_handlers.trigger_fulfillment.conditional_cases` - * * `Flow.transition_routes.trigger_fulfillment.messages` - * * `Flow.transition_routes.trigger_fulfillment.conditional_cases` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listFlows($parent, array $optionalArgs = []) - { - $request = new ListFlowsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - 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->getPagedListResponse('ListFlows', $optionalArgs, ListFlowsResponse::class, $request); - } - - /** - * Trains the specified flow. Note that only the flow in 'draft' environment - * is trained. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $flowsClient = new FlowsClient(); - * try { - * $formattedName = $flowsClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * $operationResponse = $flowsClient->trainFlow($formattedName); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $flowsClient->trainFlow($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $flowsClient->resumeOperation($operationName, 'trainFlow'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $flowsClient->close(); - * } - * ``` - * - * @param string $name Required. The flow to train. - * Format: `projects//locations//agents//flows/`. - * @param array $optionalArgs { - * Optional. - * - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function trainFlow($name, array $optionalArgs = []) - { - $request = new TrainFlowRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('TrainFlow', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Updates the specified flow. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $flowsClient = new FlowsClient(); - * try { - * $flow = new Flow(); - * $response = $flowsClient->updateFlow($flow); - * } finally { - * $flowsClient->close(); - * } - * ``` - * - * @param Flow $flow Required. The flow to update. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The mask to control which fields get updated. If the mask is not present, - * all fields will be updated. - * @type string $languageCode - * The language of the following fields in `flow`: - * - * * `Flow.event_handlers.trigger_fulfillment.messages` - * * `Flow.event_handlers.trigger_fulfillment.conditional_cases` - * * `Flow.transition_routes.trigger_fulfillment.messages` - * * `Flow.transition_routes.trigger_fulfillment.conditional_cases` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\Flow - * - * @throws ApiException if the remote call fails - */ - public function updateFlow($flow, array $optionalArgs = []) - { - $request = new UpdateFlowRequest(); - $requestParamHeaders = []; - $request->setFlow($flow); - $requestParamHeaders['flow.name'] = $flow->getName(); - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - 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('UpdateFlow', Flow::class, $optionalArgs, $request)->wait(); - } - - /** - * Validates the specified flow and creates or updates validation results. - * Please call this API after the training is completed to get the complete - * validation results. - * - * Sample code: - * ``` - * $flowsClient = new FlowsClient(); - * try { - * $formattedName = $flowsClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * $response = $flowsClient->validateFlow($formattedName); - * } finally { - * $flowsClient->close(); - * } - * ``` - * - * @param string $name Required. The flow to validate. - * Format: `projects//locations//agents//flows/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * 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\FlowValidationResult - * - * @throws ApiException if the remote call fails - */ - public function validateFlow($name, array $optionalArgs = []) - { - $request = new ValidateFlowRequest(); - $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('ValidateFlow', FlowValidationResult::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $flowsClient = new FlowsClient(); - * try { - * $response = $flowsClient->getLocation(); - * } finally { - * $flowsClient->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: - * ``` - * $flowsClient = new FlowsClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $flowsClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $flowsClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $flowsClient->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/GeneratorsGapicClient.php b/DialogflowCx/src/V3/Gapic/GeneratorsGapicClient.php deleted file mode 100644 index 03adb5e180fd..000000000000 --- a/DialogflowCx/src/V3/Gapic/GeneratorsGapicClient.php +++ /dev/null @@ -1,696 +0,0 @@ -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. - * - * @deprecated This class will be removed in the next major version update. - */ -class GeneratorsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.Generators'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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/IntentsGapicClient.php b/DialogflowCx/src/V3/Gapic/IntentsGapicClient.php deleted file mode 100644 index 8816dd713d0a..000000000000 --- a/DialogflowCx/src/V3/Gapic/IntentsGapicClient.php +++ /dev/null @@ -1,1020 +0,0 @@ -agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $intent = new Intent(); - * $response = $intentsClient->createIntent($formattedParent, $intent); - * } finally { - * $intentsClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class IntentsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.Intents'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $entityTypeNameTemplate; - - private static $intentNameTemplate; - - private static $pathTemplateMap; - - private $operationsClient; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/intents_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/intents_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/intents_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/intents_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 getEntityTypeNameTemplate() - { - if (self::$entityTypeNameTemplate == null) { - self::$entityTypeNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}'); - } - - return self::$entityTypeNameTemplate; - } - - private static function getIntentNameTemplate() - { - if (self::$intentNameTemplate == null) { - self::$intentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/intents/{intent}'); - } - - return self::$intentNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'agent' => self::getAgentNameTemplate(), - 'entityType' => self::getEntityTypeNameTemplate(), - 'intent' => self::getIntentNameTemplate(), - ]; - } - - 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 entity_type - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $entityType - * - * @return string The formatted entity_type resource. - */ - public static function entityTypeName($project, $location, $agent, $entityType) - { - return self::getEntityTypeNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a intent - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $intent - * - * @return string The formatted intent resource. - */ - public static function intentName($project, $location, $agent, $intent) - { - return self::getIntentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'intent' => $intent, - ]); - } - - /** - * 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} - * - entityType: projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type} - * - intent: projects/{project}/locations/{location}/agents/{agent}/intents/{intent} - * - * 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"); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** - * Creates an intent in the specified agent. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $intentsClient = new IntentsClient(); - * try { - * $formattedParent = $intentsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $intent = new Intent(); - * $response = $intentsClient->createIntent($formattedParent, $intent); - * } finally { - * $intentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent to create an intent for. - * Format: `projects//locations//agents/`. - * @param Intent $intent Required. The intent to create. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language of the following fields in `intent`: - * - * * `Intent.training_phrases.parts.text` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\Intent - * - * @throws ApiException if the remote call fails - */ - public function createIntent($parent, $intent, array $optionalArgs = []) - { - $request = new CreateIntentRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setIntent($intent); - $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('CreateIntent', Intent::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes the specified intent. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $intentsClient = new IntentsClient(); - * try { - * $formattedName = $intentsClient->intentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[INTENT]'); - * $intentsClient->deleteIntent($formattedName); - * } finally { - * $intentsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the intent to delete. - * Format: `projects//locations//agents//intents/`. - * @param array $optionalArgs { - * Optional. - * - * @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 deleteIntent($name, array $optionalArgs = []) - { - $request = new DeleteIntentRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteIntent', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Exports the selected intents. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [ExportIntentsMetadata][google.cloud.dialogflow.cx.v3.ExportIntentsMetadata] - * - `response`: - * [ExportIntentsResponse][google.cloud.dialogflow.cx.v3.ExportIntentsResponse] - * - * Sample code: - * ``` - * $intentsClient = new IntentsClient(); - * try { - * $formattedParent = $intentsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $intents = []; - * $operationResponse = $intentsClient->exportIntents($formattedParent, $intents); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $intentsClient->exportIntents($formattedParent, $intents); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $intentsClient->resumeOperation($operationName, 'exportIntents'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $intentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The name of the parent agent to export intents. - * Format: `projects//locations//agents/`. - * @param string[] $intents Required. The name of the intents to export. - * Format: `projects//locations//agents//intents/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $intentsUri - * Optional. The [Google Cloud - * Storage](https://cloud.google.com/storage/docs/) URI to export the - * intents to. The format of this URI must be - * `gs:///`. - * - * Dialogflow performs a write operation for the Cloud Storage object - * on the caller's behalf, so your request authentication must - * have write permissions for the object. For more information, see - * [Dialogflow access - * control](https://cloud.google.com/dialogflow/cx/docs/concept/access-control#storage). - * @type bool $intentsContentInline - * Optional. The option to return the serialized intents inline. - * @type int $dataFormat - * Optional. The data format of the exported intents. If not specified, `BLOB` - * is assumed. - * For allowed values, use constants defined on {@see \Google\Cloud\Dialogflow\Cx\V3\ExportIntentsRequest\DataFormat} - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function exportIntents($parent, $intents, array $optionalArgs = []) - { - $request = new ExportIntentsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setIntents($intents); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['intentsUri'])) { - $request->setIntentsUri($optionalArgs['intentsUri']); - } - - if (isset($optionalArgs['intentsContentInline'])) { - $request->setIntentsContentInline($optionalArgs['intentsContentInline']); - } - - if (isset($optionalArgs['dataFormat'])) { - $request->setDataFormat($optionalArgs['dataFormat']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ExportIntents', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Retrieves the specified intent. - * - * Sample code: - * ``` - * $intentsClient = new IntentsClient(); - * try { - * $formattedName = $intentsClient->intentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[INTENT]'); - * $response = $intentsClient->getIntent($formattedName); - * } finally { - * $intentsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the intent. - * Format: `projects//locations//agents//intents/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language to retrieve the intent for. The following fields are language - * dependent: - * - * * `Intent.training_phrases.parts.text` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\Intent - * - * @throws ApiException if the remote call fails - */ - public function getIntent($name, array $optionalArgs = []) - { - $request = new GetIntentRequest(); - $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('GetIntent', Intent::class, $optionalArgs, $request)->wait(); - } - - /** - * Imports the specified intents into the agent. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [ImportIntentsMetadata][google.cloud.dialogflow.cx.v3.ImportIntentsMetadata] - * - `response`: - * [ImportIntentsResponse][google.cloud.dialogflow.cx.v3.ImportIntentsResponse] - * - * Sample code: - * ``` - * $intentsClient = new IntentsClient(); - * try { - * $formattedParent = $intentsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $operationResponse = $intentsClient->importIntents($formattedParent); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $intentsClient->importIntents($formattedParent); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $intentsClient->resumeOperation($operationName, 'importIntents'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $intentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent to import the intents into. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $intentsUri - * The [Google Cloud Storage](https://cloud.google.com/storage/docs/) URI - * to import intents from. The format of this URI must be - * `gs:///`. - * - * Dialogflow performs a read operation for the Cloud Storage object - * on the caller's behalf, so your request authentication must - * have read permissions for the object. For more information, see - * [Dialogflow access - * control](https://cloud.google.com/dialogflow/cx/docs/concept/access-control#storage). - * @type InlineSource $intentsContent - * Uncompressed byte content of intents. - * @type int $mergeOption - * Merge option for importing intents. If not specified, `REJECT` is assumed. - * For allowed values, use constants defined on {@see \Google\Cloud\Dialogflow\Cx\V3\ImportIntentsRequest\MergeOption} - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function importIntents($parent, array $optionalArgs = []) - { - $request = new ImportIntentsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['intentsUri'])) { - $request->setIntentsUri($optionalArgs['intentsUri']); - } - - if (isset($optionalArgs['intentsContent'])) { - $request->setIntentsContent($optionalArgs['intentsContent']); - } - - if (isset($optionalArgs['mergeOption'])) { - $request->setMergeOption($optionalArgs['mergeOption']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ImportIntents', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Returns the list of all intents in the specified agent. - * - * Sample code: - * ``` - * $intentsClient = new IntentsClient(); - * try { - * $formattedParent = $intentsClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * // Iterate over pages of elements - * $pagedResponse = $intentsClient->listIntents($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $intentsClient->listIntents($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $intentsClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent to list all intents for. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language to list intents for. The following fields are language - * dependent: - * - * * `Intent.training_phrases.parts.text` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be used. - * @type int $intentView - * The resource view to apply to the returned intent. - * For allowed values, use constants defined on {@see \Google\Cloud\Dialogflow\Cx\V3\IntentView} - * @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 listIntents($parent, array $optionalArgs = []) - { - $request = new ListIntentsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['languageCode'])) { - $request->setLanguageCode($optionalArgs['languageCode']); - } - - if (isset($optionalArgs['intentView'])) { - $request->setIntentView($optionalArgs['intentView']); - } - - 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('ListIntents', $optionalArgs, ListIntentsResponse::class, $request); - } - - /** - * Updates the specified intent. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $intentsClient = new IntentsClient(); - * try { - * $intent = new Intent(); - * $response = $intentsClient->updateIntent($intent); - * } finally { - * $intentsClient->close(); - * } - * ``` - * - * @param Intent $intent Required. The intent to update. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language of the following fields in `intent`: - * - * * `Intent.training_phrases.parts.text` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be used. - * @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\Intent - * - * @throws ApiException if the remote call fails - */ - public function updateIntent($intent, array $optionalArgs = []) - { - $request = new UpdateIntentRequest(); - $requestParamHeaders = []; - $request->setIntent($intent); - $requestParamHeaders['intent.name'] = $intent->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('UpdateIntent', Intent::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $intentsClient = new IntentsClient(); - * try { - * $response = $intentsClient->getLocation(); - * } finally { - * $intentsClient->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: - * ``` - * $intentsClient = new IntentsClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $intentsClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $intentsClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $intentsClient->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/PagesGapicClient.php b/DialogflowCx/src/V3/Gapic/PagesGapicClient.php deleted file mode 100644 index 2acce077a37b..000000000000 --- a/DialogflowCx/src/V3/Gapic/PagesGapicClient.php +++ /dev/null @@ -1,1000 +0,0 @@ -flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * $page = new Page(); - * $response = $pagesClient->createPage($formattedParent, $page); - * } finally { - * $pagesClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class PagesGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.Pages'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $entityTypeNameTemplate; - - private static $flowNameTemplate; - - private static $intentNameTemplate; - - private static $pageNameTemplate; - - private static $projectLocationAgentFlowTransitionRouteGroupNameTemplate; - - private static $projectLocationAgentTransitionRouteGroupNameTemplate; - - private static $transitionRouteGroupNameTemplate; - - private static $webhookNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/pages_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/pages_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/pages_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/pages_rest_client_config.php', - ], - ], - ]; - } - - private static function getEntityTypeNameTemplate() - { - if (self::$entityTypeNameTemplate == null) { - self::$entityTypeNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}'); - } - - return self::$entityTypeNameTemplate; - } - - private static function getFlowNameTemplate() - { - if (self::$flowNameTemplate == null) { - self::$flowNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}'); - } - - return self::$flowNameTemplate; - } - - private static function getIntentNameTemplate() - { - if (self::$intentNameTemplate == null) { - self::$intentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/intents/{intent}'); - } - - return self::$intentNameTemplate; - } - - private static function getPageNameTemplate() - { - if (self::$pageNameTemplate == null) { - self::$pageNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}'); - } - - return self::$pageNameTemplate; - } - - private static function getProjectLocationAgentFlowTransitionRouteGroupNameTemplate() - { - if (self::$projectLocationAgentFlowTransitionRouteGroupNameTemplate == null) { - self::$projectLocationAgentFlowTransitionRouteGroupNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}'); - } - - return self::$projectLocationAgentFlowTransitionRouteGroupNameTemplate; - } - - private static function getProjectLocationAgentTransitionRouteGroupNameTemplate() - { - if (self::$projectLocationAgentTransitionRouteGroupNameTemplate == null) { - self::$projectLocationAgentTransitionRouteGroupNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group}'); - } - - return self::$projectLocationAgentTransitionRouteGroupNameTemplate; - } - - private static function getTransitionRouteGroupNameTemplate() - { - if (self::$transitionRouteGroupNameTemplate == null) { - self::$transitionRouteGroupNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}'); - } - - return self::$transitionRouteGroupNameTemplate; - } - - private static function getWebhookNameTemplate() - { - if (self::$webhookNameTemplate == null) { - self::$webhookNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}'); - } - - return self::$webhookNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'entityType' => self::getEntityTypeNameTemplate(), - 'flow' => self::getFlowNameTemplate(), - 'intent' => self::getIntentNameTemplate(), - 'page' => self::getPageNameTemplate(), - 'projectLocationAgentFlowTransitionRouteGroup' => self::getProjectLocationAgentFlowTransitionRouteGroupNameTemplate(), - 'projectLocationAgentTransitionRouteGroup' => self::getProjectLocationAgentTransitionRouteGroupNameTemplate(), - 'transitionRouteGroup' => self::getTransitionRouteGroupNameTemplate(), - 'webhook' => self::getWebhookNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a entity_type - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $entityType - * - * @return string The formatted entity_type resource. - */ - public static function entityTypeName($project, $location, $agent, $entityType) - { - return self::getEntityTypeNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a flow - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * - * @return string The formatted flow resource. - */ - public static function flowName($project, $location, $agent, $flow) - { - return self::getFlowNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a intent - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $intent - * - * @return string The formatted intent resource. - */ - public static function intentName($project, $location, $agent, $intent) - { - return self::getIntentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'intent' => $intent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a page - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $page - * - * @return string The formatted page resource. - */ - public static function pageName($project, $location, $agent, $flow, $page) - { - return self::getPageNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'page' => $page, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_flow_transition_route_group resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $transitionRouteGroup - * - * @return string The formatted project_location_agent_flow_transition_route_group resource. - */ - public static function projectLocationAgentFlowTransitionRouteGroupName($project, $location, $agent, $flow, $transitionRouteGroup) - { - return self::getProjectLocationAgentFlowTransitionRouteGroupNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'transition_route_group' => $transitionRouteGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_transition_route_group resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $transitionRouteGroup - * - * @return string The formatted project_location_agent_transition_route_group resource. - */ - public static function projectLocationAgentTransitionRouteGroupName($project, $location, $agent, $transitionRouteGroup) - { - return self::getProjectLocationAgentTransitionRouteGroupNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'transition_route_group' => $transitionRouteGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * transition_route_group resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $transitionRouteGroup - * - * @return string The formatted transition_route_group resource. - */ - public static function transitionRouteGroupName($project, $location, $agent, $flow, $transitionRouteGroup) - { - return self::getTransitionRouteGroupNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'transition_route_group' => $transitionRouteGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a webhook - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $webhook - * - * @return string The formatted webhook resource. - */ - public static function webhookName($project, $location, $agent, $webhook) - { - return self::getWebhookNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'webhook' => $webhook, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - entityType: projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type} - * - flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow} - * - intent: projects/{project}/locations/{location}/agents/{agent}/intents/{intent} - * - page: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page} - * - projectLocationAgentFlowTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} - * - projectLocationAgentTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group} - * - transitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} - * - webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook} - * - * 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 page in the specified flow. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $pagesClient = new PagesClient(); - * try { - * $formattedParent = $pagesClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * $page = new Page(); - * $response = $pagesClient->createPage($formattedParent, $page); - * } finally { - * $pagesClient->close(); - * } - * ``` - * - * @param string $parent Required. The flow to create a page for. - * Format: `projects//locations//agents//flows/`. - * @param Page $page Required. The page to create. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language of the following fields in `page`: - * - * * `Page.entry_fulfillment.messages` - * * `Page.entry_fulfillment.conditional_cases` - * * `Page.event_handlers.trigger_fulfillment.messages` - * * `Page.event_handlers.trigger_fulfillment.conditional_cases` - * * `Page.form.parameters.fill_behavior.initial_prompt_fulfillment.messages` - * * - * `Page.form.parameters.fill_behavior.initial_prompt_fulfillment.conditional_cases` - * * `Page.form.parameters.fill_behavior.reprompt_event_handlers.messages` - * * - * `Page.form.parameters.fill_behavior.reprompt_event_handlers.conditional_cases` - * * `Page.transition_routes.trigger_fulfillment.messages` - * * `Page.transition_routes.trigger_fulfillment.conditional_cases` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\Page - * - * @throws ApiException if the remote call fails - */ - public function createPage($parent, $page, array $optionalArgs = []) - { - $request = new CreatePageRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setPage($page); - $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('CreatePage', Page::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes the specified page. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $pagesClient = new PagesClient(); - * try { - * $formattedName = $pagesClient->pageName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[PAGE]'); - * $pagesClient->deletePage($formattedName); - * } finally { - * $pagesClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the page to delete. - * Format: `projects//locations//agents//Flows//pages/`. - * @param array $optionalArgs { - * Optional. - * - * @type bool $force - * This field has no effect for pages with no incoming transitions. - * For pages with incoming transitions: - * - * * If `force` is set to false, an error will be returned with message - * indicating the incoming transitions. - * * If `force` is set to true, Dialogflow will remove the page, as well as - * any transitions to the page (i.e. [Target - * page][EventHandler.target_page] in event handlers or [Target - * page][TransitionRoute.target_page] in transition routes that point to - * this page will be cleared). - * @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 deletePage($name, array $optionalArgs = []) - { - $request = new DeletePageRequest(); - $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('DeletePage', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Retrieves the specified page. - * - * Sample code: - * ``` - * $pagesClient = new PagesClient(); - * try { - * $formattedName = $pagesClient->pageName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[PAGE]'); - * $response = $pagesClient->getPage($formattedName); - * } finally { - * $pagesClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the page. - * Format: `projects//locations//agents//flows//pages/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language to retrieve the page for. The following fields are language - * dependent: - * - * * `Page.entry_fulfillment.messages` - * * `Page.entry_fulfillment.conditional_cases` - * * `Page.event_handlers.trigger_fulfillment.messages` - * * `Page.event_handlers.trigger_fulfillment.conditional_cases` - * * `Page.form.parameters.fill_behavior.initial_prompt_fulfillment.messages` - * * - * `Page.form.parameters.fill_behavior.initial_prompt_fulfillment.conditional_cases` - * * `Page.form.parameters.fill_behavior.reprompt_event_handlers.messages` - * * - * `Page.form.parameters.fill_behavior.reprompt_event_handlers.conditional_cases` - * * `Page.transition_routes.trigger_fulfillment.messages` - * * `Page.transition_routes.trigger_fulfillment.conditional_cases` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\Page - * - * @throws ApiException if the remote call fails - */ - public function getPage($name, array $optionalArgs = []) - { - $request = new GetPageRequest(); - $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('GetPage', Page::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns the list of all pages in the specified flow. - * - * Sample code: - * ``` - * $pagesClient = new PagesClient(); - * try { - * $formattedParent = $pagesClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * // Iterate over pages of elements - * $pagedResponse = $pagesClient->listPages($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $pagesClient->listPages($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $pagesClient->close(); - * } - * ``` - * - * @param string $parent Required. The flow to list all pages for. - * Format: `projects//locations//agents//flows/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language to list pages for. The following fields are language - * dependent: - * - * * `Page.entry_fulfillment.messages` - * * `Page.entry_fulfillment.conditional_cases` - * * `Page.event_handlers.trigger_fulfillment.messages` - * * `Page.event_handlers.trigger_fulfillment.conditional_cases` - * * `Page.form.parameters.fill_behavior.initial_prompt_fulfillment.messages` - * * - * `Page.form.parameters.fill_behavior.initial_prompt_fulfillment.conditional_cases` - * * `Page.form.parameters.fill_behavior.reprompt_event_handlers.messages` - * * - * `Page.form.parameters.fill_behavior.reprompt_event_handlers.conditional_cases` - * * `Page.transition_routes.trigger_fulfillment.messages` - * * `Page.transition_routes.trigger_fulfillment.conditional_cases` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be used. - * @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 listPages($parent, array $optionalArgs = []) - { - $request = new ListPagesRequest(); - $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('ListPages', $optionalArgs, ListPagesResponse::class, $request); - } - - /** - * Updates the specified page. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $pagesClient = new PagesClient(); - * try { - * $page = new Page(); - * $response = $pagesClient->updatePage($page); - * } finally { - * $pagesClient->close(); - * } - * ``` - * - * @param Page $page Required. The page to update. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language of the following fields in `page`: - * - * * `Page.entry_fulfillment.messages` - * * `Page.entry_fulfillment.conditional_cases` - * * `Page.event_handlers.trigger_fulfillment.messages` - * * `Page.event_handlers.trigger_fulfillment.conditional_cases` - * * `Page.form.parameters.fill_behavior.initial_prompt_fulfillment.messages` - * * - * `Page.form.parameters.fill_behavior.initial_prompt_fulfillment.conditional_cases` - * * `Page.form.parameters.fill_behavior.reprompt_event_handlers.messages` - * * - * `Page.form.parameters.fill_behavior.reprompt_event_handlers.conditional_cases` - * * `Page.transition_routes.trigger_fulfillment.messages` - * * `Page.transition_routes.trigger_fulfillment.conditional_cases` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be used. - * @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\Page - * - * @throws ApiException if the remote call fails - */ - public function updatePage($page, array $optionalArgs = []) - { - $request = new UpdatePageRequest(); - $requestParamHeaders = []; - $request->setPage($page); - $requestParamHeaders['page.name'] = $page->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('UpdatePage', Page::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $pagesClient = new PagesClient(); - * try { - * $response = $pagesClient->getLocation(); - * } finally { - * $pagesClient->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: - * ``` - * $pagesClient = new PagesClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $pagesClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $pagesClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $pagesClient->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/SecuritySettingsServiceGapicClient.php b/DialogflowCx/src/V3/Gapic/SecuritySettingsServiceGapicClient.php deleted file mode 100644 index aa53d39fd70f..000000000000 --- a/DialogflowCx/src/V3/Gapic/SecuritySettingsServiceGapicClient.php +++ /dev/null @@ -1,849 +0,0 @@ -locationName('[PROJECT]', '[LOCATION]'); - * $securitySettings = new SecuritySettings(); - * $response = $securitySettingsServiceClient->createSecuritySettings($formattedParent, $securitySettings); - * } finally { - * $securitySettingsServiceClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class SecuritySettingsServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.SecuritySettingsService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $deidentifyTemplateNameTemplate; - - private static $inspectTemplateNameTemplate; - - private static $locationNameTemplate; - - private static $organizationLocationDeidentifyTemplateNameTemplate; - - private static $organizationLocationInspectTemplateNameTemplate; - - private static $projectLocationDeidentifyTemplateNameTemplate; - - private static $projectLocationInspectTemplateNameTemplate; - - private static $securitySettingsNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/security_settings_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/security_settings_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/security_settings_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/security_settings_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getDeidentifyTemplateNameTemplate() - { - if (self::$deidentifyTemplateNameTemplate == null) { - self::$deidentifyTemplateNameTemplate = new PathTemplate('organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template}'); - } - - return self::$deidentifyTemplateNameTemplate; - } - - private static function getInspectTemplateNameTemplate() - { - if (self::$inspectTemplateNameTemplate == null) { - self::$inspectTemplateNameTemplate = new PathTemplate('organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template}'); - } - - return self::$inspectTemplateNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); - } - - return self::$locationNameTemplate; - } - - private static function getOrganizationLocationDeidentifyTemplateNameTemplate() - { - if (self::$organizationLocationDeidentifyTemplateNameTemplate == null) { - self::$organizationLocationDeidentifyTemplateNameTemplate = new PathTemplate('organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template}'); - } - - return self::$organizationLocationDeidentifyTemplateNameTemplate; - } - - private static function getOrganizationLocationInspectTemplateNameTemplate() - { - if (self::$organizationLocationInspectTemplateNameTemplate == null) { - self::$organizationLocationInspectTemplateNameTemplate = new PathTemplate('organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template}'); - } - - return self::$organizationLocationInspectTemplateNameTemplate; - } - - private static function getProjectLocationDeidentifyTemplateNameTemplate() - { - if (self::$projectLocationDeidentifyTemplateNameTemplate == null) { - self::$projectLocationDeidentifyTemplateNameTemplate = new PathTemplate('projects/{project}/locations/{location}/deidentifyTemplates/{deidentify_template}'); - } - - return self::$projectLocationDeidentifyTemplateNameTemplate; - } - - private static function getProjectLocationInspectTemplateNameTemplate() - { - if (self::$projectLocationInspectTemplateNameTemplate == null) { - self::$projectLocationInspectTemplateNameTemplate = new PathTemplate('projects/{project}/locations/{location}/inspectTemplates/{inspect_template}'); - } - - return self::$projectLocationInspectTemplateNameTemplate; - } - - private static function getSecuritySettingsNameTemplate() - { - if (self::$securitySettingsNameTemplate == null) { - self::$securitySettingsNameTemplate = new PathTemplate('projects/{project}/locations/{location}/securitySettings/{security_settings}'); - } - - return self::$securitySettingsNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'deidentifyTemplate' => self::getDeidentifyTemplateNameTemplate(), - 'inspectTemplate' => self::getInspectTemplateNameTemplate(), - 'location' => self::getLocationNameTemplate(), - 'organizationLocationDeidentifyTemplate' => self::getOrganizationLocationDeidentifyTemplateNameTemplate(), - 'organizationLocationInspectTemplate' => self::getOrganizationLocationInspectTemplateNameTemplate(), - 'projectLocationDeidentifyTemplate' => self::getProjectLocationDeidentifyTemplateNameTemplate(), - 'projectLocationInspectTemplate' => self::getProjectLocationInspectTemplateNameTemplate(), - 'securitySettings' => self::getSecuritySettingsNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * deidentify_template resource. - * - * @param string $organization - * @param string $location - * @param string $deidentifyTemplate - * - * @return string The formatted deidentify_template resource. - */ - public static function deidentifyTemplateName($organization, $location, $deidentifyTemplate) - { - return self::getDeidentifyTemplateNameTemplate()->render([ - 'organization' => $organization, - 'location' => $location, - 'deidentify_template' => $deidentifyTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * inspect_template resource. - * - * @param string $organization - * @param string $location - * @param string $inspectTemplate - * - * @return string The formatted inspect_template resource. - */ - public static function inspectTemplateName($organization, $location, $inspectTemplate) - { - return self::getInspectTemplateNameTemplate()->render([ - 'organization' => $organization, - 'location' => $location, - 'inspect_template' => $inspectTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName($project, $location) - { - return self::getLocationNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_deidentify_template resource. - * - * @param string $organization - * @param string $location - * @param string $deidentifyTemplate - * - * @return string The formatted organization_location_deidentify_template resource. - */ - public static function organizationLocationDeidentifyTemplateName($organization, $location, $deidentifyTemplate) - { - return self::getOrganizationLocationDeidentifyTemplateNameTemplate()->render([ - 'organization' => $organization, - 'location' => $location, - 'deidentify_template' => $deidentifyTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_inspect_template resource. - * - * @param string $organization - * @param string $location - * @param string $inspectTemplate - * - * @return string The formatted organization_location_inspect_template resource. - */ - public static function organizationLocationInspectTemplateName($organization, $location, $inspectTemplate) - { - return self::getOrganizationLocationInspectTemplateNameTemplate()->render([ - 'organization' => $organization, - 'location' => $location, - 'inspect_template' => $inspectTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_deidentify_template resource. - * - * @param string $project - * @param string $location - * @param string $deidentifyTemplate - * - * @return string The formatted project_location_deidentify_template resource. - */ - public static function projectLocationDeidentifyTemplateName($project, $location, $deidentifyTemplate) - { - return self::getProjectLocationDeidentifyTemplateNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'deidentify_template' => $deidentifyTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_inspect_template resource. - * - * @param string $project - * @param string $location - * @param string $inspectTemplate - * - * @return string The formatted project_location_inspect_template resource. - */ - public static function projectLocationInspectTemplateName($project, $location, $inspectTemplate) - { - return self::getProjectLocationInspectTemplateNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'inspect_template' => $inspectTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * security_settings resource. - * - * @param string $project - * @param string $location - * @param string $securitySettings - * - * @return string The formatted security_settings resource. - */ - public static function securitySettingsName($project, $location, $securitySettings) - { - return self::getSecuritySettingsNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'security_settings' => $securitySettings, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - deidentifyTemplate: organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template} - * - inspectTemplate: organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template} - * - location: projects/{project}/locations/{location} - * - organizationLocationDeidentifyTemplate: organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template} - * - organizationLocationInspectTemplate: organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template} - * - projectLocationDeidentifyTemplate: projects/{project}/locations/{location}/deidentifyTemplates/{deidentify_template} - * - projectLocationInspectTemplate: projects/{project}/locations/{location}/inspectTemplates/{inspect_template} - * - securitySettings: projects/{project}/locations/{location}/securitySettings/{security_settings} - * - * 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); - } - - /** - * Create security settings in the specified location. - * - * Sample code: - * ``` - * $securitySettingsServiceClient = new SecuritySettingsServiceClient(); - * try { - * $formattedParent = $securitySettingsServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * $securitySettings = new SecuritySettings(); - * $response = $securitySettingsServiceClient->createSecuritySettings($formattedParent, $securitySettings); - * } finally { - * $securitySettingsServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The location to create an - * [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings] for. - * Format: `projects//locations/`. - * @param SecuritySettings $securitySettings Required. The security settings to create. - * @param array $optionalArgs { - * Optional. - * - * @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\SecuritySettings - * - * @throws ApiException if the remote call fails - */ - public function createSecuritySettings($parent, $securitySettings, array $optionalArgs = []) - { - $request = new CreateSecuritySettingsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setSecuritySettings($securitySettings); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateSecuritySettings', SecuritySettings::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes the specified - * [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - * - * Sample code: - * ``` - * $securitySettingsServiceClient = new SecuritySettingsServiceClient(); - * try { - * $formattedName = $securitySettingsServiceClient->securitySettingsName('[PROJECT]', '[LOCATION]', '[SECURITY_SETTINGS]'); - * $securitySettingsServiceClient->deleteSecuritySettings($formattedName); - * } finally { - * $securitySettingsServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the - * [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings] to - * delete. Format: `projects//locations//securitySettings/`. - * @param array $optionalArgs { - * Optional. - * - * @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 deleteSecuritySettings($name, array $optionalArgs = []) - { - $request = new DeleteSecuritySettingsRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteSecuritySettings', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Retrieves the specified - * [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. The - * returned settings may be stale by up to 1 minute. - * - * Sample code: - * ``` - * $securitySettingsServiceClient = new SecuritySettingsServiceClient(); - * try { - * $formattedName = $securitySettingsServiceClient->securitySettingsName('[PROJECT]', '[LOCATION]', '[SECURITY_SETTINGS]'); - * $response = $securitySettingsServiceClient->getSecuritySettings($formattedName); - * } finally { - * $securitySettingsServiceClient->close(); - * } - * ``` - * - * @param string $name Required. Resource name of the settings. - * Format: `projects//locations//securitySettings/`. - * @param array $optionalArgs { - * Optional. - * - * @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\SecuritySettings - * - * @throws ApiException if the remote call fails - */ - public function getSecuritySettings($name, array $optionalArgs = []) - { - $request = new GetSecuritySettingsRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetSecuritySettings', SecuritySettings::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns the list of all security settings in the specified location. - * - * Sample code: - * ``` - * $securitySettingsServiceClient = new SecuritySettingsServiceClient(); - * try { - * $formattedParent = $securitySettingsServiceClient->locationName('[PROJECT]', '[LOCATION]'); - * // Iterate over pages of elements - * $pagedResponse = $securitySettingsServiceClient->listSecuritySettings($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $securitySettingsServiceClient->listSecuritySettings($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $securitySettingsServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The location to list all security settings for. - * Format: `projects//locations/`. - * @param array $optionalArgs { - * Optional. - * - * @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 listSecuritySettings($parent, array $optionalArgs = []) - { - $request = new ListSecuritySettingsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - 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('ListSecuritySettings', $optionalArgs, ListSecuritySettingsResponse::class, $request); - } - - /** - * Updates the specified - * [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - * - * Sample code: - * ``` - * $securitySettingsServiceClient = new SecuritySettingsServiceClient(); - * try { - * $securitySettings = new SecuritySettings(); - * $updateMask = new FieldMask(); - * $response = $securitySettingsServiceClient->updateSecuritySettings($securitySettings, $updateMask); - * } finally { - * $securitySettingsServiceClient->close(); - * } - * ``` - * - * @param SecuritySettings $securitySettings Required. [SecuritySettings] object that contains values for each of the - * fields to update. - * @param FieldMask $updateMask Required. The mask to control which fields get updated. If the mask is not - * present, all fields will be updated. - * @param array $optionalArgs { - * Optional. - * - * @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\SecuritySettings - * - * @throws ApiException if the remote call fails - */ - public function updateSecuritySettings($securitySettings, $updateMask, array $optionalArgs = []) - { - $request = new UpdateSecuritySettingsRequest(); - $requestParamHeaders = []; - $request->setSecuritySettings($securitySettings); - $request->setUpdateMask($updateMask); - $requestParamHeaders['security_settings.name'] = $securitySettings->getName(); - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('UpdateSecuritySettings', SecuritySettings::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $securitySettingsServiceClient = new SecuritySettingsServiceClient(); - * try { - * $response = $securitySettingsServiceClient->getLocation(); - * } finally { - * $securitySettingsServiceClient->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: - * ``` - * $securitySettingsServiceClient = new SecuritySettingsServiceClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $securitySettingsServiceClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $securitySettingsServiceClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $securitySettingsServiceClient->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/SessionEntityTypesGapicClient.php b/DialogflowCx/src/V3/Gapic/SessionEntityTypesGapicClient.php deleted file mode 100644 index c8d9dd08d504..000000000000 --- a/DialogflowCx/src/V3/Gapic/SessionEntityTypesGapicClient.php +++ /dev/null @@ -1,827 +0,0 @@ -sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); - * $sessionEntityType = new SessionEntityType(); - * $response = $sessionEntityTypesClient->createSessionEntityType($formattedParent, $sessionEntityType); - * } finally { - * $sessionEntityTypesClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class SessionEntityTypesGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.SessionEntityTypes'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $projectLocationAgentEnvironmentSessionNameTemplate; - - private static $projectLocationAgentEnvironmentSessionEntityTypeNameTemplate; - - private static $projectLocationAgentSessionNameTemplate; - - private static $projectLocationAgentSessionEntityTypeNameTemplate; - - private static $sessionNameTemplate; - - private static $sessionEntityTypeNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/session_entity_types_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/session_entity_types_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/session_entity_types_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/session_entity_types_rest_client_config.php', - ], - ], - ]; - } - - private static function getProjectLocationAgentEnvironmentSessionNameTemplate() - { - if (self::$projectLocationAgentEnvironmentSessionNameTemplate == null) { - self::$projectLocationAgentEnvironmentSessionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/sessions/{session}'); - } - - return self::$projectLocationAgentEnvironmentSessionNameTemplate; - } - - private static function getProjectLocationAgentEnvironmentSessionEntityTypeNameTemplate() - { - if (self::$projectLocationAgentEnvironmentSessionEntityTypeNameTemplate == null) { - self::$projectLocationAgentEnvironmentSessionEntityTypeNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/sessions/{session}/entityTypes/{entity_type}'); - } - - return self::$projectLocationAgentEnvironmentSessionEntityTypeNameTemplate; - } - - private static function getProjectLocationAgentSessionNameTemplate() - { - if (self::$projectLocationAgentSessionNameTemplate == null) { - self::$projectLocationAgentSessionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/sessions/{session}'); - } - - return self::$projectLocationAgentSessionNameTemplate; - } - - private static function getProjectLocationAgentSessionEntityTypeNameTemplate() - { - if (self::$projectLocationAgentSessionEntityTypeNameTemplate == null) { - self::$projectLocationAgentSessionEntityTypeNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/sessions/{session}/entityTypes/{entity_type}'); - } - - return self::$projectLocationAgentSessionEntityTypeNameTemplate; - } - - private static function getSessionNameTemplate() - { - if (self::$sessionNameTemplate == null) { - self::$sessionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/sessions/{session}'); - } - - return self::$sessionNameTemplate; - } - - private static function getSessionEntityTypeNameTemplate() - { - if (self::$sessionEntityTypeNameTemplate == null) { - self::$sessionEntityTypeNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/sessions/{session}/entityTypes/{entity_type}'); - } - - return self::$sessionEntityTypeNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'projectLocationAgentEnvironmentSession' => self::getProjectLocationAgentEnvironmentSessionNameTemplate(), - 'projectLocationAgentEnvironmentSessionEntityType' => self::getProjectLocationAgentEnvironmentSessionEntityTypeNameTemplate(), - 'projectLocationAgentSession' => self::getProjectLocationAgentSessionNameTemplate(), - 'projectLocationAgentSessionEntityType' => self::getProjectLocationAgentSessionEntityTypeNameTemplate(), - 'session' => self::getSessionNameTemplate(), - 'sessionEntityType' => self::getSessionEntityTypeNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_environment_session resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $environment - * @param string $session - * - * @return string The formatted project_location_agent_environment_session resource. - */ - public static function projectLocationAgentEnvironmentSessionName($project, $location, $agent, $environment, $session) - { - return self::getProjectLocationAgentEnvironmentSessionNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'environment' => $environment, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_environment_session_entity_type resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $environment - * @param string $session - * @param string $entityType - * - * @return string The formatted project_location_agent_environment_session_entity_type resource. - */ - public static function projectLocationAgentEnvironmentSessionEntityTypeName($project, $location, $agent, $environment, $session, $entityType) - { - return self::getProjectLocationAgentEnvironmentSessionEntityTypeNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'environment' => $environment, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_session resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $session - * - * @return string The formatted project_location_agent_session resource. - */ - public static function projectLocationAgentSessionName($project, $location, $agent, $session) - { - return self::getProjectLocationAgentSessionNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_session_entity_type resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $session - * @param string $entityType - * - * @return string The formatted project_location_agent_session_entity_type resource. - */ - public static function projectLocationAgentSessionEntityTypeName($project, $location, $agent, $session, $entityType) - { - return self::getProjectLocationAgentSessionEntityTypeNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a session - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $session - * - * @return string The formatted session resource. - */ - public static function sessionName($project, $location, $agent, $session) - { - return self::getSessionNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * session_entity_type resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $session - * @param string $entityType - * - * @return string The formatted session_entity_type resource. - */ - public static function sessionEntityTypeName($project, $location, $agent, $session, $entityType) - { - return self::getSessionEntityTypeNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - projectLocationAgentEnvironmentSession: projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/sessions/{session} - * - 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} - * - session: projects/{project}/locations/{location}/agents/{agent}/sessions/{session} - * - sessionEntityType: projects/{project}/locations/{location}/agents/{agent}/sessions/{session}/entityTypes/{entity_type} - * - * 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 session entity type. - * - * Sample code: - * ``` - * $sessionEntityTypesClient = new SessionEntityTypesClient(); - * try { - * $formattedParent = $sessionEntityTypesClient->sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); - * $sessionEntityType = new SessionEntityType(); - * $response = $sessionEntityTypesClient->createSessionEntityType($formattedParent, $sessionEntityType); - * } finally { - * $sessionEntityTypesClient->close(); - * } - * ``` - * - * @param string $parent Required. The session to create a session entity type for. - * Format: `projects//locations//agents//sessions/` or `projects//locations//agents//environments//sessions/`. - * If `Environment ID` is not specified, we assume default 'draft' - * environment. - * @param SessionEntityType $sessionEntityType Required. The session entity type to create. - * @param array $optionalArgs { - * Optional. - * - * @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\SessionEntityType - * - * @throws ApiException if the remote call fails - */ - public function createSessionEntityType($parent, $sessionEntityType, array $optionalArgs = []) - { - $request = new CreateSessionEntityTypeRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setSessionEntityType($sessionEntityType); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateSessionEntityType', SessionEntityType::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes the specified session entity type. - * - * Sample code: - * ``` - * $sessionEntityTypesClient = new SessionEntityTypesClient(); - * try { - * $formattedName = $sessionEntityTypesClient->sessionEntityTypeName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]', '[ENTITY_TYPE]'); - * $sessionEntityTypesClient->deleteSessionEntityType($formattedName); - * } finally { - * $sessionEntityTypesClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the session entity type to delete. - * Format: `projects//locations//agents//sessions//entityTypes/` or - * `projects//locations//agents//environments//sessions//entityTypes/`. If `Environment ID` is not specified, we assume default 'draft' - * environment. - * @param array $optionalArgs { - * Optional. - * - * @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 deleteSessionEntityType($name, array $optionalArgs = []) - { - $request = new DeleteSessionEntityTypeRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteSessionEntityType', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Retrieves the specified session entity type. - * - * Sample code: - * ``` - * $sessionEntityTypesClient = new SessionEntityTypesClient(); - * try { - * $formattedName = $sessionEntityTypesClient->sessionEntityTypeName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]', '[ENTITY_TYPE]'); - * $response = $sessionEntityTypesClient->getSessionEntityType($formattedName); - * } finally { - * $sessionEntityTypesClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the session entity type. - * Format: `projects//locations//agents//sessions//entityTypes/` or - * `projects//locations//agents//environments//sessions//entityTypes/`. If `Environment ID` is not specified, we assume default 'draft' - * environment. - * @param array $optionalArgs { - * Optional. - * - * @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\SessionEntityType - * - * @throws ApiException if the remote call fails - */ - public function getSessionEntityType($name, array $optionalArgs = []) - { - $request = new GetSessionEntityTypeRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetSessionEntityType', SessionEntityType::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns the list of all session entity types in the specified session. - * - * Sample code: - * ``` - * $sessionEntityTypesClient = new SessionEntityTypesClient(); - * try { - * $formattedParent = $sessionEntityTypesClient->sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); - * // Iterate over pages of elements - * $pagedResponse = $sessionEntityTypesClient->listSessionEntityTypes($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $sessionEntityTypesClient->listSessionEntityTypes($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $sessionEntityTypesClient->close(); - * } - * ``` - * - * @param string $parent Required. The session to list all session entity types from. - * Format: `projects//locations//agents//sessions/` or `projects//locations//agents//environments//sessions/`. - * If `Environment ID` is not specified, we assume default 'draft' - * environment. - * @param array $optionalArgs { - * Optional. - * - * @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 listSessionEntityTypes($parent, array $optionalArgs = []) - { - $request = new ListSessionEntityTypesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - 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('ListSessionEntityTypes', $optionalArgs, ListSessionEntityTypesResponse::class, $request); - } - - /** - * Updates the specified session entity type. - * - * Sample code: - * ``` - * $sessionEntityTypesClient = new SessionEntityTypesClient(); - * try { - * $sessionEntityType = new SessionEntityType(); - * $response = $sessionEntityTypesClient->updateSessionEntityType($sessionEntityType); - * } finally { - * $sessionEntityTypesClient->close(); - * } - * ``` - * - * @param SessionEntityType $sessionEntityType Required. The session entity type to update. - * Format: `projects//locations//agents//sessions//entityTypes/` or - * `projects//locations//agents//environments//sessions//entityTypes/`. If `Environment ID` is not specified, we assume default 'draft' - * environment. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The mask to control which fields get 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\SessionEntityType - * - * @throws ApiException if the remote call fails - */ - public function updateSessionEntityType($sessionEntityType, array $optionalArgs = []) - { - $request = new UpdateSessionEntityTypeRequest(); - $requestParamHeaders = []; - $request->setSessionEntityType($sessionEntityType); - $requestParamHeaders['session_entity_type.name'] = $sessionEntityType->getName(); - 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('UpdateSessionEntityType', SessionEntityType::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $sessionEntityTypesClient = new SessionEntityTypesClient(); - * try { - * $response = $sessionEntityTypesClient->getLocation(); - * } finally { - * $sessionEntityTypesClient->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: - * ``` - * $sessionEntityTypesClient = new SessionEntityTypesClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $sessionEntityTypesClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $sessionEntityTypesClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $sessionEntityTypesClient->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 deleted file mode 100644 index 0f28b13214e7..000000000000 --- a/DialogflowCx/src/V3/Gapic/SessionsGapicClient.php +++ /dev/null @@ -1,1169 +0,0 @@ -sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); - * $queryInput = new QueryInput(); - * $response = $sessionsClient->detectIntent($formattedSession, $queryInput); - * } finally { - * $sessionsClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class SessionsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.Sessions'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $dataStoreNameTemplate; - - private static $entityTypeNameTemplate; - - private static $intentNameTemplate; - - private static $pageNameTemplate; - - private static $projectLocationAgentEnvironmentSessionNameTemplate; - - private static $projectLocationAgentEnvironmentSessionEntityTypeNameTemplate; - - private static $projectLocationAgentSessionNameTemplate; - - private static $projectLocationAgentSessionEntityTypeNameTemplate; - - private static $projectLocationCollectionDataStoreNameTemplate; - - private static $projectLocationDataStoreNameTemplate; - - private static $sessionNameTemplate; - - private static $sessionEntityTypeNameTemplate; - - private static $versionNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/sessions_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/sessions_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/sessions_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/sessions_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 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) { - self::$entityTypeNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}'); - } - - return self::$entityTypeNameTemplate; - } - - private static function getIntentNameTemplate() - { - if (self::$intentNameTemplate == null) { - self::$intentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/intents/{intent}'); - } - - return self::$intentNameTemplate; - } - - private static function getPageNameTemplate() - { - if (self::$pageNameTemplate == null) { - self::$pageNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}'); - } - - return self::$pageNameTemplate; - } - - private static function getProjectLocationAgentEnvironmentSessionNameTemplate() - { - if (self::$projectLocationAgentEnvironmentSessionNameTemplate == null) { - self::$projectLocationAgentEnvironmentSessionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/sessions/{session}'); - } - - return self::$projectLocationAgentEnvironmentSessionNameTemplate; - } - - private static function getProjectLocationAgentEnvironmentSessionEntityTypeNameTemplate() - { - if (self::$projectLocationAgentEnvironmentSessionEntityTypeNameTemplate == null) { - self::$projectLocationAgentEnvironmentSessionEntityTypeNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/sessions/{session}/entityTypes/{entity_type}'); - } - - return self::$projectLocationAgentEnvironmentSessionEntityTypeNameTemplate; - } - - private static function getProjectLocationAgentSessionNameTemplate() - { - if (self::$projectLocationAgentSessionNameTemplate == null) { - self::$projectLocationAgentSessionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/sessions/{session}'); - } - - return self::$projectLocationAgentSessionNameTemplate; - } - - private static function getProjectLocationAgentSessionEntityTypeNameTemplate() - { - if (self::$projectLocationAgentSessionEntityTypeNameTemplate == null) { - self::$projectLocationAgentSessionEntityTypeNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/sessions/{session}/entityTypes/{entity_type}'); - } - - 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) { - self::$sessionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/sessions/{session}'); - } - - return self::$sessionNameTemplate; - } - - private static function getSessionEntityTypeNameTemplate() - { - if (self::$sessionEntityTypeNameTemplate == null) { - self::$sessionEntityTypeNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/sessions/{session}/entityTypes/{entity_type}'); - } - - return self::$sessionEntityTypeNameTemplate; - } - - private static function getVersionNameTemplate() - { - if (self::$versionNameTemplate == null) { - self::$versionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}'); - } - - return self::$versionNameTemplate; - } - - 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(), - 'projectLocationAgentEnvironmentSession' => self::getProjectLocationAgentEnvironmentSessionNameTemplate(), - 'projectLocationAgentEnvironmentSessionEntityType' => self::getProjectLocationAgentEnvironmentSessionEntityTypeNameTemplate(), - 'projectLocationAgentSession' => self::getProjectLocationAgentSessionNameTemplate(), - 'projectLocationAgentSessionEntityType' => self::getProjectLocationAgentSessionEntityTypeNameTemplate(), - 'projectLocationCollectionDataStore' => self::getProjectLocationCollectionDataStoreNameTemplate(), - 'projectLocationDataStore' => self::getProjectLocationDataStoreNameTemplate(), - 'session' => self::getSessionNameTemplate(), - 'sessionEntityType' => self::getSessionEntityTypeNameTemplate(), - 'version' => self::getVersionNameTemplate(), - ]; - } - - 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 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. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $entityType - * - * @return string The formatted entity_type resource. - */ - public static function entityTypeName($project, $location, $agent, $entityType) - { - return self::getEntityTypeNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a intent - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $intent - * - * @return string The formatted intent resource. - */ - public static function intentName($project, $location, $agent, $intent) - { - return self::getIntentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'intent' => $intent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a page - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $page - * - * @return string The formatted page resource. - */ - public static function pageName($project, $location, $agent, $flow, $page) - { - return self::getPageNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'page' => $page, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_environment_session resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $environment - * @param string $session - * - * @return string The formatted project_location_agent_environment_session resource. - */ - public static function projectLocationAgentEnvironmentSessionName($project, $location, $agent, $environment, $session) - { - return self::getProjectLocationAgentEnvironmentSessionNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'environment' => $environment, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_environment_session_entity_type resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $environment - * @param string $session - * @param string $entityType - * - * @return string The formatted project_location_agent_environment_session_entity_type resource. - */ - public static function projectLocationAgentEnvironmentSessionEntityTypeName($project, $location, $agent, $environment, $session, $entityType) - { - return self::getProjectLocationAgentEnvironmentSessionEntityTypeNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'environment' => $environment, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_session resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $session - * - * @return string The formatted project_location_agent_session resource. - */ - public static function projectLocationAgentSessionName($project, $location, $agent, $session) - { - return self::getProjectLocationAgentSessionNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_session_entity_type resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $session - * @param string $entityType - * - * @return string The formatted project_location_agent_session_entity_type resource. - */ - public static function projectLocationAgentSessionEntityTypeName($project, $location, $agent, $session, $entityType) - { - return self::getProjectLocationAgentSessionEntityTypeNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * 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. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $session - * - * @return string The formatted session resource. - */ - public static function sessionName($project, $location, $agent, $session) - { - return self::getSessionNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * session_entity_type resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $session - * @param string $entityType - * - * @return string The formatted session_entity_type resource. - */ - public static function sessionEntityTypeName($project, $location, $agent, $session, $entityType) - { - return self::getSessionEntityTypeNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a version - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $version - * - * @return string The formatted version resource. - */ - public static function versionName($project, $location, $agent, $flow, $version) - { - return self::getVersionNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'version' => $version, - ]); - } - - /** - * 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} - * - 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} - * - projectLocationAgentEnvironmentSession: projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/sessions/{session} - * - 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} - * - * 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); - } - - /** - * Processes a natural language query and returns structured, actionable data - * as a result. This method is not idempotent, because it may cause session - * entity types to be updated, which in turn might affect results of future - * queries. - * - * Note: Always use agent versions for production traffic. - * See [Versions and - * environments](https://cloud.google.com/dialogflow/cx/docs/concept/version). - * - * Sample code: - * ``` - * $sessionsClient = new SessionsClient(); - * try { - * $formattedSession = $sessionsClient->sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); - * $queryInput = new QueryInput(); - * $response = $sessionsClient->detectIntent($formattedSession, $queryInput); - * } finally { - * $sessionsClient->close(); - * } - * ``` - * - * @param string $session Required. The name of the session this query is sent to. - * Format: `projects//locations//agents//sessions/` or `projects//locations//agents//environments//sessions/`. - * If `Environment ID` is not specified, we assume default 'draft' - * environment. - * It's up to the API caller to choose an appropriate `Session ID`. It can be - * a random number or some type of session identifiers (preferably hashed). - * The length of the `Session ID` must not exceed 36 characters. - * - * For more information, see the [sessions - * guide](https://cloud.google.com/dialogflow/cx/docs/concept/session). - * - * Note: Always use agent versions for production traffic. - * See [Versions and - * environments](https://cloud.google.com/dialogflow/cx/docs/concept/version). - * @param QueryInput $queryInput Required. The input specification. - * @param array $optionalArgs { - * Optional. - * - * @type QueryParameters $queryParams - * The parameters of this query. - * @type OutputAudioConfig $outputAudioConfig - * Instructs the speech synthesizer how to generate the output audio. - * @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\DetectIntentResponse - * - * @throws ApiException if the remote call fails - */ - public function detectIntent($session, $queryInput, array $optionalArgs = []) - { - $request = new DetectIntentRequest(); - $requestParamHeaders = []; - $request->setSession($session); - $request->setQueryInput($queryInput); - $requestParamHeaders['session'] = $session; - if (isset($optionalArgs['queryParams'])) { - $request->setQueryParams($optionalArgs['queryParams']); - } - - if (isset($optionalArgs['outputAudioConfig'])) { - $request->setOutputAudioConfig($optionalArgs['outputAudioConfig']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DetectIntent', DetectIntentResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Fulfills a matched intent returned by - * [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent]. Must be - * called after - * [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent], with - * input from - * [MatchIntentResponse][google.cloud.dialogflow.cx.v3.MatchIntentResponse]. - * Otherwise, the behavior is undefined. - * - * Sample code: - * ``` - * $sessionsClient = new SessionsClient(); - * try { - * $response = $sessionsClient->fulfillIntent(); - * } finally { - * $sessionsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type MatchIntentRequest $matchIntentRequest - * Must be same as the corresponding MatchIntent request, otherwise the - * behavior is undefined. - * @type PBMatch $match - * The matched intent/event to fulfill. - * @type OutputAudioConfig $outputAudioConfig - * Instructs the speech synthesizer how to generate output audio. - * @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\FulfillIntentResponse - * - * @throws ApiException if the remote call fails - */ - public function fulfillIntent(array $optionalArgs = []) - { - $request = new FulfillIntentRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['matchIntentRequest'])) { - $request->setMatchIntentRequest($optionalArgs['matchIntentRequest']); - } - - if (isset($optionalArgs['match'])) { - $request->setMatch($optionalArgs['match']); - } - - if (isset($optionalArgs['outputAudioConfig'])) { - $request->setOutputAudioConfig($optionalArgs['outputAudioConfig']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('FulfillIntent', FulfillIntentResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns preliminary intent match results, doesn't change the session - * status. - * - * Sample code: - * ``` - * $sessionsClient = new SessionsClient(); - * try { - * $formattedSession = $sessionsClient->sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); - * $queryInput = new QueryInput(); - * $response = $sessionsClient->matchIntent($formattedSession, $queryInput); - * } finally { - * $sessionsClient->close(); - * } - * ``` - * - * @param string $session Required. The name of the session this query is sent to. - * Format: `projects//locations//agents//sessions/` or `projects//locations//agents//environments//sessions/`. - * If `Environment ID` is not specified, we assume default 'draft' - * environment. - * It's up to the API caller to choose an appropriate `Session ID`. It can be - * a random number or some type of session identifiers (preferably hashed). - * The length of the `Session ID` must not exceed 36 characters. - * - * For more information, see the [sessions - * guide](https://cloud.google.com/dialogflow/cx/docs/concept/session). - * @param QueryInput $queryInput Required. The input specification. - * @param array $optionalArgs { - * Optional. - * - * @type QueryParameters $queryParams - * The parameters of this query. - * @type bool $persistParameterChanges - * Persist session parameter changes from `query_params`. - * @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\MatchIntentResponse - * - * @throws ApiException if the remote call fails - */ - public function matchIntent($session, $queryInput, array $optionalArgs = []) - { - $request = new MatchIntentRequest(); - $requestParamHeaders = []; - $request->setSession($session); - $request->setQueryInput($queryInput); - $requestParamHeaders['session'] = $session; - if (isset($optionalArgs['queryParams'])) { - $request->setQueryParams($optionalArgs['queryParams']); - } - - if (isset($optionalArgs['persistParameterChanges'])) { - $request->setPersistParameterChanges($optionalArgs['persistParameterChanges']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('MatchIntent', MatchIntentResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Processes a natural language query in audio format in a streaming fashion - * and returns structured, actionable data as a result. This method is only - * available via the gRPC API (not REST). - * - * Note: Always use agent versions for production traffic. - * See [Versions and - * environments](https://cloud.google.com/dialogflow/cx/docs/concept/version). - * - * Sample code: - * ``` - * $sessionsClient = new SessionsClient(); - * try { - * $queryInput = new QueryInput(); - * $request = new StreamingDetectIntentRequest(); - * $request->setQueryInput($queryInput); - * // Write all requests to the server, then read all responses until the - * // stream is complete - * $requests = [ - * $request, - * ]; - * $stream = $sessionsClient->streamingDetectIntent(); - * $stream->writeAll($requests); - * foreach ($stream->closeWriteAndReadAll() as $element) { - * // doSomethingWith($element); - * } - * // Alternatively: - * // Write requests individually, making read() calls if - * // required. Call closeWrite() once writes are complete, and read the - * // remaining responses from the server. - * $requests = [ - * $request, - * ]; - * $stream = $sessionsClient->streamingDetectIntent(); - * foreach ($requests as $request) { - * $stream->write($request); - * // if required, read a single response from the stream - * $element = $stream->read(); - * // doSomethingWith($element) - * } - * $stream->closeWrite(); - * $element = $stream->read(); - * while (!is_null($element)) { - * // doSomethingWith($element) - * $element = $stream->read(); - * } - * } finally { - * $sessionsClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return \Google\ApiCore\BidiStream - * - * @throws ApiException if the remote call fails - */ - 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. - * - * Sample code: - * ``` - * $sessionsClient = new SessionsClient(); - * try { - * $response = $sessionsClient->getLocation(); - * } finally { - * $sessionsClient->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: - * ``` - * $sessionsClient = new SessionsClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $sessionsClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $sessionsClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $sessionsClient->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/TestCasesGapicClient.php b/DialogflowCx/src/V3/Gapic/TestCasesGapicClient.php deleted file mode 100644 index 35dd9dc06617..000000000000 --- a/DialogflowCx/src/V3/Gapic/TestCasesGapicClient.php +++ /dev/null @@ -1,1638 +0,0 @@ -agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $formattedNames = [ - * $testCasesClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'), - * ]; - * $testCasesClient->batchDeleteTestCases($formattedParent, $formattedNames); - * } finally { - * $testCasesClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class TestCasesGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.TestCases'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $entityTypeNameTemplate; - - private static $environmentNameTemplate; - - private static $flowNameTemplate; - - private static $intentNameTemplate; - - private static $pageNameTemplate; - - private static $projectLocationAgentFlowTransitionRouteGroupNameTemplate; - - private static $projectLocationAgentTransitionRouteGroupNameTemplate; - - private static $testCaseNameTemplate; - - private static $testCaseResultNameTemplate; - - private static $transitionRouteGroupNameTemplate; - - private static $webhookNameTemplate; - - private static $pathTemplateMap; - - private $operationsClient; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/test_cases_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/test_cases_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/test_cases_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/test_cases_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 getEntityTypeNameTemplate() - { - if (self::$entityTypeNameTemplate == null) { - self::$entityTypeNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}'); - } - - return self::$entityTypeNameTemplate; - } - - private static function getEnvironmentNameTemplate() - { - if (self::$environmentNameTemplate == null) { - self::$environmentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/environments/{environment}'); - } - - return self::$environmentNameTemplate; - } - - private static function getFlowNameTemplate() - { - if (self::$flowNameTemplate == null) { - self::$flowNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}'); - } - - return self::$flowNameTemplate; - } - - private static function getIntentNameTemplate() - { - if (self::$intentNameTemplate == null) { - self::$intentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/intents/{intent}'); - } - - return self::$intentNameTemplate; - } - - private static function getPageNameTemplate() - { - if (self::$pageNameTemplate == null) { - self::$pageNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}'); - } - - return self::$pageNameTemplate; - } - - private static function getProjectLocationAgentFlowTransitionRouteGroupNameTemplate() - { - if (self::$projectLocationAgentFlowTransitionRouteGroupNameTemplate == null) { - self::$projectLocationAgentFlowTransitionRouteGroupNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}'); - } - - return self::$projectLocationAgentFlowTransitionRouteGroupNameTemplate; - } - - private static function getProjectLocationAgentTransitionRouteGroupNameTemplate() - { - if (self::$projectLocationAgentTransitionRouteGroupNameTemplate == null) { - self::$projectLocationAgentTransitionRouteGroupNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group}'); - } - - return self::$projectLocationAgentTransitionRouteGroupNameTemplate; - } - - private static function getTestCaseNameTemplate() - { - if (self::$testCaseNameTemplate == null) { - self::$testCaseNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}'); - } - - return self::$testCaseNameTemplate; - } - - private static function getTestCaseResultNameTemplate() - { - if (self::$testCaseResultNameTemplate == null) { - self::$testCaseResultNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}/results/{result}'); - } - - return self::$testCaseResultNameTemplate; - } - - private static function getTransitionRouteGroupNameTemplate() - { - if (self::$transitionRouteGroupNameTemplate == null) { - self::$transitionRouteGroupNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}'); - } - - return self::$transitionRouteGroupNameTemplate; - } - - private static function getWebhookNameTemplate() - { - if (self::$webhookNameTemplate == null) { - self::$webhookNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}'); - } - - return self::$webhookNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'agent' => self::getAgentNameTemplate(), - 'entityType' => self::getEntityTypeNameTemplate(), - 'environment' => self::getEnvironmentNameTemplate(), - 'flow' => self::getFlowNameTemplate(), - 'intent' => self::getIntentNameTemplate(), - 'page' => self::getPageNameTemplate(), - 'projectLocationAgentFlowTransitionRouteGroup' => self::getProjectLocationAgentFlowTransitionRouteGroupNameTemplate(), - 'projectLocationAgentTransitionRouteGroup' => self::getProjectLocationAgentTransitionRouteGroupNameTemplate(), - 'testCase' => self::getTestCaseNameTemplate(), - 'testCaseResult' => self::getTestCaseResultNameTemplate(), - 'transitionRouteGroup' => self::getTransitionRouteGroupNameTemplate(), - 'webhook' => self::getWebhookNameTemplate(), - ]; - } - - 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 entity_type - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $entityType - * - * @return string The formatted entity_type resource. - */ - public static function entityTypeName($project, $location, $agent, $entityType) - { - return self::getEntityTypeNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a environment - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $environment - * - * @return string The formatted environment resource. - */ - public static function environmentName($project, $location, $agent, $environment) - { - return self::getEnvironmentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'environment' => $environment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a flow - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * - * @return string The formatted flow resource. - */ - public static function flowName($project, $location, $agent, $flow) - { - return self::getFlowNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a intent - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $intent - * - * @return string The formatted intent resource. - */ - public static function intentName($project, $location, $agent, $intent) - { - return self::getIntentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'intent' => $intent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a page - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $page - * - * @return string The formatted page resource. - */ - public static function pageName($project, $location, $agent, $flow, $page) - { - return self::getPageNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'page' => $page, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_flow_transition_route_group resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $transitionRouteGroup - * - * @return string The formatted project_location_agent_flow_transition_route_group resource. - */ - public static function projectLocationAgentFlowTransitionRouteGroupName($project, $location, $agent, $flow, $transitionRouteGroup) - { - return self::getProjectLocationAgentFlowTransitionRouteGroupNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'transition_route_group' => $transitionRouteGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_transition_route_group resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $transitionRouteGroup - * - * @return string The formatted project_location_agent_transition_route_group resource. - */ - public static function projectLocationAgentTransitionRouteGroupName($project, $location, $agent, $transitionRouteGroup) - { - return self::getProjectLocationAgentTransitionRouteGroupNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'transition_route_group' => $transitionRouteGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a test_case - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $testCase - * - * @return string The formatted test_case resource. - */ - public static function testCaseName($project, $location, $agent, $testCase) - { - return self::getTestCaseNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'test_case' => $testCase, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * test_case_result resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $testCase - * @param string $result - * - * @return string The formatted test_case_result resource. - */ - public static function testCaseResultName($project, $location, $agent, $testCase, $result) - { - return self::getTestCaseResultNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'test_case' => $testCase, - 'result' => $result, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * transition_route_group resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $transitionRouteGroup - * - * @return string The formatted transition_route_group resource. - */ - public static function transitionRouteGroupName($project, $location, $agent, $flow, $transitionRouteGroup) - { - return self::getTransitionRouteGroupNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'transition_route_group' => $transitionRouteGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a webhook - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $webhook - * - * @return string The formatted webhook resource. - */ - public static function webhookName($project, $location, $agent, $webhook) - { - return self::getWebhookNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'webhook' => $webhook, - ]); - } - - /** - * 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} - * - entityType: projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type} - * - environment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment} - * - flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow} - * - intent: projects/{project}/locations/{location}/agents/{agent}/intents/{intent} - * - page: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page} - * - projectLocationAgentFlowTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} - * - projectLocationAgentTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group} - * - testCase: projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case} - * - testCaseResult: projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}/results/{result} - * - transitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} - * - webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook} - * - * 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"); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** - * Batch deletes test cases. - * - * Sample code: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * $formattedParent = $testCasesClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $formattedNames = [ - * $testCasesClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'), - * ]; - * $testCasesClient->batchDeleteTestCases($formattedParent, $formattedNames); - * } finally { - * $testCasesClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent to delete test cases from. - * Format: `projects//locations//agents/`. - * @param string[] $names Required. Format of test case names: `projects//locations/ - * /agents//testCases/`. - * @param array $optionalArgs { - * Optional. - * - * @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 batchDeleteTestCases($parent, $names, array $optionalArgs = []) - { - $request = new BatchDeleteTestCasesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setNames($names); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('BatchDeleteTestCases', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Kicks off a batch run of test cases. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [BatchRunTestCasesMetadata][google.cloud.dialogflow.cx.v3.BatchRunTestCasesMetadata] - * - `response`: - * [BatchRunTestCasesResponse][google.cloud.dialogflow.cx.v3.BatchRunTestCasesResponse] - * - * Sample code: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * $formattedParent = $testCasesClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $formattedTestCases = [ - * $testCasesClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'), - * ]; - * $operationResponse = $testCasesClient->batchRunTestCases($formattedParent, $formattedTestCases); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $testCasesClient->batchRunTestCases($formattedParent, $formattedTestCases); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $testCasesClient->resumeOperation($operationName, 'batchRunTestCases'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $testCasesClient->close(); - * } - * ``` - * - * @param string $parent Required. Agent name. Format: `projects//locations//agents/ `. - * @param string[] $testCases Required. Format: `projects//locations//agents//testCases/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $environment - * Optional. If not set, draft environment is assumed. Format: - * `projects//locations//agents//environments/`. - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function batchRunTestCases($parent, $testCases, array $optionalArgs = []) - { - $request = new BatchRunTestCasesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setTestCases($testCases); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['environment'])) { - $request->setEnvironment($optionalArgs['environment']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('BatchRunTestCases', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Calculates the test coverage for an agent. - * - * Sample code: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * $formattedAgent = $testCasesClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $type = CoverageType::COVERAGE_TYPE_UNSPECIFIED; - * $response = $testCasesClient->calculateCoverage($formattedAgent, $type); - * } finally { - * $testCasesClient->close(); - * } - * ``` - * - * @param string $agent Required. The agent to calculate coverage for. - * Format: `projects//locations//agents/`. - * @param int $type Required. The type of coverage requested. - * For allowed values, use constants defined on {@see \Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageRequest\CoverageType} - * @param array $optionalArgs { - * Optional. - * - * @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\CalculateCoverageResponse - * - * @throws ApiException if the remote call fails - */ - public function calculateCoverage($agent, $type, array $optionalArgs = []) - { - $request = new CalculateCoverageRequest(); - $requestParamHeaders = []; - $request->setAgent($agent); - $request->setType($type); - $requestParamHeaders['agent'] = $agent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CalculateCoverage', CalculateCoverageResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Creates a test case for the given agent. - * - * Sample code: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * $formattedParent = $testCasesClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $testCase = new TestCase(); - * $response = $testCasesClient->createTestCase($formattedParent, $testCase); - * } finally { - * $testCasesClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent to create the test case for. - * Format: `projects//locations//agents/`. - * @param TestCase $testCase Required. The test case to create. - * @param array $optionalArgs { - * Optional. - * - * @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\TestCase - * - * @throws ApiException if the remote call fails - */ - public function createTestCase($parent, $testCase, array $optionalArgs = []) - { - $request = new CreateTestCaseRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setTestCase($testCase); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateTestCase', TestCase::class, $optionalArgs, $request)->wait(); - } - - /** - * Exports the test cases under the agent to a Cloud Storage bucket or a local - * file. Filter can be applied to export a subset of test cases. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [ExportTestCasesMetadata][google.cloud.dialogflow.cx.v3.ExportTestCasesMetadata] - * - `response`: - * [ExportTestCasesResponse][google.cloud.dialogflow.cx.v3.ExportTestCasesResponse] - * - * Sample code: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * $formattedParent = $testCasesClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $operationResponse = $testCasesClient->exportTestCases($formattedParent); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $testCasesClient->exportTestCases($formattedParent); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $testCasesClient->resumeOperation($operationName, 'exportTestCases'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $testCasesClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent where to export test cases from. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $gcsUri - * The [Google Cloud Storage](https://cloud.google.com/storage/docs/) URI to - * export the test cases to. The format of this URI must be - * `gs:///`. If unspecified, the serialized test - * cases is returned inline. - * - * Dialogflow performs a write operation for the Cloud Storage object - * on the caller's behalf, so your request authentication must - * have write permissions for the object. For more information, see - * [Dialogflow access - * control](https://cloud.google.com/dialogflow/cx/docs/concept/access-control#storage). - * @type int $dataFormat - * The data format of the exported test cases. If not specified, `BLOB` is - * assumed. - * For allowed values, use constants defined on {@see \Google\Cloud\Dialogflow\Cx\V3\ExportTestCasesRequest\DataFormat} - * @type string $filter - * The filter expression used to filter exported test cases, see - * [API Filtering](https://aip.dev/160). The expression is case insensitive - * and supports the following syntax: - * - * name = [OR name = ] ... - * - * For example: - * - * * "name = t1 OR name = t2" matches the test case with the exact resource - * name "t1" or "t2". - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function exportTestCases($parent, array $optionalArgs = []) - { - $request = new ExportTestCasesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['gcsUri'])) { - $request->setGcsUri($optionalArgs['gcsUri']); - } - - if (isset($optionalArgs['dataFormat'])) { - $request->setDataFormat($optionalArgs['dataFormat']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ExportTestCases', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Gets a test case. - * - * Sample code: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * $formattedName = $testCasesClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'); - * $response = $testCasesClient->getTestCase($formattedName); - * } finally { - * $testCasesClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the testcase. - * Format: `projects//locations//agents//testCases/`. - * @param array $optionalArgs { - * Optional. - * - * @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\TestCase - * - * @throws ApiException if the remote call fails - */ - public function getTestCase($name, array $optionalArgs = []) - { - $request = new GetTestCaseRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetTestCase', TestCase::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets a test case result. - * - * Sample code: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * $formattedName = $testCasesClient->testCaseResultName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]', '[RESULT]'); - * $response = $testCasesClient->getTestCaseResult($formattedName); - * } finally { - * $testCasesClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the testcase. - * Format: `projects//locations//agents//testCases//results/`. - * @param array $optionalArgs { - * Optional. - * - * @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\TestCaseResult - * - * @throws ApiException if the remote call fails - */ - public function getTestCaseResult($name, array $optionalArgs = []) - { - $request = new GetTestCaseResultRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetTestCaseResult', TestCaseResult::class, $optionalArgs, $request)->wait(); - } - - /** - * Imports the test cases from a Cloud Storage bucket or a local file. It - * always creates new test cases and won't overwrite any existing ones. The - * provided ID in the imported test case is neglected. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [ImportTestCasesMetadata][google.cloud.dialogflow.cx.v3.ImportTestCasesMetadata] - * - `response`: - * [ImportTestCasesResponse][google.cloud.dialogflow.cx.v3.ImportTestCasesResponse] - * - * Sample code: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * $formattedParent = $testCasesClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $operationResponse = $testCasesClient->importTestCases($formattedParent); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $testCasesClient->importTestCases($formattedParent); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $testCasesClient->resumeOperation($operationName, 'importTestCases'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $testCasesClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent to import test cases to. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $gcsUri - * The [Google Cloud Storage](https://cloud.google.com/storage/docs/) URI - * to import test cases from. The format of this URI must be - * `gs:///`. - * - * Dialogflow performs a read operation for the Cloud Storage object - * on the caller's behalf, so your request authentication must - * have read permissions for the object. For more information, see - * [Dialogflow access - * control](https://cloud.google.com/dialogflow/cx/docs/concept/access-control#storage). - * @type string $content - * Uncompressed raw byte content for test cases. - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function importTestCases($parent, array $optionalArgs = []) - { - $request = new ImportTestCasesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['gcsUri'])) { - $request->setGcsUri($optionalArgs['gcsUri']); - } - - if (isset($optionalArgs['content'])) { - $request->setContent($optionalArgs['content']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('ImportTestCases', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Fetches the list of run results for the given test case. A maximum of 100 - * results are kept for each test case. - * - * Sample code: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * $formattedParent = $testCasesClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'); - * // Iterate over pages of elements - * $pagedResponse = $testCasesClient->listTestCaseResults($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $testCasesClient->listTestCaseResults($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $testCasesClient->close(); - * } - * ``` - * - * @param string $parent Required. The test case to list results for. - * Format: `projects//locations//agents// - * testCases/`. Specify a `-` as a wildcard for TestCase ID to - * list results across multiple test cases. - * @param array $optionalArgs { - * Optional. - * - * @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 string $filter - * The filter expression used to filter test case results. See - * [API Filtering](https://aip.dev/160). - * - * The expression is case insensitive. Only 'AND' is supported for logical - * operators. The supported syntax is listed below in detail: - * - * [AND ] ... - * [AND latest] - * - * The supported fields and operators are: - * field operator - * `environment` `=`, `IN` (Use value `draft` for draft environment) - * `test_time` `>`, `<` - * - * `latest` only returns the latest test result in all results for each test - * case. - * - * Examples: - * * "environment=draft AND latest" matches the latest test result for each - * test case in the draft environment. - * * "environment IN (e1,e2)" matches any test case results with an - * environment resource name of either "e1" or "e2". - * * "test_time > 1602540713" matches any test case results with test time - * later than a unix timestamp in seconds 1602540713. - * @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 listTestCaseResults($parent, array $optionalArgs = []) - { - $request = new ListTestCaseResultsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListTestCaseResults', $optionalArgs, ListTestCaseResultsResponse::class, $request); - } - - /** - * Fetches a list of test cases for a given agent. - * - * Sample code: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * $formattedParent = $testCasesClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * // Iterate over pages of elements - * $pagedResponse = $testCasesClient->listTestCases($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $testCasesClient->listTestCases($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $testCasesClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent to list all pages for. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @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 int $view - * Specifies whether response should include all fields or just the metadata. - * For allowed values, use constants defined on {@see \Google\Cloud\Dialogflow\Cx\V3\ListTestCasesRequest\TestCaseView} - * @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 listTestCases($parent, array $optionalArgs = []) - { - $request = new ListTestCasesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListTestCases', $optionalArgs, ListTestCasesResponse::class, $request); - } - - /** - * Kicks off a test case run. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [RunTestCaseMetadata][google.cloud.dialogflow.cx.v3.RunTestCaseMetadata] - * - `response`: - * [RunTestCaseResponse][google.cloud.dialogflow.cx.v3.RunTestCaseResponse] - * - * Sample code: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * $formattedName = $testCasesClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'); - * $operationResponse = $testCasesClient->runTestCase($formattedName); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $testCasesClient->runTestCase($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $testCasesClient->resumeOperation($operationName, 'runTestCase'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $testCasesClient->close(); - * } - * ``` - * - * @param string $name Required. Format of test case name to run: `projects//locations/ /agents//testCases/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $environment - * Optional. Environment name. If not set, draft environment is assumed. - * Format: `projects//locations//agents//environments/`. - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function runTestCase($name, array $optionalArgs = []) - { - $request = new RunTestCaseRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['environment'])) { - $request->setEnvironment($optionalArgs['environment']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('RunTestCase', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Updates the specified test case. - * - * Sample code: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * $testCase = new TestCase(); - * $updateMask = new FieldMask(); - * $response = $testCasesClient->updateTestCase($testCase, $updateMask); - * } finally { - * $testCasesClient->close(); - * } - * ``` - * - * @param TestCase $testCase Required. The test case to update. - * @param FieldMask $updateMask Required. The mask to specify which fields should be updated. The - * [`creationTime`][google.cloud.dialogflow.cx.v3.TestCase.creation_time] and - * [`lastTestResult`][google.cloud.dialogflow.cx.v3.TestCase.last_test_result] - * cannot be updated. - * @param array $optionalArgs { - * Optional. - * - * @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\TestCase - * - * @throws ApiException if the remote call fails - */ - public function updateTestCase($testCase, $updateMask, array $optionalArgs = []) - { - $request = new UpdateTestCaseRequest(); - $requestParamHeaders = []; - $request->setTestCase($testCase); - $request->setUpdateMask($updateMask); - $requestParamHeaders['test_case.name'] = $testCase->getName(); - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('UpdateTestCase', TestCase::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * $response = $testCasesClient->getLocation(); - * } finally { - * $testCasesClient->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: - * ``` - * $testCasesClient = new TestCasesClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $testCasesClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $testCasesClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $testCasesClient->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/TransitionRouteGroupsGapicClient.php b/DialogflowCx/src/V3/Gapic/TransitionRouteGroupsGapicClient.php deleted file mode 100644 index 7e11121043a7..000000000000 --- a/DialogflowCx/src/V3/Gapic/TransitionRouteGroupsGapicClient.php +++ /dev/null @@ -1,975 +0,0 @@ -flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * $transitionRouteGroup = new TransitionRouteGroup(); - * $response = $transitionRouteGroupsClient->createTransitionRouteGroup($formattedParent, $transitionRouteGroup); - * } finally { - * $transitionRouteGroupsClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class TransitionRouteGroupsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.TransitionRouteGroups'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $flowNameTemplate; - - private static $intentNameTemplate; - - private static $pageNameTemplate; - - private static $projectLocationAgentFlowTransitionRouteGroupNameTemplate; - - private static $projectLocationAgentTransitionRouteGroupNameTemplate; - - private static $transitionRouteGroupNameTemplate; - - private static $webhookNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/transition_route_groups_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/transition_route_groups_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/transition_route_groups_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/transition_route_groups_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 getFlowNameTemplate() - { - if (self::$flowNameTemplate == null) { - self::$flowNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}'); - } - - return self::$flowNameTemplate; - } - - private static function getIntentNameTemplate() - { - if (self::$intentNameTemplate == null) { - self::$intentNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/intents/{intent}'); - } - - return self::$intentNameTemplate; - } - - private static function getPageNameTemplate() - { - if (self::$pageNameTemplate == null) { - self::$pageNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}'); - } - - return self::$pageNameTemplate; - } - - private static function getProjectLocationAgentFlowTransitionRouteGroupNameTemplate() - { - if (self::$projectLocationAgentFlowTransitionRouteGroupNameTemplate == null) { - self::$projectLocationAgentFlowTransitionRouteGroupNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}'); - } - - return self::$projectLocationAgentFlowTransitionRouteGroupNameTemplate; - } - - private static function getProjectLocationAgentTransitionRouteGroupNameTemplate() - { - if (self::$projectLocationAgentTransitionRouteGroupNameTemplate == null) { - self::$projectLocationAgentTransitionRouteGroupNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group}'); - } - - return self::$projectLocationAgentTransitionRouteGroupNameTemplate; - } - - private static function getTransitionRouteGroupNameTemplate() - { - if (self::$transitionRouteGroupNameTemplate == null) { - self::$transitionRouteGroupNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}'); - } - - return self::$transitionRouteGroupNameTemplate; - } - - private static function getWebhookNameTemplate() - { - if (self::$webhookNameTemplate == null) { - self::$webhookNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}'); - } - - return self::$webhookNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'agent' => self::getAgentNameTemplate(), - 'flow' => self::getFlowNameTemplate(), - 'intent' => self::getIntentNameTemplate(), - 'page' => self::getPageNameTemplate(), - 'projectLocationAgentFlowTransitionRouteGroup' => self::getProjectLocationAgentFlowTransitionRouteGroupNameTemplate(), - 'projectLocationAgentTransitionRouteGroup' => self::getProjectLocationAgentTransitionRouteGroupNameTemplate(), - 'transitionRouteGroup' => self::getTransitionRouteGroupNameTemplate(), - 'webhook' => self::getWebhookNameTemplate(), - ]; - } - - 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 flow - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * - * @return string The formatted flow resource. - */ - public static function flowName($project, $location, $agent, $flow) - { - return self::getFlowNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a intent - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $intent - * - * @return string The formatted intent resource. - */ - public static function intentName($project, $location, $agent, $intent) - { - return self::getIntentNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'intent' => $intent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a page - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $page - * - * @return string The formatted page resource. - */ - public static function pageName($project, $location, $agent, $flow, $page) - { - return self::getPageNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'page' => $page, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_flow_transition_route_group resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $transitionRouteGroup - * - * @return string The formatted project_location_agent_flow_transition_route_group resource. - */ - public static function projectLocationAgentFlowTransitionRouteGroupName($project, $location, $agent, $flow, $transitionRouteGroup) - { - return self::getProjectLocationAgentFlowTransitionRouteGroupNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'transition_route_group' => $transitionRouteGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent_transition_route_group resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $transitionRouteGroup - * - * @return string The formatted project_location_agent_transition_route_group resource. - */ - public static function projectLocationAgentTransitionRouteGroupName($project, $location, $agent, $transitionRouteGroup) - { - return self::getProjectLocationAgentTransitionRouteGroupNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'transition_route_group' => $transitionRouteGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * transition_route_group resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $transitionRouteGroup - * - * @return string The formatted transition_route_group resource. - */ - public static function transitionRouteGroupName($project, $location, $agent, $flow, $transitionRouteGroup) - { - return self::getTransitionRouteGroupNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'transition_route_group' => $transitionRouteGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a webhook - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $webhook - * - * @return string The formatted webhook resource. - */ - public static function webhookName($project, $location, $agent, $webhook) - { - return self::getWebhookNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'webhook' => $webhook, - ]); - } - - /** - * 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} - * - flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow} - * - intent: projects/{project}/locations/{location}/agents/{agent}/intents/{intent} - * - page: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page} - * - projectLocationAgentFlowTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} - * - projectLocationAgentTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group} - * - transitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group} - * - webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook} - * - * 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 an - * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - * in the specified flow. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); - * try { - * $formattedParent = $transitionRouteGroupsClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * $transitionRouteGroup = new TransitionRouteGroup(); - * $response = $transitionRouteGroupsClient->createTransitionRouteGroup($formattedParent, $transitionRouteGroup); - * } finally { - * $transitionRouteGroupsClient->close(); - * } - * ``` - * - * @param string $parent Required. The flow to create an - * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - * for. Format: `projects//locations//agents//flows/` - * or `projects//locations//agents/` - * for agent-level groups. - * @param TransitionRouteGroup $transitionRouteGroup Required. The transition route group to create. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language of the following fields in `TransitionRouteGroup`: - * - * * `TransitionRouteGroup.transition_routes.trigger_fulfillment.messages` - * * - * `TransitionRouteGroup.transition_routes.trigger_fulfillment.conditional_cases` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\TransitionRouteGroup - * - * @throws ApiException if the remote call fails - */ - public function createTransitionRouteGroup($parent, $transitionRouteGroup, array $optionalArgs = []) - { - $request = new CreateTransitionRouteGroupRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setTransitionRouteGroup($transitionRouteGroup); - $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('CreateTransitionRouteGroup', TransitionRouteGroup::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes the specified - * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); - * try { - * $formattedName = $transitionRouteGroupsClient->transitionRouteGroupName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[TRANSITION_ROUTE_GROUP]'); - * $transitionRouteGroupsClient->deleteTransitionRouteGroup($formattedName); - * } finally { - * $transitionRouteGroupsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the - * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - * to delete. Format: `projects//locations//agents//flows//transitionRouteGroups/` or `projects//locations//agents//transitionRouteGroups/`. - * @param array $optionalArgs { - * Optional. - * - * @type bool $force - * This field has no effect for transition route group that no page is using. - * If the transition route group is referenced by any page: - * - * * If `force` is set to false, an error will be returned with message - * indicating pages that reference the transition route group. - * * If `force` is set to true, Dialogflow will remove the transition route - * group, as well as any reference to it. - * @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 deleteTransitionRouteGroup($name, array $optionalArgs = []) - { - $request = new DeleteTransitionRouteGroupRequest(); - $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('DeleteTransitionRouteGroup', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Retrieves the specified - * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - * - * Sample code: - * ``` - * $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); - * try { - * $formattedName = $transitionRouteGroupsClient->transitionRouteGroupName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[TRANSITION_ROUTE_GROUP]'); - * $response = $transitionRouteGroupsClient->getTransitionRouteGroup($formattedName); - * } finally { - * $transitionRouteGroupsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the - * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - * Format: `projects//locations//agents//flows//transitionRouteGroups/` - * or `projects//locations//agents//transitionRouteGroups/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language to retrieve the transition route group for. The following - * fields are language dependent: - * - * * `TransitionRouteGroup.transition_routes.trigger_fulfillment.messages` - * * - * `TransitionRouteGroup.transition_routes.trigger_fulfillment.conditional_cases` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\TransitionRouteGroup - * - * @throws ApiException if the remote call fails - */ - public function getTransitionRouteGroup($name, array $optionalArgs = []) - { - $request = new GetTransitionRouteGroupRequest(); - $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('GetTransitionRouteGroup', TransitionRouteGroup::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns the list of all transition route groups in the specified flow. - * - * Sample code: - * ``` - * $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); - * try { - * $formattedParent = $transitionRouteGroupsClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * // Iterate over pages of elements - * $pagedResponse = $transitionRouteGroupsClient->listTransitionRouteGroups($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $transitionRouteGroupsClient->listTransitionRouteGroups($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $transitionRouteGroupsClient->close(); - * } - * ``` - * - * @param string $parent Required. The flow to list all transition route groups for. - * Format: `projects//locations//agents//flows/` - * or `projects//locations//agents/. - * @param array $optionalArgs { - * Optional. - * - * @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 string $languageCode - * The language to list transition route groups for. The following fields are - * language dependent: - * - * * `TransitionRouteGroup.transition_routes.trigger_fulfillment.messages` - * * - * `TransitionRouteGroup.transition_routes.trigger_fulfillment.conditional_cases` - * - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listTransitionRouteGroups($parent, array $optionalArgs = []) - { - $request = new ListTransitionRouteGroupsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - 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->getPagedListResponse('ListTransitionRouteGroups', $optionalArgs, ListTransitionRouteGroupsResponse::class, $request); - } - - /** - * Updates the specified - * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - * - * Note: You should always train a flow prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/cx/docs/concept/training). - * - * Sample code: - * ``` - * $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); - * try { - * $transitionRouteGroup = new TransitionRouteGroup(); - * $response = $transitionRouteGroupsClient->updateTransitionRouteGroup($transitionRouteGroup); - * } finally { - * $transitionRouteGroupsClient->close(); - * } - * ``` - * - * @param TransitionRouteGroup $transitionRouteGroup Required. The transition route group to update. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * The mask to control which fields get updated. - * @type string $languageCode - * The language of the following fields in `TransitionRouteGroup`: - * - * * `TransitionRouteGroup.transition_routes.trigger_fulfillment.messages` - * * - * `TransitionRouteGroup.transition_routes.trigger_fulfillment.conditional_cases` - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/cx/docs/reference/language) - * are supported. - * Note: languages must be enabled in the agent before they can be 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\TransitionRouteGroup - * - * @throws ApiException if the remote call fails - */ - public function updateTransitionRouteGroup($transitionRouteGroup, array $optionalArgs = []) - { - $request = new UpdateTransitionRouteGroupRequest(); - $requestParamHeaders = []; - $request->setTransitionRouteGroup($transitionRouteGroup); - $requestParamHeaders['transition_route_group.name'] = $transitionRouteGroup->getName(); - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - 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('UpdateTransitionRouteGroup', TransitionRouteGroup::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); - * try { - * $response = $transitionRouteGroupsClient->getLocation(); - * } finally { - * $transitionRouteGroupsClient->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: - * ``` - * $transitionRouteGroupsClient = new TransitionRouteGroupsClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $transitionRouteGroupsClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $transitionRouteGroupsClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $transitionRouteGroupsClient->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/VersionsGapicClient.php b/DialogflowCx/src/V3/Gapic/VersionsGapicClient.php deleted file mode 100644 index 1c43d29947d2..000000000000 --- a/DialogflowCx/src/V3/Gapic/VersionsGapicClient.php +++ /dev/null @@ -1,879 +0,0 @@ -versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - * $formattedTargetVersion = $versionsClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - * $response = $versionsClient->compareVersions($formattedBaseVersion, $formattedTargetVersion); - * } finally { - * $versionsClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class VersionsGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.Versions'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $flowNameTemplate; - - private static $versionNameTemplate; - - private static $pathTemplateMap; - - private $operationsClient; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/versions_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/versions_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/versions_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/versions_rest_client_config.php', - ], - ], - ]; - } - - private static function getFlowNameTemplate() - { - if (self::$flowNameTemplate == null) { - self::$flowNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}'); - } - - return self::$flowNameTemplate; - } - - private static function getVersionNameTemplate() - { - if (self::$versionNameTemplate == null) { - self::$versionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}'); - } - - return self::$versionNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'flow' => self::getFlowNameTemplate(), - 'version' => self::getVersionNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a flow - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * - * @return string The formatted flow resource. - */ - public static function flowName($project, $location, $agent, $flow) - { - return self::getFlowNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a version - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $flow - * @param string $version - * - * @return string The formatted version resource. - */ - public static function versionName($project, $location, $agent, $flow, $version) - { - return self::getVersionNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'flow' => $flow, - 'version' => $version, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow} - * - version: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version} - * - * 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"); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** - * Compares the specified base version with target version. - * - * Sample code: - * ``` - * $versionsClient = new VersionsClient(); - * try { - * $formattedBaseVersion = $versionsClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - * $formattedTargetVersion = $versionsClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - * $response = $versionsClient->compareVersions($formattedBaseVersion, $formattedTargetVersion); - * } finally { - * $versionsClient->close(); - * } - * ``` - * - * @param string $baseVersion Required. Name of the base flow version to compare with the target version. - * Use version ID `0` to indicate the draft version of the specified flow. - * - * Format: `projects//locations//agents/ - * /flows//versions/`. - * @param string $targetVersion Required. Name of the target flow version to compare with the - * base version. Use version ID `0` to indicate the draft version of the - * specified flow. Format: `projects//locations//agents//flows//versions/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $languageCode - * The language to compare the flow versions for. - * - * If not specified, the agent's default language is used. - * [Many - * languages](https://cloud.google.com/dialogflow/docs/reference/language) are - * supported. Note: languages must be enabled in the agent before they can be - * 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\CompareVersionsResponse - * - * @throws ApiException if the remote call fails - */ - public function compareVersions($baseVersion, $targetVersion, array $optionalArgs = []) - { - $request = new CompareVersionsRequest(); - $requestParamHeaders = []; - $request->setBaseVersion($baseVersion); - $request->setTargetVersion($targetVersion); - $requestParamHeaders['base_version'] = $baseVersion; - 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('CompareVersions', CompareVersionsResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Creates a [Version][google.cloud.dialogflow.cx.v3.Version] in the specified - * [Flow][google.cloud.dialogflow.cx.v3.Flow]. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [CreateVersionOperationMetadata][google.cloud.dialogflow.cx.v3.CreateVersionOperationMetadata] - * - `response`: [Version][google.cloud.dialogflow.cx.v3.Version] - * - * Sample code: - * ``` - * $versionsClient = new VersionsClient(); - * try { - * $formattedParent = $versionsClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * $version = new Version(); - * $operationResponse = $versionsClient->createVersion($formattedParent, $version); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $versionsClient->createVersion($formattedParent, $version); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $versionsClient->resumeOperation($operationName, 'createVersion'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $versionsClient->close(); - * } - * ``` - * - * @param string $parent Required. The [Flow][google.cloud.dialogflow.cx.v3.Flow] to create an - * [Version][google.cloud.dialogflow.cx.v3.Version] for. Format: - * `projects//locations//agents//flows/`. - * @param Version $version Required. The version to create. - * @param array $optionalArgs { - * Optional. - * - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function createVersion($parent, $version, array $optionalArgs = []) - { - $request = new CreateVersionRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setVersion($version); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreateVersion', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Deletes the specified [Version][google.cloud.dialogflow.cx.v3.Version]. - * - * Sample code: - * ``` - * $versionsClient = new VersionsClient(); - * try { - * $formattedName = $versionsClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - * $versionsClient->deleteVersion($formattedName); - * } finally { - * $versionsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the [Version][google.cloud.dialogflow.cx.v3.Version] - * to delete. Format: `projects//locations//agents//flows//versions/`. - * @param array $optionalArgs { - * Optional. - * - * @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 deleteVersion($name, array $optionalArgs = []) - { - $request = new DeleteVersionRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteVersion', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Retrieves the specified [Version][google.cloud.dialogflow.cx.v3.Version]. - * - * Sample code: - * ``` - * $versionsClient = new VersionsClient(); - * try { - * $formattedName = $versionsClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - * $response = $versionsClient->getVersion($formattedName); - * } finally { - * $versionsClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the [Version][google.cloud.dialogflow.cx.v3.Version]. - * Format: `projects//locations//agents//flows//versions/`. - * @param array $optionalArgs { - * Optional. - * - * @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\Version - * - * @throws ApiException if the remote call fails - */ - public function getVersion($name, array $optionalArgs = []) - { - $request = new GetVersionRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetVersion', Version::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns the list of all versions in the specified - * [Flow][google.cloud.dialogflow.cx.v3.Flow]. - * - * Sample code: - * ``` - * $versionsClient = new VersionsClient(); - * try { - * $formattedParent = $versionsClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - * // Iterate over pages of elements - * $pagedResponse = $versionsClient->listVersions($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $versionsClient->listVersions($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $versionsClient->close(); - * } - * ``` - * - * @param string $parent Required. The [Flow][google.cloud.dialogflow.cx.v3.Flow] to list all - * versions for. Format: `projects//locations//agents//flows/`. - * @param array $optionalArgs { - * Optional. - * - * @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 listVersions($parent, array $optionalArgs = []) - { - $request = new ListVersionsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - 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('ListVersions', $optionalArgs, ListVersionsResponse::class, $request); - } - - /** - * Loads resources in the specified version to the draft flow. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * Sample code: - * ``` - * $versionsClient = new VersionsClient(); - * try { - * $formattedName = $versionsClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - * $operationResponse = $versionsClient->loadVersion($formattedName); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $versionsClient->loadVersion($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $versionsClient->resumeOperation($operationName, 'loadVersion'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * // operation succeeded and returns no value - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $versionsClient->close(); - * } - * ``` - * - * @param string $name Required. The [Version][google.cloud.dialogflow.cx.v3.Version] to be loaded - * to draft flow. Format: `projects//locations//agents//flows//versions/`. - * @param array $optionalArgs { - * Optional. - * - * @type bool $allowOverrideAgentResources - * This field is used to prevent accidental overwrite of other agent - * resources, which can potentially impact other flow's behavior. If - * `allow_override_agent_resources` is false, conflicted agent-level resources - * will not be overridden (i.e. intents, entities, webhooks). - * @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\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function loadVersion($name, array $optionalArgs = []) - { - $request = new LoadVersionRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['allowOverrideAgentResources'])) { - $request->setAllowOverrideAgentResources($optionalArgs['allowOverrideAgentResources']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('LoadVersion', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Updates the specified [Version][google.cloud.dialogflow.cx.v3.Version]. - * - * Sample code: - * ``` - * $versionsClient = new VersionsClient(); - * try { - * $version = new Version(); - * $updateMask = new FieldMask(); - * $response = $versionsClient->updateVersion($version, $updateMask); - * } finally { - * $versionsClient->close(); - * } - * ``` - * - * @param Version $version Required. The version to update. - * @param FieldMask $updateMask Required. The mask to control which fields get updated. Currently only - * `description` and `display_name` can be updated. - * @param array $optionalArgs { - * Optional. - * - * @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\Version - * - * @throws ApiException if the remote call fails - */ - public function updateVersion($version, $updateMask, array $optionalArgs = []) - { - $request = new UpdateVersionRequest(); - $requestParamHeaders = []; - $request->setVersion($version); - $request->setUpdateMask($updateMask); - $requestParamHeaders['version.name'] = $version->getName(); - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('UpdateVersion', Version::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $versionsClient = new VersionsClient(); - * try { - * $response = $versionsClient->getLocation(); - * } finally { - * $versionsClient->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: - * ``` - * $versionsClient = new VersionsClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $versionsClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $versionsClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $versionsClient->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/WebhooksGapicClient.php b/DialogflowCx/src/V3/Gapic/WebhooksGapicClient.php deleted file mode 100644 index df31a4a6d7c4..000000000000 --- a/DialogflowCx/src/V3/Gapic/WebhooksGapicClient.php +++ /dev/null @@ -1,706 +0,0 @@ -agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $webhook = new Webhook(); - * $response = $webhooksClient->createWebhook($formattedParent, $webhook); - * } finally { - * $webhooksClient->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. - * - * @deprecated This class will be removed in the next major version update. - */ -class WebhooksGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.cloud.dialogflow.cx.v3.Webhooks'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'dialogflow.UNIVERSE_DOMAIN'; - - /** 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 $serviceNameTemplate; - - private static $webhookNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/webhooks_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/webhooks_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/webhooks_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/webhooks_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 getServiceNameTemplate() - { - if (self::$serviceNameTemplate == null) { - self::$serviceNameTemplate = new PathTemplate('projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}'); - } - - return self::$serviceNameTemplate; - } - - private static function getWebhookNameTemplate() - { - if (self::$webhookNameTemplate == null) { - self::$webhookNameTemplate = new PathTemplate('projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}'); - } - - return self::$webhookNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'agent' => self::getAgentNameTemplate(), - 'service' => self::getServiceNameTemplate(), - 'webhook' => self::getWebhookNameTemplate(), - ]; - } - - 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 service - * resource. - * - * @param string $project - * @param string $location - * @param string $namespace - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName($project, $location, $namespace, $service) - { - return self::getServiceNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'namespace' => $namespace, - 'service' => $service, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a webhook - * resource. - * - * @param string $project - * @param string $location - * @param string $agent - * @param string $webhook - * - * @return string The formatted webhook resource. - */ - public static function webhookName($project, $location, $agent, $webhook) - { - return self::getWebhookNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'agent' => $agent, - 'webhook' => $webhook, - ]); - } - - /** - * 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} - * - service: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service} - * - webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook} - * - * 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 webhook in the specified agent. - * - * Sample code: - * ``` - * $webhooksClient = new WebhooksClient(); - * try { - * $formattedParent = $webhooksClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * $webhook = new Webhook(); - * $response = $webhooksClient->createWebhook($formattedParent, $webhook); - * } finally { - * $webhooksClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent to create a webhook for. - * Format: `projects//locations//agents/`. - * @param Webhook $webhook Required. The webhook to create. - * @param array $optionalArgs { - * Optional. - * - * @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\Webhook - * - * @throws ApiException if the remote call fails - */ - public function createWebhook($parent, $webhook, array $optionalArgs = []) - { - $request = new CreateWebhookRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setWebhook($webhook); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateWebhook', Webhook::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes the specified webhook. - * - * Sample code: - * ``` - * $webhooksClient = new WebhooksClient(); - * try { - * $formattedName = $webhooksClient->webhookName('[PROJECT]', '[LOCATION]', '[AGENT]', '[WEBHOOK]'); - * $webhooksClient->deleteWebhook($formattedName); - * } finally { - * $webhooksClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the webhook to delete. - * Format: `projects//locations//agents//webhooks/`. - * @param array $optionalArgs { - * Optional. - * - * @type bool $force - * This field has no effect for webhook not being used. - * For webhooks 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 webhook, as well - * as any references to the webhook (i.e. - * [Webhook][google.cloud.dialogflow.cx.v3.Fulfillment.webhook] and - * [tag][google.cloud.dialogflow.cx.v3.Fulfillment.tag]in fulfillments that - * point to this webhook will be removed). - * @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 deleteWebhook($name, array $optionalArgs = []) - { - $request = new DeleteWebhookRequest(); - $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('DeleteWebhook', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Retrieves the specified webhook. - * - * Sample code: - * ``` - * $webhooksClient = new WebhooksClient(); - * try { - * $formattedName = $webhooksClient->webhookName('[PROJECT]', '[LOCATION]', '[AGENT]', '[WEBHOOK]'); - * $response = $webhooksClient->getWebhook($formattedName); - * } finally { - * $webhooksClient->close(); - * } - * ``` - * - * @param string $name Required. The name of the webhook. - * Format: `projects//locations//agents//webhooks/`. - * @param array $optionalArgs { - * Optional. - * - * @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\Webhook - * - * @throws ApiException if the remote call fails - */ - public function getWebhook($name, array $optionalArgs = []) - { - $request = new GetWebhookRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetWebhook', Webhook::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns the list of all webhooks in the specified agent. - * - * Sample code: - * ``` - * $webhooksClient = new WebhooksClient(); - * try { - * $formattedParent = $webhooksClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - * // Iterate over pages of elements - * $pagedResponse = $webhooksClient->listWebhooks($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $webhooksClient->listWebhooks($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $webhooksClient->close(); - * } - * ``` - * - * @param string $parent Required. The agent to list all webhooks for. - * Format: `projects//locations//agents/`. - * @param array $optionalArgs { - * Optional. - * - * @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 listWebhooks($parent, array $optionalArgs = []) - { - $request = new ListWebhooksRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - 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('ListWebhooks', $optionalArgs, ListWebhooksResponse::class, $request); - } - - /** - * Updates the specified webhook. - * - * Sample code: - * ``` - * $webhooksClient = new WebhooksClient(); - * try { - * $webhook = new Webhook(); - * $response = $webhooksClient->updateWebhook($webhook); - * } finally { - * $webhooksClient->close(); - * } - * ``` - * - * @param Webhook $webhook Required. The webhook to update. - * @param array $optionalArgs { - * Optional. - * - * @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\Webhook - * - * @throws ApiException if the remote call fails - */ - public function updateWebhook($webhook, array $optionalArgs = []) - { - $request = new UpdateWebhookRequest(); - $requestParamHeaders = []; - $request->setWebhook($webhook); - $requestParamHeaders['webhook.name'] = $webhook->getName(); - 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('UpdateWebhook', Webhook::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about a location. - * - * Sample code: - * ``` - * $webhooksClient = new WebhooksClient(); - * try { - * $response = $webhooksClient->getLocation(); - * } finally { - * $webhooksClient->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: - * ``` - * $webhooksClient = new WebhooksClient(); - * try { - * // Iterate over pages of elements - * $pagedResponse = $webhooksClient->listLocations(); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $webhooksClient->listLocations(); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $webhooksClient->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/GeneratorsClient.php b/DialogflowCx/src/V3/GeneratorsClient.php deleted file mode 100644 index 16771a3ba24e..000000000000 --- a/DialogflowCx/src/V3/GeneratorsClient.php +++ /dev/null @@ -1,34 +0,0 @@ -/locations//agents/`. Please see + * {@see AgentsClient::agentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetAgentRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetAgentValidationResultRequest.php b/DialogflowCx/src/V3/GetAgentValidationResultRequest.php index 5a4cec331dd4..a1a88413ad4d 100644 --- a/DialogflowCx/src/V3/GetAgentValidationResultRequest.php +++ b/DialogflowCx/src/V3/GetAgentValidationResultRequest.php @@ -31,6 +31,22 @@ class GetAgentValidationResultRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $name Required. The agent name. + * Format: `projects//locations//agents//validationResult`. Please see + * {@see AgentsClient::agentValidationResultName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetAgentValidationResultRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetChangelogRequest.php b/DialogflowCx/src/V3/GetChangelogRequest.php index 05ac7173c574..68b74f913fc5 100644 --- a/DialogflowCx/src/V3/GetChangelogRequest.php +++ b/DialogflowCx/src/V3/GetChangelogRequest.php @@ -25,6 +25,22 @@ class GetChangelogRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the changelog to get. + * Format: `projects//locations//agents//changelogs/`. Please see + * {@see ChangelogsClient::changelogName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetChangelogRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetDeploymentRequest.php b/DialogflowCx/src/V3/GetDeploymentRequest.php index 8227fcaed3f6..3afd3af928fe 100644 --- a/DialogflowCx/src/V3/GetDeploymentRequest.php +++ b/DialogflowCx/src/V3/GetDeploymentRequest.php @@ -26,6 +26,23 @@ class GetDeploymentRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the + * [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. Format: + * `projects//locations//agents//environments//deployments/`. Please see + * {@see DeploymentsClient::deploymentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetDeploymentRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetEntityTypeRequest.php b/DialogflowCx/src/V3/GetEntityTypeRequest.php index 2f3cfaebbda1..8fc4b0595181 100644 --- a/DialogflowCx/src/V3/GetEntityTypeRequest.php +++ b/DialogflowCx/src/V3/GetEntityTypeRequest.php @@ -40,6 +40,22 @@ class GetEntityTypeRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $name Required. The name of the entity type. + * Format: `projects//locations//agents//entityTypes/`. Please see + * {@see EntityTypesClient::entityTypeName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetEntityTypeRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetEnvironmentRequest.php b/DialogflowCx/src/V3/GetEnvironmentRequest.php index df7211d60f1f..88856535e3ce 100644 --- a/DialogflowCx/src/V3/GetEnvironmentRequest.php +++ b/DialogflowCx/src/V3/GetEnvironmentRequest.php @@ -26,6 +26,23 @@ class GetEnvironmentRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the + * [Environment][google.cloud.dialogflow.cx.v3.Environment]. Format: + * `projects//locations//agents//environments/`. Please see + * {@see EnvironmentsClient::environmentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetEnvironmentRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetExperimentRequest.php b/DialogflowCx/src/V3/GetExperimentRequest.php index c6c8b88b6599..bbbb079206d5 100644 --- a/DialogflowCx/src/V3/GetExperimentRequest.php +++ b/DialogflowCx/src/V3/GetExperimentRequest.php @@ -26,6 +26,23 @@ class GetExperimentRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the + * [Environment][google.cloud.dialogflow.cx.v3.Environment]. Format: + * `projects//locations//agents//environments//experiments/`. Please see + * {@see ExperimentsClient::experimentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetExperimentRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetFlowRequest.php b/DialogflowCx/src/V3/GetFlowRequest.php index 9b5933ae5c94..77d0bb69d7e9 100644 --- a/DialogflowCx/src/V3/GetFlowRequest.php +++ b/DialogflowCx/src/V3/GetFlowRequest.php @@ -41,6 +41,22 @@ class GetFlowRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $name Required. The name of the flow to get. + * Format: `projects//locations//agents//flows/`. Please see + * {@see FlowsClient::flowName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetFlowRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetFlowValidationResultRequest.php b/DialogflowCx/src/V3/GetFlowValidationResultRequest.php index 6133074f6d64..d34b1f06c807 100644 --- a/DialogflowCx/src/V3/GetFlowValidationResultRequest.php +++ b/DialogflowCx/src/V3/GetFlowValidationResultRequest.php @@ -31,6 +31,22 @@ class GetFlowValidationResultRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $name Required. The flow name. + * Format: `projects//locations//agents//flows//validationResult`. Please see + * {@see FlowsClient::flowValidationResultName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetFlowValidationResultRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetGenerativeSettingsRequest.php b/DialogflowCx/src/V3/GetGenerativeSettingsRequest.php index 3b88efb8dcaf..e60a0c87b341 100644 --- a/DialogflowCx/src/V3/GetGenerativeSettingsRequest.php +++ b/DialogflowCx/src/V3/GetGenerativeSettingsRequest.php @@ -31,6 +31,23 @@ class GetGenerativeSettingsRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $name Required. Format: `projects//locations//agents//generativeSettings`. Please see + * {@see AgentsClient::agentGenerativeSettingsName()} for help formatting this field. + * @param string $languageCode Required. Language code of the generative settings. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetGenerativeSettingsRequest + * + * @experimental + */ + public static function build(string $name, string $languageCode): self + { + return (new self()) + ->setName($name) + ->setLanguageCode($languageCode); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetGeneratorRequest.php b/DialogflowCx/src/V3/GetGeneratorRequest.php index 5cd4657a4603..ec136bd747a9 100644 --- a/DialogflowCx/src/V3/GetGeneratorRequest.php +++ b/DialogflowCx/src/V3/GetGeneratorRequest.php @@ -31,6 +31,22 @@ class GetGeneratorRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $name Required. The name of the generator. + * Format: `projects//locations//agents//generators/`. Please see + * {@see GeneratorsClient::generatorName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetGeneratorRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetIntentRequest.php b/DialogflowCx/src/V3/GetIntentRequest.php index 910aa8747d02..a64a9afec5aa 100644 --- a/DialogflowCx/src/V3/GetIntentRequest.php +++ b/DialogflowCx/src/V3/GetIntentRequest.php @@ -38,6 +38,22 @@ class GetIntentRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $name Required. The name of the intent. + * Format: `projects//locations//agents//intents/`. Please see + * {@see IntentsClient::intentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetIntentRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetPageRequest.php b/DialogflowCx/src/V3/GetPageRequest.php index 09be79d5cec5..e62f722da435 100644 --- a/DialogflowCx/src/V3/GetPageRequest.php +++ b/DialogflowCx/src/V3/GetPageRequest.php @@ -49,6 +49,22 @@ class GetPageRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $name Required. The name of the page. + * Format: `projects//locations//agents//flows//pages/`. Please see + * {@see PagesClient::pageName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetPageRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetSecuritySettingsRequest.php b/DialogflowCx/src/V3/GetSecuritySettingsRequest.php index cd16bce60627..0d54c2da7b6d 100644 --- a/DialogflowCx/src/V3/GetSecuritySettingsRequest.php +++ b/DialogflowCx/src/V3/GetSecuritySettingsRequest.php @@ -25,6 +25,22 @@ class GetSecuritySettingsRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. Resource name of the settings. + * Format: `projects//locations//securitySettings/`. Please see + * {@see SecuritySettingsServiceClient::securitySettingsName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetSecuritySettingsRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetSessionEntityTypeRequest.php b/DialogflowCx/src/V3/GetSessionEntityTypeRequest.php index 0fdfa6cf8af4..bf673f6c5b91 100644 --- a/DialogflowCx/src/V3/GetSessionEntityTypeRequest.php +++ b/DialogflowCx/src/V3/GetSessionEntityTypeRequest.php @@ -29,6 +29,26 @@ class GetSessionEntityTypeRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the session entity type. + * Format: `projects//locations//agents//sessions//entityTypes/` or + * `projects//locations//agents//environments//sessions//entityTypes/`. If `Environment ID` is not specified, we assume default 'draft' + * environment. Please see + * {@see SessionEntityTypesClient::sessionEntityTypeName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetSessionEntityTypeRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetTestCaseRequest.php b/DialogflowCx/src/V3/GetTestCaseRequest.php index aa6fdab0a56f..a721c9668c38 100644 --- a/DialogflowCx/src/V3/GetTestCaseRequest.php +++ b/DialogflowCx/src/V3/GetTestCaseRequest.php @@ -25,6 +25,22 @@ class GetTestCaseRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the testcase. + * Format: `projects//locations//agents//testCases/`. Please see + * {@see TestCasesClient::testCaseName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetTestCaseRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetTestCaseResultRequest.php b/DialogflowCx/src/V3/GetTestCaseResultRequest.php index 3cb600e1cf19..210b372f91c7 100644 --- a/DialogflowCx/src/V3/GetTestCaseResultRequest.php +++ b/DialogflowCx/src/V3/GetTestCaseResultRequest.php @@ -25,6 +25,22 @@ class GetTestCaseResultRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the testcase. + * Format: `projects//locations//agents//testCases//results/`. Please see + * {@see TestCasesClient::testCaseResultName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetTestCaseResultRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetTransitionRouteGroupRequest.php b/DialogflowCx/src/V3/GetTransitionRouteGroupRequest.php index 79bd221f1f48..236882f97bb3 100644 --- a/DialogflowCx/src/V3/GetTransitionRouteGroupRequest.php +++ b/DialogflowCx/src/V3/GetTransitionRouteGroupRequest.php @@ -43,6 +43,25 @@ class GetTransitionRouteGroupRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $name Required. The name of the + * [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. + * Format: `projects//locations//agents//flows//transitionRouteGroups/` + * or `projects//locations//agents//transitionRouteGroups/`. Please see + * {@see TransitionRouteGroupsClient::transitionRouteGroupName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetTransitionRouteGroupRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetVersionRequest.php b/DialogflowCx/src/V3/GetVersionRequest.php index 997e5fa480ac..b8e8e7c3162f 100644 --- a/DialogflowCx/src/V3/GetVersionRequest.php +++ b/DialogflowCx/src/V3/GetVersionRequest.php @@ -25,6 +25,22 @@ class GetVersionRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the [Version][google.cloud.dialogflow.cx.v3.Version]. + * Format: `projects//locations//agents//flows//versions/`. Please see + * {@see VersionsClient::versionName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetVersionRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/GetWebhookRequest.php b/DialogflowCx/src/V3/GetWebhookRequest.php index 10f4e0ee8c67..c68f3f629ab6 100644 --- a/DialogflowCx/src/V3/GetWebhookRequest.php +++ b/DialogflowCx/src/V3/GetWebhookRequest.php @@ -25,6 +25,22 @@ class GetWebhookRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the webhook. + * Format: `projects//locations//agents//webhooks/`. Please see + * {@see WebhooksClient::webhookName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\GetWebhookRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/IntentsClient.php b/DialogflowCx/src/V3/IntentsClient.php deleted file mode 100644 index c23267307b87..000000000000 --- a/DialogflowCx/src/V3/IntentsClient.php +++ /dev/null @@ -1,34 +0,0 @@ -/locations/`. Please see + * {@see AgentsClient::locationName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListAgentsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListChangelogsRequest.php b/DialogflowCx/src/V3/ListChangelogsRequest.php index a3157a9df961..11e985ae4cf7 100644 --- a/DialogflowCx/src/V3/ListChangelogsRequest.php +++ b/DialogflowCx/src/V3/ListChangelogsRequest.php @@ -62,6 +62,21 @@ class ListChangelogsRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The agent containing the changelogs. + * Format: `projects//locations//agents/`. Please see + * {@see ChangelogsClient::agentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListChangelogsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListContinuousTestResultsRequest.php b/DialogflowCx/src/V3/ListContinuousTestResultsRequest.php index d1c19ffbb16f..28374b5ca0d6 100644 --- a/DialogflowCx/src/V3/ListContinuousTestResultsRequest.php +++ b/DialogflowCx/src/V3/ListContinuousTestResultsRequest.php @@ -38,6 +38,22 @@ class ListContinuousTestResultsRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The environment to list results for. + * Format: `projects//locations//agents// + * environments/`. Please see + * {@see EnvironmentsClient::environmentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListContinuousTestResultsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListDeploymentsRequest.php b/DialogflowCx/src/V3/ListDeploymentsRequest.php index 9122cf75d8f6..ff572ac54799 100644 --- a/DialogflowCx/src/V3/ListDeploymentsRequest.php +++ b/DialogflowCx/src/V3/ListDeploymentsRequest.php @@ -39,6 +39,23 @@ class ListDeploymentsRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The [Environment][google.cloud.dialogflow.cx.v3.Environment] to + * list all environments for. Format: `projects//locations//agents//environments/`. Please see + * {@see DeploymentsClient::environmentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListDeploymentsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListEntityTypesRequest.php b/DialogflowCx/src/V3/ListEntityTypesRequest.php index 83a706c66ea0..db4205733dde 100644 --- a/DialogflowCx/src/V3/ListEntityTypesRequest.php +++ b/DialogflowCx/src/V3/ListEntityTypesRequest.php @@ -52,6 +52,21 @@ class ListEntityTypesRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The agent to list all entity types for. + * Format: `projects//locations//agents/`. Please see + * {@see EntityTypesClient::agentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListEntityTypesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListEnvironmentsRequest.php b/DialogflowCx/src/V3/ListEnvironmentsRequest.php index f6de55136e30..16a54de19865 100644 --- a/DialogflowCx/src/V3/ListEnvironmentsRequest.php +++ b/DialogflowCx/src/V3/ListEnvironmentsRequest.php @@ -38,6 +38,22 @@ class ListEnvironmentsRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The [Agent][google.cloud.dialogflow.cx.v3.Agent] to list all + * environments for. Format: `projects//locations//agents/`. Please see + * {@see EnvironmentsClient::agentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListEnvironmentsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListExperimentsRequest.php b/DialogflowCx/src/V3/ListExperimentsRequest.php index 8ae7c17d9a31..d69bba8f11f1 100644 --- a/DialogflowCx/src/V3/ListExperimentsRequest.php +++ b/DialogflowCx/src/V3/ListExperimentsRequest.php @@ -39,6 +39,23 @@ class ListExperimentsRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The [Environment][google.cloud.dialogflow.cx.v3.Environment] to + * list all environments for. Format: `projects//locations//agents//environments/`. Please see + * {@see ExperimentsClient::environmentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListExperimentsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListFlowsRequest.php b/DialogflowCx/src/V3/ListFlowsRequest.php index 664175364c1f..db07b32102c5 100644 --- a/DialogflowCx/src/V3/ListFlowsRequest.php +++ b/DialogflowCx/src/V3/ListFlowsRequest.php @@ -53,6 +53,21 @@ class ListFlowsRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $parent Required. The agent containing the flows. + * Format: `projects//locations//agents/`. Please see + * {@see FlowsClient::agentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListFlowsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListGeneratorsRequest.php b/DialogflowCx/src/V3/ListGeneratorsRequest.php index 49d3ddef2d77..438bd593c0f8 100644 --- a/DialogflowCx/src/V3/ListGeneratorsRequest.php +++ b/DialogflowCx/src/V3/ListGeneratorsRequest.php @@ -43,6 +43,21 @@ class ListGeneratorsRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The agent to list all generators for. + * Format: `projects//locations//agents/`. Please see + * {@see GeneratorsClient::agentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListGeneratorsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListIntentsRequest.php b/DialogflowCx/src/V3/ListIntentsRequest.php index 9d2fbd36c6cd..7a9065dcb926 100644 --- a/DialogflowCx/src/V3/ListIntentsRequest.php +++ b/DialogflowCx/src/V3/ListIntentsRequest.php @@ -56,6 +56,21 @@ class ListIntentsRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The agent to list all intents for. + * Format: `projects//locations//agents/`. Please see + * {@see IntentsClient::agentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListIntentsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListPagesRequest.php b/DialogflowCx/src/V3/ListPagesRequest.php index 94b774da1e03..0a7848ca3e8b 100644 --- a/DialogflowCx/src/V3/ListPagesRequest.php +++ b/DialogflowCx/src/V3/ListPagesRequest.php @@ -62,6 +62,22 @@ class ListPagesRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The flow to list all pages for. + * Format: `projects//locations//agents//flows/`. Please see + * {@see PagesClient::flowName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListPagesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListSecuritySettingsRequest.php b/DialogflowCx/src/V3/ListSecuritySettingsRequest.php index 3cdcc76f4ee1..bf0786db3f61 100644 --- a/DialogflowCx/src/V3/ListSecuritySettingsRequest.php +++ b/DialogflowCx/src/V3/ListSecuritySettingsRequest.php @@ -36,6 +36,21 @@ class ListSecuritySettingsRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The location to list all security settings for. + * Format: `projects//locations/`. Please see + * {@see SecuritySettingsServiceClient::locationName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListSecuritySettingsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListSessionEntityTypesRequest.php b/DialogflowCx/src/V3/ListSessionEntityTypesRequest.php index 5cdc94c98214..42ec7f555680 100644 --- a/DialogflowCx/src/V3/ListSessionEntityTypesRequest.php +++ b/DialogflowCx/src/V3/ListSessionEntityTypesRequest.php @@ -41,6 +41,25 @@ class ListSessionEntityTypesRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The session to list all session entity types from. + * Format: `projects//locations//agents//sessions/` or `projects//locations//agents//environments//sessions/`. + * If `Environment ID` is not specified, we assume default 'draft' + * environment. Please see + * {@see SessionEntityTypesClient::sessionName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListSessionEntityTypesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListTestCaseResultsRequest.php b/DialogflowCx/src/V3/ListTestCaseResultsRequest.php index ba3f3615fa4f..48bfae19d703 100644 --- a/DialogflowCx/src/V3/ListTestCaseResultsRequest.php +++ b/DialogflowCx/src/V3/ListTestCaseResultsRequest.php @@ -63,6 +63,23 @@ class ListTestCaseResultsRequest extends \Google\Protobuf\Internal\Message */ protected $filter = ''; + /** + * @param string $parent Required. The test case to list results for. + * Format: `projects//locations//agents// + * testCases/`. Specify a `-` as a wildcard for TestCase ID to + * list results across multiple test cases. Please see + * {@see TestCasesClient::testCaseName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListTestCaseResultsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListTestCasesRequest.php b/DialogflowCx/src/V3/ListTestCasesRequest.php index 3ee1f6ab5efe..126b96cb6fd1 100644 --- a/DialogflowCx/src/V3/ListTestCasesRequest.php +++ b/DialogflowCx/src/V3/ListTestCasesRequest.php @@ -44,6 +44,21 @@ class ListTestCasesRequest extends \Google\Protobuf\Internal\Message */ protected $view = 0; + /** + * @param string $parent Required. The agent to list all pages for. + * Format: `projects//locations//agents/`. Please see + * {@see TestCasesClient::agentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListTestCasesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListTransitionRouteGroupsRequest.php b/DialogflowCx/src/V3/ListTransitionRouteGroupsRequest.php index a224fd874535..54ba858d3f29 100644 --- a/DialogflowCx/src/V3/ListTransitionRouteGroupsRequest.php +++ b/DialogflowCx/src/V3/ListTransitionRouteGroupsRequest.php @@ -54,6 +54,23 @@ class ListTransitionRouteGroupsRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param string $parent Required. The flow to list all transition route groups for. + * Format: `projects//locations//agents//flows/` + * or `projects//locations//agents/. Please see + * {@see TransitionRouteGroupsClient::flowName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListTransitionRouteGroupsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListVersionsRequest.php b/DialogflowCx/src/V3/ListVersionsRequest.php index 785543b62d2b..724b7b6700b9 100644 --- a/DialogflowCx/src/V3/ListVersionsRequest.php +++ b/DialogflowCx/src/V3/ListVersionsRequest.php @@ -38,6 +38,22 @@ class ListVersionsRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The [Flow][google.cloud.dialogflow.cx.v3.Flow] to list all + * versions for. Format: `projects//locations//agents//flows/`. Please see + * {@see VersionsClient::flowName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListVersionsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/ListWebhooksRequest.php b/DialogflowCx/src/V3/ListWebhooksRequest.php index b251c3a83c13..7dae89e4852d 100644 --- a/DialogflowCx/src/V3/ListWebhooksRequest.php +++ b/DialogflowCx/src/V3/ListWebhooksRequest.php @@ -37,6 +37,21 @@ class ListWebhooksRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The agent to list all webhooks for. + * Format: `projects//locations//agents/`. Please see + * {@see WebhooksClient::agentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\ListWebhooksRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/LoadVersionRequest.php b/DialogflowCx/src/V3/LoadVersionRequest.php index 9183032c53b2..956456fd0620 100644 --- a/DialogflowCx/src/V3/LoadVersionRequest.php +++ b/DialogflowCx/src/V3/LoadVersionRequest.php @@ -34,6 +34,22 @@ class LoadVersionRequest extends \Google\Protobuf\Internal\Message */ protected $allow_override_agent_resources = false; + /** + * @param string $name Required. The [Version][google.cloud.dialogflow.cx.v3.Version] to be loaded + * to draft flow. Format: `projects//locations//agents//flows//versions/`. Please see + * {@see VersionsClient::versionName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\LoadVersionRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/LookupEnvironmentHistoryRequest.php b/DialogflowCx/src/V3/LookupEnvironmentHistoryRequest.php index 80c5fd7e5f13..1b41646f3ff0 100644 --- a/DialogflowCx/src/V3/LookupEnvironmentHistoryRequest.php +++ b/DialogflowCx/src/V3/LookupEnvironmentHistoryRequest.php @@ -38,6 +38,22 @@ class LookupEnvironmentHistoryRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $name Required. Resource name of the environment to look up the history for. + * Format: `projects//locations//agents//environments/`. Please see + * {@see EnvironmentsClient::environmentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\LookupEnvironmentHistoryRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/PagesClient.php b/DialogflowCx/src/V3/PagesClient.php deleted file mode 100644 index fac3beb52315..000000000000 --- a/DialogflowCx/src/V3/PagesClient.php +++ /dev/null @@ -1,34 +0,0 @@ -/locations//agents//environments//experiments/`. Please see + * {@see ExperimentsClient::experimentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\StartExperimentRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/StopExperimentRequest.php b/DialogflowCx/src/V3/StopExperimentRequest.php index 1f0d6c980099..c3da25da5e39 100644 --- a/DialogflowCx/src/V3/StopExperimentRequest.php +++ b/DialogflowCx/src/V3/StopExperimentRequest.php @@ -25,6 +25,22 @@ class StopExperimentRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. Resource name of the experiment to stop. + * Format: `projects//locations//agents//environments//experiments/`. Please see + * {@see ExperimentsClient::experimentName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\StopExperimentRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/TestCasesClient.php b/DialogflowCx/src/V3/TestCasesClient.php deleted file mode 100644 index 2e2135c843b7..000000000000 --- a/DialogflowCx/src/V3/TestCasesClient.php +++ /dev/null @@ -1,34 +0,0 @@ -/locations//agents//flows/`. Please see + * {@see FlowsClient::flowName()} for help formatting this field. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\TrainFlowRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/TransitionRouteGroupsClient.php b/DialogflowCx/src/V3/TransitionRouteGroupsClient.php deleted file mode 100644 index ff5763d7ae7e..000000000000 --- a/DialogflowCx/src/V3/TransitionRouteGroupsClient.php +++ /dev/null @@ -1,34 +0,0 @@ -setAgent($agent) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdateEntityTypeRequest.php b/DialogflowCx/src/V3/UpdateEntityTypeRequest.php index a440daff0c44..eb795ce68bf3 100644 --- a/DialogflowCx/src/V3/UpdateEntityTypeRequest.php +++ b/DialogflowCx/src/V3/UpdateEntityTypeRequest.php @@ -43,6 +43,21 @@ class UpdateEntityTypeRequest extends \Google\Protobuf\Internal\Message */ protected $update_mask = null; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\EntityType $entityType Required. The entity type to update. + * @param \Google\Protobuf\FieldMask $updateMask The mask to control which fields get updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdateEntityTypeRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\EntityType $entityType, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setEntityType($entityType) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdateEnvironmentRequest.php b/DialogflowCx/src/V3/UpdateEnvironmentRequest.php index 85d48213c796..cadbf57a4152 100644 --- a/DialogflowCx/src/V3/UpdateEnvironmentRequest.php +++ b/DialogflowCx/src/V3/UpdateEnvironmentRequest.php @@ -29,6 +29,21 @@ class UpdateEnvironmentRequest extends \Google\Protobuf\Internal\Message */ protected $update_mask = null; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\Environment $environment Required. The environment to update. + * @param \Google\Protobuf\FieldMask $updateMask Required. The mask to control which fields get updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdateEnvironmentRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\Environment $environment, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setEnvironment($environment) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdateExperimentRequest.php b/DialogflowCx/src/V3/UpdateExperimentRequest.php index a010642d0c8b..176d4b093336 100644 --- a/DialogflowCx/src/V3/UpdateExperimentRequest.php +++ b/DialogflowCx/src/V3/UpdateExperimentRequest.php @@ -29,6 +29,21 @@ class UpdateExperimentRequest extends \Google\Protobuf\Internal\Message */ protected $update_mask = null; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\Experiment $experiment Required. The experiment to update. + * @param \Google\Protobuf\FieldMask $updateMask Required. The mask to control which fields get updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdateExperimentRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\Experiment $experiment, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setExperiment($experiment) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdateFlowRequest.php b/DialogflowCx/src/V3/UpdateFlowRequest.php index 7d1a40cabea0..7958a5ad2242 100644 --- a/DialogflowCx/src/V3/UpdateFlowRequest.php +++ b/DialogflowCx/src/V3/UpdateFlowRequest.php @@ -45,6 +45,22 @@ class UpdateFlowRequest extends \Google\Protobuf\Internal\Message */ protected $language_code = ''; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\Flow $flow Required. The flow to update. + * @param \Google\Protobuf\FieldMask $updateMask The mask to control which fields get updated. If the mask is not present, + * all fields will be updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdateFlowRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\Flow $flow, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setFlow($flow) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdateGenerativeSettingsRequest.php b/DialogflowCx/src/V3/UpdateGenerativeSettingsRequest.php index fe73a042fc17..bb137233d7ef 100644 --- a/DialogflowCx/src/V3/UpdateGenerativeSettingsRequest.php +++ b/DialogflowCx/src/V3/UpdateGenerativeSettingsRequest.php @@ -31,6 +31,22 @@ class UpdateGenerativeSettingsRequest extends \Google\Protobuf\Internal\Message */ protected $update_mask = null; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\GenerativeSettings $generativeSettings Required. Generative settings to update. + * @param \Google\Protobuf\FieldMask $updateMask Optional. The mask to control which fields get updated. If the mask is not + * present, all fields will be updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdateGenerativeSettingsRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\GenerativeSettings $generativeSettings, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setGenerativeSettings($generativeSettings) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdateGeneratorRequest.php b/DialogflowCx/src/V3/UpdateGeneratorRequest.php index b9533fc00423..c7a6701d7dbd 100644 --- a/DialogflowCx/src/V3/UpdateGeneratorRequest.php +++ b/DialogflowCx/src/V3/UpdateGeneratorRequest.php @@ -36,6 +36,22 @@ class UpdateGeneratorRequest extends \Google\Protobuf\Internal\Message */ protected $update_mask = null; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\Generator $generator Required. The generator to update. + * @param \Google\Protobuf\FieldMask $updateMask The mask to control which fields get updated. If the mask is not present, + * all fields will be updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdateGeneratorRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\Generator $generator, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setGenerator($generator) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdateIntentRequest.php b/DialogflowCx/src/V3/UpdateIntentRequest.php index 0a0835a4593e..97ea71f67b8f 100644 --- a/DialogflowCx/src/V3/UpdateIntentRequest.php +++ b/DialogflowCx/src/V3/UpdateIntentRequest.php @@ -42,6 +42,22 @@ class UpdateIntentRequest extends \Google\Protobuf\Internal\Message */ protected $update_mask = null; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\Intent $intent Required. The intent to update. + * @param \Google\Protobuf\FieldMask $updateMask The mask to control which fields get updated. If the mask is not present, + * all fields will be updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdateIntentRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\Intent $intent, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setIntent($intent) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdatePageRequest.php b/DialogflowCx/src/V3/UpdatePageRequest.php index 9b66b6a21079..12a53a370793 100644 --- a/DialogflowCx/src/V3/UpdatePageRequest.php +++ b/DialogflowCx/src/V3/UpdatePageRequest.php @@ -53,6 +53,22 @@ class UpdatePageRequest extends \Google\Protobuf\Internal\Message */ protected $update_mask = null; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\Page $page Required. The page to update. + * @param \Google\Protobuf\FieldMask $updateMask The mask to control which fields get updated. If the mask is not present, + * all fields will be updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdatePageRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\Page $page, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setPage($page) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdateSecuritySettingsRequest.php b/DialogflowCx/src/V3/UpdateSecuritySettingsRequest.php index 1be56fedd7ee..4615d8419770 100644 --- a/DialogflowCx/src/V3/UpdateSecuritySettingsRequest.php +++ b/DialogflowCx/src/V3/UpdateSecuritySettingsRequest.php @@ -31,6 +31,23 @@ class UpdateSecuritySettingsRequest extends \Google\Protobuf\Internal\Message */ protected $update_mask = null; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\SecuritySettings $securitySettings Required. [SecuritySettings] object that contains values for each of the + * fields to update. + * @param \Google\Protobuf\FieldMask $updateMask Required. The mask to control which fields get updated. If the mask is not + * present, all fields will be updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdateSecuritySettingsRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\SecuritySettings $securitySettings, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setSecuritySettings($securitySettings) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdateSessionEntityTypeRequest.php b/DialogflowCx/src/V3/UpdateSessionEntityTypeRequest.php index 103759270ae6..5c2e810f1ddc 100644 --- a/DialogflowCx/src/V3/UpdateSessionEntityTypeRequest.php +++ b/DialogflowCx/src/V3/UpdateSessionEntityTypeRequest.php @@ -35,6 +35,27 @@ class UpdateSessionEntityTypeRequest extends \Google\Protobuf\Internal\Message */ protected $update_mask = null; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\SessionEntityType $sessionEntityType Required. The session entity type to update. + * Format: `projects//locations//agents//sessions//entityTypes/` or + * `projects//locations//agents//environments//sessions//entityTypes/`. If `Environment ID` is not specified, we assume default 'draft' + * environment. + * @param \Google\Protobuf\FieldMask $updateMask The mask to control which fields get updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdateSessionEntityTypeRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\SessionEntityType $sessionEntityType, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setSessionEntityType($sessionEntityType) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdateTestCaseRequest.php b/DialogflowCx/src/V3/UpdateTestCaseRequest.php index 3338effac576..4f7b23f1d441 100644 --- a/DialogflowCx/src/V3/UpdateTestCaseRequest.php +++ b/DialogflowCx/src/V3/UpdateTestCaseRequest.php @@ -32,6 +32,24 @@ class UpdateTestCaseRequest extends \Google\Protobuf\Internal\Message */ protected $update_mask = null; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\TestCase $testCase Required. The test case to update. + * @param \Google\Protobuf\FieldMask $updateMask Required. The mask to specify which fields should be updated. The + * [`creationTime`][google.cloud.dialogflow.cx.v3.TestCase.creation_time] and + * [`lastTestResult`][google.cloud.dialogflow.cx.v3.TestCase.last_test_result] + * cannot be updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdateTestCaseRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\TestCase $testCase, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setTestCase($testCase) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdateTransitionRouteGroupRequest.php b/DialogflowCx/src/V3/UpdateTransitionRouteGroupRequest.php index a62ecc2ef039..e3e033c82b6b 100644 --- a/DialogflowCx/src/V3/UpdateTransitionRouteGroupRequest.php +++ b/DialogflowCx/src/V3/UpdateTransitionRouteGroupRequest.php @@ -43,6 +43,21 @@ class UpdateTransitionRouteGroupRequest extends \Google\Protobuf\Internal\Messag */ protected $language_code = ''; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroup $transitionRouteGroup Required. The transition route group to update. + * @param \Google\Protobuf\FieldMask $updateMask The mask to control which fields get updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdateTransitionRouteGroupRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroup $transitionRouteGroup, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setTransitionRouteGroup($transitionRouteGroup) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdateVersionRequest.php b/DialogflowCx/src/V3/UpdateVersionRequest.php index 066b39b7a675..babda721b2ed 100644 --- a/DialogflowCx/src/V3/UpdateVersionRequest.php +++ b/DialogflowCx/src/V3/UpdateVersionRequest.php @@ -30,6 +30,22 @@ class UpdateVersionRequest extends \Google\Protobuf\Internal\Message */ protected $update_mask = null; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\Version $version Required. The version to update. + * @param \Google\Protobuf\FieldMask $updateMask Required. The mask to control which fields get updated. Currently only + * `description` and `display_name` can be updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdateVersionRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\Version $version, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setVersion($version) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/UpdateWebhookRequest.php b/DialogflowCx/src/V3/UpdateWebhookRequest.php index ced0345914b0..621a1b1f29f1 100644 --- a/DialogflowCx/src/V3/UpdateWebhookRequest.php +++ b/DialogflowCx/src/V3/UpdateWebhookRequest.php @@ -30,6 +30,22 @@ class UpdateWebhookRequest extends \Google\Protobuf\Internal\Message */ protected $update_mask = null; + /** + * @param \Google\Cloud\Dialogflow\Cx\V3\Webhook $webhook Required. The webhook to update. + * @param \Google\Protobuf\FieldMask $updateMask The mask to control which fields get updated. If the mask is not present, + * all fields will be updated. + * + * @return \Google\Cloud\Dialogflow\Cx\V3\UpdateWebhookRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Dialogflow\Cx\V3\Webhook $webhook, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setWebhook($webhook) + ->setUpdateMask($updateMask); + } + /** * Constructor. * diff --git a/DialogflowCx/src/V3/VersionsClient.php b/DialogflowCx/src/V3/VersionsClient.php deleted file mode 100644 index f4dc18db4f75..000000000000 --- a/DialogflowCx/src/V3/VersionsClient.php +++ /dev/null @@ -1,34 +0,0 @@ - '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], ], 'RestoreAgent' => [ 'longRunning' => [ @@ -22,6 +31,75 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'CreateAgent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Agent', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteAgent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetAgent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Agent', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetAgentValidationResult' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\AgentValidationResult', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetGenerativeSettings' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\GenerativeSettings', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], ], 'ListAgents' => [ 'pageStreaming' => [ @@ -32,8 +110,66 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getAgents', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListAgentsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateAgent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Agent', + 'headerParams' => [ + [ + 'keyName' => 'agent.name', + 'fieldAccessors' => [ + 'getAgent', + 'getName', + ], + ], + ], + ], + 'UpdateGenerativeSettings' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\GenerativeSettings', + 'headerParams' => [ + [ + 'keyName' => 'generative_settings.name', + 'fieldAccessors' => [ + 'getGenerativeSettings', + 'getName', + ], + ], + ], + ], + 'ValidateAgent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\AgentValidationResult', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -45,8 +181,27 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'agent' => 'projects/{project}/locations/{location}/agents/{agent}', + 'agentGenerativeSettings' => 'projects/{project}/locations/{location}/agents/{agent}/generativeSettings', + 'agentValidationResult' => 'projects/{project}/locations/{location}/agents/{agent}/validationResult', + 'environment' => 'projects/{project}/locations/{location}/agents/{agent}/environments/{environment}', + 'flow' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}', + 'location' => 'projects/{project}/locations/{location}', + 'securitySettings' => 'projects/{project}/locations/{location}/securitySettings/{security_settings}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/changelogs_descriptor_config.php b/DialogflowCx/src/V3/resources/changelogs_descriptor_config.php index 36bd572cfd34..1cc1746815ac 100644 --- a/DialogflowCx/src/V3/resources/changelogs_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/changelogs_descriptor_config.php @@ -3,6 +3,18 @@ return [ 'interfaces' => [ 'google.cloud.dialogflow.cx.v3.Changelogs' => [ + 'GetChangelog' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Changelog', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'ListChangelogs' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -12,8 +24,28 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getChangelogs', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListChangelogsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -25,8 +57,22 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'agent' => 'projects/{project}/locations/{location}/agents/{agent}', + 'changelog' => 'projects/{project}/locations/{location}/agents/{agent}/changelogs/{changelog}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/deployments_descriptor_config.php b/DialogflowCx/src/V3/resources/deployments_descriptor_config.php index 3ac9a4f11d87..e20287f99c98 100644 --- a/DialogflowCx/src/V3/resources/deployments_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/deployments_descriptor_config.php @@ -3,6 +3,18 @@ return [ 'interfaces' => [ 'google.cloud.dialogflow.cx.v3.Deployments' => [ + 'GetDeployment' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Deployment', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'ListDeployments' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -12,8 +24,28 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getDeployments', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListDeploymentsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -25,8 +57,22 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'deployment' => 'projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/deployments/{deployment}', + 'environment' => 'projects/{project}/locations/{location}/agents/{agent}/environments/{environment}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/entity_types_descriptor_config.php b/DialogflowCx/src/V3/resources/entity_types_descriptor_config.php index 4eafc759afab..78ee6964677e 100644 --- a/DialogflowCx/src/V3/resources/entity_types_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/entity_types_descriptor_config.php @@ -3,6 +3,42 @@ return [ 'interfaces' => [ 'google.cloud.dialogflow.cx.v3.EntityTypes' => [ + 'CreateEntityType' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\EntityType', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteEntityType' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetEntityType' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\EntityType', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'ListEntityTypes' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -12,8 +48,41 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getEntityTypes', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListEntityTypesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateEntityType' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\EntityType', + 'headerParams' => [ + [ + 'keyName' => 'entity_type.name', + 'fieldAccessors' => [ + 'getEntityType', + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -25,8 +94,22 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'agent' => 'projects/{project}/locations/{location}/agents/{agent}', + 'entityType' => 'projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/environments_descriptor_config.php b/DialogflowCx/src/V3/resources/environments_descriptor_config.php index 06eded6e1602..b2ed48fd868b 100644 --- a/DialogflowCx/src/V3/resources/environments_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/environments_descriptor_config.php @@ -12,6 +12,15 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], ], 'DeployFlow' => [ 'longRunning' => [ @@ -22,6 +31,15 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'environment', + 'fieldAccessors' => [ + 'getEnvironment', + ], + ], + ], ], 'RunContinuousTest' => [ 'longRunning' => [ @@ -32,6 +50,15 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'environment', + 'fieldAccessors' => [ + 'getEnvironment', + ], + ], + ], ], 'UpdateEnvironment' => [ 'longRunning' => [ @@ -42,6 +69,40 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'environment.name', + 'fieldAccessors' => [ + 'getEnvironment', + 'getName', + ], + ], + ], + ], + 'DeleteEnvironment' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetEnvironment' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Environment', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], ], 'ListContinuousTestResults' => [ 'pageStreaming' => [ @@ -52,6 +113,16 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getContinuousTestResults', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListContinuousTestResultsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], ], 'ListEnvironments' => [ 'pageStreaming' => [ @@ -62,6 +133,16 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getEnvironments', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListEnvironmentsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], ], 'LookupEnvironmentHistory' => [ 'pageStreaming' => [ @@ -72,8 +153,28 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getEnvironments', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\LookupEnvironmentHistoryResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -85,8 +186,26 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'agent' => 'projects/{project}/locations/{location}/agents/{agent}', + 'environment' => 'projects/{project}/locations/{location}/agents/{agent}/environments/{environment}', + 'service' => 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}', + 'testCase' => 'projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}', + 'version' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}', + 'webhook' => 'projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/experiments_descriptor_config.php b/DialogflowCx/src/V3/resources/experiments_descriptor_config.php index 061642d3bf14..a3961da02b10 100644 --- a/DialogflowCx/src/V3/resources/experiments_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/experiments_descriptor_config.php @@ -3,6 +3,42 @@ return [ 'interfaces' => [ 'google.cloud.dialogflow.cx.v3.Experiments' => [ + 'CreateExperiment' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Experiment', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteExperiment' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetExperiment' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Experiment', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'ListExperiments' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -12,8 +48,65 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getExperiments', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListExperimentsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'StartExperiment' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Experiment', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'StopExperiment' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Experiment', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'UpdateExperiment' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Experiment', + 'headerParams' => [ + [ + 'keyName' => 'experiment.name', + 'fieldAccessors' => [ + 'getExperiment', + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -25,8 +118,23 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'environment' => 'projects/{project}/locations/{location}/agents/{agent}/environments/{environment}', + 'experiment' => 'projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/experiments/{experiment}', + 'version' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/flows_descriptor_config.php b/DialogflowCx/src/V3/resources/flows_descriptor_config.php index 63612b708f42..757185974c34 100644 --- a/DialogflowCx/src/V3/resources/flows_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/flows_descriptor_config.php @@ -12,6 +12,15 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], ], 'ImportFlow' => [ 'longRunning' => [ @@ -22,6 +31,15 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], ], 'TrainFlow' => [ 'longRunning' => [ @@ -32,6 +50,63 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'CreateFlow' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Flow', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteFlow' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetFlow' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Flow', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetFlowValidationResult' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\FlowValidationResult', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], ], 'ListFlows' => [ 'pageStreaming' => [ @@ -42,8 +117,53 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getFlows', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListFlowsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateFlow' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Flow', + 'headerParams' => [ + [ + 'keyName' => 'flow.name', + 'fieldAccessors' => [ + 'getFlow', + 'getName', + ], + ], + ], + ], + 'ValidateFlow' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\FlowValidationResult', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -55,8 +175,29 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'agent' => 'projects/{project}/locations/{location}/agents/{agent}', + 'flow' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}', + 'flowValidationResult' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/validationResult', + 'intent' => 'projects/{project}/locations/{location}/agents/{agent}/intents/{intent}', + 'page' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}', + 'projectLocationAgentFlowTransitionRouteGroup' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}', + 'projectLocationAgentTransitionRouteGroup' => 'projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group}', + 'transitionRouteGroup' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}', + 'webhook' => 'projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/generators_descriptor_config.php b/DialogflowCx/src/V3/resources/generators_descriptor_config.php index 991f2a0163ac..3b3eebb40634 100644 --- a/DialogflowCx/src/V3/resources/generators_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/generators_descriptor_config.php @@ -3,6 +3,42 @@ return [ 'interfaces' => [ 'google.cloud.dialogflow.cx.v3.Generators' => [ + 'CreateGenerator' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Generator', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteGenerator' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetGenerator' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Generator', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'ListGenerators' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -12,8 +48,41 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getGenerators', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListGeneratorsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateGenerator' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Generator', + 'headerParams' => [ + [ + 'keyName' => 'generator.name', + 'fieldAccessors' => [ + 'getGenerator', + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -25,8 +94,22 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'agent' => 'projects/{project}/locations/{location}/agents/{agent}', + 'generator' => 'projects/{project}/locations/{location}/agents/{agent}/generators/{generator}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/intents_descriptor_config.php b/DialogflowCx/src/V3/resources/intents_descriptor_config.php index 3cd27f242393..dba9dfca420e 100644 --- a/DialogflowCx/src/V3/resources/intents_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/intents_descriptor_config.php @@ -12,6 +12,15 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], ], 'ImportIntents' => [ 'longRunning' => [ @@ -22,6 +31,51 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'CreateIntent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Intent', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteIntent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetIntent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Intent', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], ], 'ListIntents' => [ 'pageStreaming' => [ @@ -32,8 +86,41 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getIntents', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListIntentsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateIntent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Intent', + 'headerParams' => [ + [ + 'keyName' => 'intent.name', + 'fieldAccessors' => [ + 'getIntent', + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -45,8 +132,23 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'agent' => 'projects/{project}/locations/{location}/agents/{agent}', + 'entityType' => 'projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}', + 'intent' => 'projects/{project}/locations/{location}/agents/{agent}/intents/{intent}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/pages_descriptor_config.php b/DialogflowCx/src/V3/resources/pages_descriptor_config.php index 36c6a0b56174..c20869166a1e 100644 --- a/DialogflowCx/src/V3/resources/pages_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/pages_descriptor_config.php @@ -3,6 +3,42 @@ return [ 'interfaces' => [ 'google.cloud.dialogflow.cx.v3.Pages' => [ + 'CreatePage' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Page', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeletePage' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetPage' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Page', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'ListPages' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -12,8 +48,41 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getPages', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListPagesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdatePage' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Page', + 'headerParams' => [ + [ + 'keyName' => 'page.name', + 'fieldAccessors' => [ + 'getPage', + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -25,8 +94,28 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'entityType' => 'projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}', + 'flow' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}', + 'intent' => 'projects/{project}/locations/{location}/agents/{agent}/intents/{intent}', + 'page' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}', + 'projectLocationAgentFlowTransitionRouteGroup' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}', + 'projectLocationAgentTransitionRouteGroup' => 'projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group}', + 'transitionRouteGroup' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}', + 'webhook' => 'projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/security_settings_service_descriptor_config.php b/DialogflowCx/src/V3/resources/security_settings_service_descriptor_config.php index 2703d0acd183..a5927cfa3f7f 100644 --- a/DialogflowCx/src/V3/resources/security_settings_service_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/security_settings_service_descriptor_config.php @@ -3,6 +3,42 @@ return [ 'interfaces' => [ 'google.cloud.dialogflow.cx.v3.SecuritySettingsService' => [ + 'CreateSecuritySettings' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\SecuritySettings', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteSecuritySettings' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetSecuritySettings' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\SecuritySettings', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'ListSecuritySettings' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -12,8 +48,41 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getSecuritySettings', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListSecuritySettingsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateSecuritySettings' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\SecuritySettings', + 'headerParams' => [ + [ + 'keyName' => 'security_settings.name', + 'fieldAccessors' => [ + 'getSecuritySettings', + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -25,8 +94,28 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'deidentifyTemplate' => 'organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template}', + 'inspectTemplate' => 'organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template}', + 'location' => 'projects/{project}/locations/{location}', + 'organizationLocationDeidentifyTemplate' => 'organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template}', + 'organizationLocationInspectTemplate' => 'organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template}', + 'projectLocationDeidentifyTemplate' => 'projects/{project}/locations/{location}/deidentifyTemplates/{deidentify_template}', + 'projectLocationInspectTemplate' => 'projects/{project}/locations/{location}/inspectTemplates/{inspect_template}', + 'securitySettings' => 'projects/{project}/locations/{location}/securitySettings/{security_settings}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/session_entity_types_descriptor_config.php b/DialogflowCx/src/V3/resources/session_entity_types_descriptor_config.php index 142f42953982..44f086ca6889 100644 --- a/DialogflowCx/src/V3/resources/session_entity_types_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/session_entity_types_descriptor_config.php @@ -3,6 +3,42 @@ return [ 'interfaces' => [ 'google.cloud.dialogflow.cx.v3.SessionEntityTypes' => [ + 'CreateSessionEntityType' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\SessionEntityType', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteSessionEntityType' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetSessionEntityType' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\SessionEntityType', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'ListSessionEntityTypes' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -12,8 +48,41 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getSessionEntityTypes', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListSessionEntityTypesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateSessionEntityType' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\SessionEntityType', + 'headerParams' => [ + [ + 'keyName' => 'session_entity_type.name', + 'fieldAccessors' => [ + 'getSessionEntityType', + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -25,8 +94,26 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'projectLocationAgentEnvironmentSession' => 'projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/sessions/{session}', + '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}', + 'session' => 'projects/{project}/locations/{location}/agents/{agent}/sessions/{session}', + 'sessionEntityType' => 'projects/{project}/locations/{location}/agents/{agent}/sessions/{session}/entityTypes/{entity_type}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/sessions_descriptor_config.php b/DialogflowCx/src/V3/resources/sessions_descriptor_config.php index 852c2ea43382..a94293c545e8 100644 --- a/DialogflowCx/src/V3/resources/sessions_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/sessions_descriptor_config.php @@ -3,12 +3,73 @@ return [ 'interfaces' => [ 'google.cloud.dialogflow.cx.v3.Sessions' => [ + 'DetectIntent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\DetectIntentResponse', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], + ], + 'FulfillIntent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\FulfillIntentResponse', + 'headerParams' => [ + [ + 'keyName' => 'match_intent_request.session', + 'fieldAccessors' => [ + 'getMatchIntentRequest', + 'getSession', + ], + ], + ], + ], + 'MatchIntent' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\MatchIntentResponse', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], + ], 'StreamingDetectIntent' => [ 'grpcStreaming' => [ 'grpcStreamingType' => 'BidiStreaming', ], + 'callType' => \Google\ApiCore\Call::BIDI_STREAMING_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\StreamingDetectIntentResponse', + ], + 'SubmitAnswerFeedback' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback', + 'headerParams' => [ + [ + 'keyName' => 'session', + 'fieldAccessors' => [ + 'getSession', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -20,8 +81,34 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + '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}', + 'projectLocationAgentEnvironmentSession' => 'projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/sessions/{session}', + '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}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/test_cases_descriptor_config.php b/DialogflowCx/src/V3/resources/test_cases_descriptor_config.php index b19b9868f6f5..0234231b2429 100644 --- a/DialogflowCx/src/V3/resources/test_cases_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/test_cases_descriptor_config.php @@ -12,6 +12,15 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], ], 'ExportTestCases' => [ 'longRunning' => [ @@ -22,6 +31,15 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], ], 'ImportTestCases' => [ 'longRunning' => [ @@ -32,6 +50,15 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], ], 'RunTestCase' => [ 'longRunning' => [ @@ -42,6 +69,75 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'BatchDeleteTestCases' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'CalculateCoverage' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageResponse', + 'headerParams' => [ + [ + 'keyName' => 'agent', + 'fieldAccessors' => [ + 'getAgent', + ], + ], + ], + ], + 'CreateTestCase' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\TestCase', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'GetTestCase' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\TestCase', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetTestCaseResult' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\TestCaseResult', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], ], 'ListTestCaseResults' => [ 'pageStreaming' => [ @@ -52,6 +148,16 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getTestCaseResults', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListTestCaseResultsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], ], 'ListTestCases' => [ 'pageStreaming' => [ @@ -62,8 +168,41 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getTestCases', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListTestCasesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateTestCase' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\TestCase', + 'headerParams' => [ + [ + 'keyName' => 'test_case.name', + 'fieldAccessors' => [ + 'getTestCase', + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -75,8 +214,32 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'agent' => 'projects/{project}/locations/{location}/agents/{agent}', + 'entityType' => 'projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}', + 'environment' => 'projects/{project}/locations/{location}/agents/{agent}/environments/{environment}', + 'flow' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}', + 'intent' => 'projects/{project}/locations/{location}/agents/{agent}/intents/{intent}', + 'page' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}', + 'projectLocationAgentFlowTransitionRouteGroup' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}', + 'projectLocationAgentTransitionRouteGroup' => 'projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group}', + 'testCase' => 'projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}', + 'testCaseResult' => 'projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}/results/{result}', + 'transitionRouteGroup' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}', + 'webhook' => 'projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/transition_route_groups_descriptor_config.php b/DialogflowCx/src/V3/resources/transition_route_groups_descriptor_config.php index d867f54c4c7d..17e42b8a540a 100644 --- a/DialogflowCx/src/V3/resources/transition_route_groups_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/transition_route_groups_descriptor_config.php @@ -3,6 +3,42 @@ return [ 'interfaces' => [ 'google.cloud.dialogflow.cx.v3.TransitionRouteGroups' => [ + 'CreateTransitionRouteGroup' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroup', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteTransitionRouteGroup' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetTransitionRouteGroup' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroup', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'ListTransitionRouteGroups' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -12,8 +48,41 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getTransitionRouteGroups', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListTransitionRouteGroupsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateTransitionRouteGroup' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroup', + 'headerParams' => [ + [ + 'keyName' => 'transition_route_group.name', + 'fieldAccessors' => [ + 'getTransitionRouteGroup', + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -25,8 +94,28 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'agent' => 'projects/{project}/locations/{location}/agents/{agent}', + 'flow' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}', + 'intent' => 'projects/{project}/locations/{location}/agents/{agent}/intents/{intent}', + 'page' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}', + 'projectLocationAgentFlowTransitionRouteGroup' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}', + 'projectLocationAgentTransitionRouteGroup' => 'projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group}', + 'transitionRouteGroup' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}', + 'webhook' => 'projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/versions_descriptor_config.php b/DialogflowCx/src/V3/resources/versions_descriptor_config.php index 290deba46ade..a6194d47bf78 100644 --- a/DialogflowCx/src/V3/resources/versions_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/versions_descriptor_config.php @@ -12,6 +12,15 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], ], 'LoadVersion' => [ 'longRunning' => [ @@ -22,6 +31,51 @@ 'maxPollDelayMillis' => '5000', 'totalPollTimeoutMillis' => '300000', ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'CompareVersions' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\CompareVersionsResponse', + 'headerParams' => [ + [ + 'keyName' => 'base_version', + 'fieldAccessors' => [ + 'getBaseVersion', + ], + ], + ], + ], + 'DeleteVersion' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetVersion' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Version', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], ], 'ListVersions' => [ 'pageStreaming' => [ @@ -32,8 +86,41 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getVersions', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListVersionsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateVersion' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Version', + 'headerParams' => [ + [ + 'keyName' => 'version.name', + 'fieldAccessors' => [ + 'getVersion', + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -45,8 +132,22 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'flow' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}', + 'version' => 'projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}', + ], ], ], ]; diff --git a/DialogflowCx/src/V3/resources/webhooks_descriptor_config.php b/DialogflowCx/src/V3/resources/webhooks_descriptor_config.php index 770ae0765568..232a880bf66b 100644 --- a/DialogflowCx/src/V3/resources/webhooks_descriptor_config.php +++ b/DialogflowCx/src/V3/resources/webhooks_descriptor_config.php @@ -3,6 +3,42 @@ return [ 'interfaces' => [ 'google.cloud.dialogflow.cx.v3.Webhooks' => [ + 'CreateWebhook' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Webhook', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'DeleteWebhook' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'GetWebhook' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Webhook', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'ListWebhooks' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -12,8 +48,41 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getWebhooks', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\ListWebhooksResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateWebhook' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Dialogflow\Cx\V3\Webhook', + 'headerParams' => [ + [ + 'keyName' => 'webhook.name', + 'fieldAccessors' => [ + 'getWebhook', + 'getName', + ], + ], + ], ], 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], 'ListLocations' => [ @@ -25,8 +94,23 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocations', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], 'interfaceOverride' => 'google.cloud.location.Locations', ], + 'templateMap' => [ + 'agent' => 'projects/{project}/locations/{location}/agents/{agent}', + 'service' => 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}', + 'webhook' => 'projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}', + ], ], ], ]; diff --git a/DialogflowCx/tests/Unit/V3/AgentsClientTest.php b/DialogflowCx/tests/Unit/V3/Client/AgentsClientTest.php similarity index 79% rename from DialogflowCx/tests/Unit/V3/AgentsClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/AgentsClientTest.php index ed5e99311a1e..9707ce135d4f 100644 --- a/DialogflowCx/tests/Unit/V3/AgentsClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/AgentsClientTest.php @@ -20,7 +20,7 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; @@ -29,10 +29,23 @@ use Google\ApiCore\Testing\MockTransport; use Google\Cloud\Dialogflow\Cx\V3\Agent; use Google\Cloud\Dialogflow\Cx\V3\AgentValidationResult; -use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\AgentsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateAgentRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeleteAgentRequest; +use Google\Cloud\Dialogflow\Cx\V3\ExportAgentRequest; use Google\Cloud\Dialogflow\Cx\V3\ExportAgentResponse; use Google\Cloud\Dialogflow\Cx\V3\GenerativeSettings; +use Google\Cloud\Dialogflow\Cx\V3\GetAgentRequest; +use Google\Cloud\Dialogflow\Cx\V3\GetAgentValidationResultRequest; +use Google\Cloud\Dialogflow\Cx\V3\GetGenerativeSettingsRequest; +use Google\Cloud\Dialogflow\Cx\V3\ListAgentsRequest; use Google\Cloud\Dialogflow\Cx\V3\ListAgentsResponse; +use Google\Cloud\Dialogflow\Cx\V3\RestoreAgentRequest; +use Google\Cloud\Dialogflow\Cx\V3\UpdateAgentRequest; +use Google\Cloud\Dialogflow\Cx\V3\UpdateGenerativeSettingsRequest; +use Google\Cloud\Dialogflow\Cx\V3\ValidateAgentRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\LongRunning\GetOperationRequest; @@ -58,7 +71,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return AgentsClient */ @@ -112,7 +127,8 @@ public function createAgentTest() $agent->setDefaultLanguageCode($agentDefaultLanguageCode); $agentTimeZone = 'agentTimeZone-453669314'; $agent->setTimeZone($agentTimeZone); - $response = $gapicClient->createAgent($formattedParent, $agent); + $request = (new CreateAgentRequest())->setParent($formattedParent)->setAgent($agent); + $response = $gapicClient->createAgent($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -137,12 +153,15 @@ public function createAgentExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); @@ -153,8 +172,9 @@ public function createAgentExceptionTest() $agent->setDefaultLanguageCode($agentDefaultLanguageCode); $agentTimeZone = 'agentTimeZone-453669314'; $agent->setTimeZone($agentTimeZone); + $request = (new CreateAgentRequest())->setParent($formattedParent)->setAgent($agent); try { - $gapicClient->createAgent($formattedParent, $agent); + $gapicClient->createAgent($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -179,7 +199,8 @@ public function deleteAgentTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $gapicClient->deleteAgent($formattedName); + $request = (new DeleteAgentRequest())->setName($formattedName); + $gapicClient->deleteAgent($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); @@ -201,17 +222,21 @@ public function deleteAgentExceptionTest() $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); + $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->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $request = (new DeleteAgentRequest())->setName($formattedName); try { - $gapicClient->deleteAgent($formattedName); + $gapicClient->deleteAgent($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -256,7 +281,8 @@ public function exportAgentTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->exportAgent($formattedName); + $request = (new ExportAgentRequest())->setName($formattedName); + $response = $gapicClient->exportAgent($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -311,16 +337,20 @@ public function exportAgentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedName = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->exportAgent($formattedName); + $request = (new ExportAgentRequest())->setName($formattedName); + $response = $gapicClient->exportAgent($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -377,7 +407,8 @@ public function getAgentTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->getAgent($formattedName); + $request = (new GetAgentRequest())->setName($formattedName); + $response = $gapicClient->getAgent($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -400,17 +431,21 @@ public function getAgentExceptionTest() $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); + $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->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $request = (new GetAgentRequest())->setName($formattedName); try { - $gapicClient->getAgent($formattedName); + $gapicClient->getAgent($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -437,7 +472,8 @@ public function getAgentValidationResultTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->agentValidationResultName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->getAgentValidationResult($formattedName); + $request = (new GetAgentValidationResultRequest())->setName($formattedName); + $response = $gapicClient->getAgentValidationResult($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -460,17 +496,21 @@ public function getAgentValidationResultExceptionTest() $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); + $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->agentValidationResultName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $request = (new GetAgentValidationResultRequest())->setName($formattedName); try { - $gapicClient->getAgentValidationResult($formattedName); + $gapicClient->getAgentValidationResult($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -500,7 +540,8 @@ public function getGenerativeSettingsTest() // Mock request $formattedName = $gapicClient->agentGenerativeSettingsName('[PROJECT]', '[LOCATION]', '[AGENT]'); $languageCode = 'languageCode-412800396'; - $response = $gapicClient->getGenerativeSettings($formattedName, $languageCode); + $request = (new GetGenerativeSettingsRequest())->setName($formattedName)->setLanguageCode($languageCode); + $response = $gapicClient->getGenerativeSettings($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -525,18 +566,22 @@ public function getGenerativeSettingsExceptionTest() $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); + $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->agentGenerativeSettingsName('[PROJECT]', '[LOCATION]', '[AGENT]'); $languageCode = 'languageCode-412800396'; + $request = (new GetGenerativeSettingsRequest())->setName($formattedName)->setLanguageCode($languageCode); try { - $gapicClient->getGenerativeSettings($formattedName, $languageCode); + $gapicClient->getGenerativeSettings($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -559,16 +604,15 @@ public function listAgentsTest() // Mock response $nextPageToken = ''; $agentsElement = new Agent(); - $agents = [ - $agentsElement, - ]; + $agents = [$agentsElement]; $expectedResponse = new ListAgentsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setAgents($agents); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listAgents($formattedParent); + $request = (new ListAgentsRequest())->setParent($formattedParent); + $response = $gapicClient->listAgents($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -594,17 +638,21 @@ public function listAgentsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); + $request = (new ListAgentsRequest())->setParent($formattedParent); try { - $gapicClient->listAgents($formattedParent); + $gapicClient->listAgents($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -647,7 +695,8 @@ public function restoreAgentTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->restoreAgent($formattedName); + $request = (new RestoreAgentRequest())->setName($formattedName); + $response = $gapicClient->restoreAgent($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -702,16 +751,20 @@ public function restoreAgentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedName = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->restoreAgent($formattedName); + $request = (new RestoreAgentRequest())->setName($formattedName); + $response = $gapicClient->restoreAgent($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -774,7 +827,8 @@ public function updateAgentTest() $agent->setDefaultLanguageCode($agentDefaultLanguageCode); $agentTimeZone = 'agentTimeZone-453669314'; $agent->setTimeZone($agentTimeZone); - $response = $gapicClient->updateAgent($agent); + $request = (new UpdateAgentRequest())->setAgent($agent); + $response = $gapicClient->updateAgent($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -797,12 +851,15 @@ public function updateAgentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $agent = new Agent(); @@ -812,8 +869,9 @@ public function updateAgentExceptionTest() $agent->setDefaultLanguageCode($agentDefaultLanguageCode); $agentTimeZone = 'agentTimeZone-453669314'; $agent->setTimeZone($agentTimeZone); + $request = (new UpdateAgentRequest())->setAgent($agent); try { - $gapicClient->updateAgent($agent); + $gapicClient->updateAgent($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -842,7 +900,8 @@ public function updateGenerativeSettingsTest() $transport->addResponse($expectedResponse); // Mock request $generativeSettings = new GenerativeSettings(); - $response = $gapicClient->updateGenerativeSettings($generativeSettings); + $request = (new UpdateGenerativeSettingsRequest())->setGenerativeSettings($generativeSettings); + $response = $gapicClient->updateGenerativeSettings($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -865,17 +924,21 @@ public function updateGenerativeSettingsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $generativeSettings = new GenerativeSettings(); + $request = (new UpdateGenerativeSettingsRequest())->setGenerativeSettings($generativeSettings); try { - $gapicClient->updateGenerativeSettings($generativeSettings); + $gapicClient->updateGenerativeSettings($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -902,7 +965,8 @@ public function validateAgentTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->validateAgent($formattedName); + $request = (new ValidateAgentRequest())->setName($formattedName); + $response = $gapicClient->validateAgent($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -925,17 +989,21 @@ public function validateAgentExceptionTest() $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); + $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->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $request = (new ValidateAgentRequest())->setName($formattedName); try { - $gapicClient->validateAgent($formattedName); + $gapicClient->validateAgent($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -964,7 +1032,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -985,15 +1054,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -1016,14 +1089,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -1047,15 +1119,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -1066,4 +1142,61 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function createAgentAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $defaultLanguageCode = 'defaultLanguageCode856575222'; + $timeZone = 'timeZone36848094'; + $description = 'description-1724546052'; + $avatarUri = 'avatarUri-402824826'; + $startFlow = 'startFlow-1573559573'; + $securitySettings = 'securitySettings-595091902'; + $enableStackdriverLogging = true; + $enableSpellCorrection = false; + $locked = true; + $expectedResponse = new Agent(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDefaultLanguageCode($defaultLanguageCode); + $expectedResponse->setTimeZone($timeZone); + $expectedResponse->setDescription($description); + $expectedResponse->setAvatarUri($avatarUri); + $expectedResponse->setStartFlow($startFlow); + $expectedResponse->setSecuritySettings($securitySettings); + $expectedResponse->setEnableStackdriverLogging($enableStackdriverLogging); + $expectedResponse->setEnableSpellCorrection($enableSpellCorrection); + $expectedResponse->setLocked($locked); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $agent = new Agent(); + $agentDisplayName = 'agentDisplayName2121176616'; + $agent->setDisplayName($agentDisplayName); + $agentDefaultLanguageCode = 'agentDefaultLanguageCode-1905463551'; + $agent->setDefaultLanguageCode($agentDefaultLanguageCode); + $agentTimeZone = 'agentTimeZone-453669314'; + $agent->setTimeZone($agentTimeZone); + $request = (new CreateAgentRequest())->setParent($formattedParent)->setAgent($agent); + $response = $gapicClient->createAgentAsync($request)->wait(); + $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.Agents/CreateAgent', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getAgent(); + $this->assertProtobufEquals($agent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/ChangelogsClientTest.php b/DialogflowCx/tests/Unit/V3/Client/ChangelogsClientTest.php similarity index 72% rename from DialogflowCx/tests/Unit/V3/ChangelogsClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/ChangelogsClientTest.php index c10c83a239f0..bdb7312cdc8f 100644 --- a/DialogflowCx/tests/Unit/V3/ChangelogsClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/ChangelogsClientTest.php @@ -20,15 +20,19 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; use Google\Cloud\Dialogflow\Cx\V3\Changelog; -use Google\Cloud\Dialogflow\Cx\V3\ChangelogsClient; +use Google\Cloud\Dialogflow\Cx\V3\Client\ChangelogsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetChangelogRequest; +use Google\Cloud\Dialogflow\Cx\V3\ListChangelogsRequest; use Google\Cloud\Dialogflow\Cx\V3\ListChangelogsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\Rpc\Code; @@ -50,7 +54,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return ChangelogsClient */ @@ -87,7 +93,8 @@ public function getChangelogTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->changelogName('[PROJECT]', '[LOCATION]', '[AGENT]', '[CHANGELOG]'); - $response = $gapicClient->getChangelog($formattedName); + $request = (new GetChangelogRequest())->setName($formattedName); + $response = $gapicClient->getChangelog($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -110,17 +117,21 @@ public function getChangelogExceptionTest() $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); + $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->changelogName('[PROJECT]', '[LOCATION]', '[AGENT]', '[CHANGELOG]'); + $request = (new GetChangelogRequest())->setName($formattedName); try { - $gapicClient->getChangelog($formattedName); + $gapicClient->getChangelog($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -143,16 +154,15 @@ public function listChangelogsTest() // Mock response $nextPageToken = ''; $changelogsElement = new Changelog(); - $changelogs = [ - $changelogsElement, - ]; + $changelogs = [$changelogsElement]; $expectedResponse = new ListChangelogsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setChangelogs($changelogs); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->listChangelogs($formattedParent); + $request = (new ListChangelogsRequest())->setParent($formattedParent); + $response = $gapicClient->listChangelogs($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -178,17 +188,21 @@ public function listChangelogsExceptionTest() $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); + $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]'); + $request = (new ListChangelogsRequest())->setParent($formattedParent); try { - $gapicClient->listChangelogs($formattedParent); + $gapicClient->listChangelogs($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -217,7 +231,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -238,15 +253,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -269,14 +288,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -300,15 +318,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -319,4 +341,42 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function getChangelogAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $userEmail = 'userEmail1921668648'; + $displayName = 'displayName1615086568'; + $action = 'action-1422950858'; + $type = 'type3575610'; + $resource = 'resource-341064690'; + $expectedResponse = new Changelog(); + $expectedResponse->setName($name2); + $expectedResponse->setUserEmail($userEmail); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setAction($action); + $expectedResponse->setType($type); + $expectedResponse->setResource($resource); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->changelogName('[PROJECT]', '[LOCATION]', '[AGENT]', '[CHANGELOG]'); + $request = (new GetChangelogRequest())->setName($formattedName); + $response = $gapicClient->getChangelogAsync($request)->wait(); + $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.Changelogs/GetChangelog', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/DeploymentsClientTest.php b/DialogflowCx/tests/Unit/V3/Client/DeploymentsClientTest.php similarity index 70% rename from DialogflowCx/tests/Unit/V3/DeploymentsClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/DeploymentsClientTest.php index cafa722498f4..a30d96a4dcce 100644 --- a/DialogflowCx/tests/Unit/V3/DeploymentsClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/DeploymentsClientTest.php @@ -20,15 +20,19 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\Client\DeploymentsClient; use Google\Cloud\Dialogflow\Cx\V3\Deployment; -use Google\Cloud\Dialogflow\Cx\V3\DeploymentsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetDeploymentRequest; +use Google\Cloud\Dialogflow\Cx\V3\ListDeploymentsRequest; use Google\Cloud\Dialogflow\Cx\V3\ListDeploymentsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\Rpc\Code; @@ -50,7 +54,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return DeploymentsClient */ @@ -78,8 +84,15 @@ public function getDeploymentTest() $expectedResponse->setFlowVersion($flowVersion); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->deploymentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[DEPLOYMENT]'); - $response = $gapicClient->getDeployment($formattedName); + $formattedName = $gapicClient->deploymentName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[ENVIRONMENT]', + '[DEPLOYMENT]' + ); + $request = (new GetDeploymentRequest())->setName($formattedName); + $response = $gapicClient->getDeployment($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -102,17 +115,27 @@ public function getDeploymentExceptionTest() $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); + $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->deploymentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[DEPLOYMENT]'); + $formattedName = $gapicClient->deploymentName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[ENVIRONMENT]', + '[DEPLOYMENT]' + ); + $request = (new GetDeploymentRequest())->setName($formattedName); try { - $gapicClient->getDeployment($formattedName); + $gapicClient->getDeployment($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -135,16 +158,15 @@ public function listDeploymentsTest() // Mock response $nextPageToken = ''; $deploymentsElement = new Deployment(); - $deployments = [ - $deploymentsElement, - ]; + $deployments = [$deploymentsElement]; $expectedResponse = new ListDeploymentsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setDeployments($deployments); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - $response = $gapicClient->listDeployments($formattedParent); + $request = (new ListDeploymentsRequest())->setParent($formattedParent); + $response = $gapicClient->listDeployments($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -170,17 +192,21 @@ public function listDeploymentsExceptionTest() $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); + $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->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); + $request = (new ListDeploymentsRequest())->setParent($formattedParent); try { - $gapicClient->listDeployments($formattedParent); + $gapicClient->listDeployments($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -209,7 +235,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -230,15 +257,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -261,14 +292,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -292,15 +322,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -311,4 +345,40 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function getDeploymentAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $flowVersion = 'flowVersion1517270727'; + $expectedResponse = new Deployment(); + $expectedResponse->setName($name2); + $expectedResponse->setFlowVersion($flowVersion); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->deploymentName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[ENVIRONMENT]', + '[DEPLOYMENT]' + ); + $request = (new GetDeploymentRequest())->setName($formattedName); + $response = $gapicClient->getDeploymentAsync($request)->wait(); + $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.Deployments/GetDeployment', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/EntityTypesClientTest.php b/DialogflowCx/tests/Unit/V3/Client/EntityTypesClientTest.php similarity index 74% rename from DialogflowCx/tests/Unit/V3/EntityTypesClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/EntityTypesClientTest.php index 6272187aece0..0dc9e5c99591 100644 --- a/DialogflowCx/tests/Unit/V3/EntityTypesClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/EntityTypesClientTest.php @@ -20,16 +20,23 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\Client\EntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateEntityTypeRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeleteEntityTypeRequest; use Google\Cloud\Dialogflow\Cx\V3\EntityType; use Google\Cloud\Dialogflow\Cx\V3\EntityType\Kind; -use Google\Cloud\Dialogflow\Cx\V3\EntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\GetEntityTypeRequest; +use Google\Cloud\Dialogflow\Cx\V3\ListEntityTypesRequest; use Google\Cloud\Dialogflow\Cx\V3\ListEntityTypesResponse; +use Google\Cloud\Dialogflow\Cx\V3\UpdateEntityTypeRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\Protobuf\GPBEmpty; @@ -52,7 +59,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return EntityTypesClient */ @@ -90,7 +99,8 @@ public function createEntityTypeTest() $entityType->setDisplayName($entityTypeDisplayName); $entityTypeKind = Kind::KIND_UNSPECIFIED; $entityType->setKind($entityTypeKind); - $response = $gapicClient->createEntityType($formattedParent, $entityType); + $request = (new CreateEntityTypeRequest())->setParent($formattedParent)->setEntityType($entityType); + $response = $gapicClient->createEntityType($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -115,12 +125,15 @@ public function createEntityTypeExceptionTest() $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); + $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]'); @@ -129,8 +142,9 @@ public function createEntityTypeExceptionTest() $entityType->setDisplayName($entityTypeDisplayName); $entityTypeKind = Kind::KIND_UNSPECIFIED; $entityType->setKind($entityTypeKind); + $request = (new CreateEntityTypeRequest())->setParent($formattedParent)->setEntityType($entityType); try { - $gapicClient->createEntityType($formattedParent, $entityType); + $gapicClient->createEntityType($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -155,7 +169,8 @@ public function deleteEntityTypeTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->entityTypeName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENTITY_TYPE]'); - $gapicClient->deleteEntityType($formattedName); + $request = (new DeleteEntityTypeRequest())->setName($formattedName); + $gapicClient->deleteEntityType($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); @@ -177,17 +192,21 @@ public function deleteEntityTypeExceptionTest() $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); + $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->entityTypeName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENTITY_TYPE]'); + $request = (new DeleteEntityTypeRequest())->setName($formattedName); try { - $gapicClient->deleteEntityType($formattedName); + $gapicClient->deleteEntityType($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -220,7 +239,8 @@ public function getEntityTypeTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->entityTypeName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENTITY_TYPE]'); - $response = $gapicClient->getEntityType($formattedName); + $request = (new GetEntityTypeRequest())->setName($formattedName); + $response = $gapicClient->getEntityType($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -243,17 +263,21 @@ public function getEntityTypeExceptionTest() $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); + $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->entityTypeName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENTITY_TYPE]'); + $request = (new GetEntityTypeRequest())->setName($formattedName); try { - $gapicClient->getEntityType($formattedName); + $gapicClient->getEntityType($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -276,16 +300,15 @@ public function listEntityTypesTest() // Mock response $nextPageToken = ''; $entityTypesElement = new EntityType(); - $entityTypes = [ - $entityTypesElement, - ]; + $entityTypes = [$entityTypesElement]; $expectedResponse = new ListEntityTypesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setEntityTypes($entityTypes); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->listEntityTypes($formattedParent); + $request = (new ListEntityTypesRequest())->setParent($formattedParent); + $response = $gapicClient->listEntityTypes($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -311,17 +334,21 @@ public function listEntityTypesExceptionTest() $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); + $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]'); + $request = (new ListEntityTypesRequest())->setParent($formattedParent); try { - $gapicClient->listEntityTypes($formattedParent); + $gapicClient->listEntityTypes($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -358,7 +385,8 @@ public function updateEntityTypeTest() $entityType->setDisplayName($entityTypeDisplayName); $entityTypeKind = Kind::KIND_UNSPECIFIED; $entityType->setKind($entityTypeKind); - $response = $gapicClient->updateEntityType($entityType); + $request = (new UpdateEntityTypeRequest())->setEntityType($entityType); + $response = $gapicClient->updateEntityType($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -381,12 +409,15 @@ public function updateEntityTypeExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $entityType = new EntityType(); @@ -394,8 +425,9 @@ public function updateEntityTypeExceptionTest() $entityType->setDisplayName($entityTypeDisplayName); $entityTypeKind = Kind::KIND_UNSPECIFIED; $entityType->setKind($entityTypeKind); + $request = (new UpdateEntityTypeRequest())->setEntityType($entityType); try { - $gapicClient->updateEntityType($entityType); + $gapicClient->updateEntityType($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -424,7 +456,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -445,15 +478,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -476,14 +513,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -507,15 +543,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -526,4 +566,45 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function createEntityTypeAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $enableFuzzyExtraction = true; + $redact = false; + $expectedResponse = new EntityType(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setEnableFuzzyExtraction($enableFuzzyExtraction); + $expectedResponse->setRedact($redact); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $entityType = new EntityType(); + $entityTypeDisplayName = 'entityTypeDisplayName-441894800'; + $entityType->setDisplayName($entityTypeDisplayName); + $entityTypeKind = Kind::KIND_UNSPECIFIED; + $entityType->setKind($entityTypeKind); + $request = (new CreateEntityTypeRequest())->setParent($formattedParent)->setEntityType($entityType); + $response = $gapicClient->createEntityTypeAsync($request)->wait(); + $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.EntityTypes/CreateEntityType', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getEntityType(); + $this->assertProtobufEquals($entityType, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/EnvironmentsClientTest.php b/DialogflowCx/tests/Unit/V3/Client/EnvironmentsClientTest.php similarity index 78% rename from DialogflowCx/tests/Unit/V3/EnvironmentsClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/EnvironmentsClientTest.php index ea2f03077926..6dde3e39f8f9 100644 --- a/DialogflowCx/tests/Unit/V3/EnvironmentsClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/EnvironmentsClientTest.php @@ -20,21 +20,32 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\Client\EnvironmentsClient; use Google\Cloud\Dialogflow\Cx\V3\ContinuousTestResult; +use Google\Cloud\Dialogflow\Cx\V3\CreateEnvironmentRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeleteEnvironmentRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeployFlowRequest; use Google\Cloud\Dialogflow\Cx\V3\DeployFlowResponse; use Google\Cloud\Dialogflow\Cx\V3\Environment; -use Google\Cloud\Dialogflow\Cx\V3\EnvironmentsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetEnvironmentRequest; +use Google\Cloud\Dialogflow\Cx\V3\ListContinuousTestResultsRequest; use Google\Cloud\Dialogflow\Cx\V3\ListContinuousTestResultsResponse; +use Google\Cloud\Dialogflow\Cx\V3\ListEnvironmentsRequest; use Google\Cloud\Dialogflow\Cx\V3\ListEnvironmentsResponse; +use Google\Cloud\Dialogflow\Cx\V3\LookupEnvironmentHistoryRequest; use Google\Cloud\Dialogflow\Cx\V3\LookupEnvironmentHistoryResponse; +use Google\Cloud\Dialogflow\Cx\V3\RunContinuousTestRequest; use Google\Cloud\Dialogflow\Cx\V3\RunContinuousTestResponse; +use Google\Cloud\Dialogflow\Cx\V3\UpdateEnvironmentRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\LongRunning\GetOperationRequest; @@ -61,7 +72,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return EnvironmentsClient */ @@ -113,7 +126,8 @@ public function createEnvironmentTest() $environment = new Environment(); $environmentDisplayName = 'environmentDisplayName747655770'; $environment->setDisplayName($environmentDisplayName); - $response = $gapicClient->createEnvironment($formattedParent, $environment); + $request = (new CreateEnvironmentRequest())->setParent($formattedParent)->setEnvironment($environment); + $response = $gapicClient->createEnvironment($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -170,19 +184,23 @@ public function createEnvironmentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); $environment = new Environment(); $environmentDisplayName = 'environmentDisplayName747655770'; $environment->setDisplayName($environmentDisplayName); - $response = $gapicClient->createEnvironment($formattedParent, $environment); + $request = (new CreateEnvironmentRequest())->setParent($formattedParent)->setEnvironment($environment); + $response = $gapicClient->createEnvironment($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -217,7 +235,8 @@ public function deleteEnvironmentTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - $gapicClient->deleteEnvironment($formattedName); + $request = (new DeleteEnvironmentRequest())->setName($formattedName); + $gapicClient->deleteEnvironment($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); @@ -239,17 +258,21 @@ public function deleteEnvironmentExceptionTest() $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); + $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->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); + $request = (new DeleteEnvironmentRequest())->setName($formattedName); try { - $gapicClient->deleteEnvironment($formattedName); + $gapicClient->deleteEnvironment($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -295,7 +318,10 @@ public function deployFlowTest() // Mock request $formattedEnvironment = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); $formattedFlowVersion = $gapicClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - $response = $gapicClient->deployFlow($formattedEnvironment, $formattedFlowVersion); + $request = (new DeployFlowRequest()) + ->setEnvironment($formattedEnvironment) + ->setFlowVersion($formattedFlowVersion); + $response = $gapicClient->deployFlow($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -352,17 +378,23 @@ public function deployFlowExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedEnvironment = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); $formattedFlowVersion = $gapicClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - $response = $gapicClient->deployFlow($formattedEnvironment, $formattedFlowVersion); + $request = (new DeployFlowRequest()) + ->setEnvironment($formattedEnvironment) + ->setFlowVersion($formattedFlowVersion); + $response = $gapicClient->deployFlow($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -403,7 +435,8 @@ public function getEnvironmentTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - $response = $gapicClient->getEnvironment($formattedName); + $request = (new GetEnvironmentRequest())->setName($formattedName); + $response = $gapicClient->getEnvironment($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -426,17 +459,21 @@ public function getEnvironmentExceptionTest() $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); + $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->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); + $request = (new GetEnvironmentRequest())->setName($formattedName); try { - $gapicClient->getEnvironment($formattedName); + $gapicClient->getEnvironment($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -459,16 +496,15 @@ public function listContinuousTestResultsTest() // Mock response $nextPageToken = ''; $continuousTestResultsElement = new ContinuousTestResult(); - $continuousTestResults = [ - $continuousTestResultsElement, - ]; + $continuousTestResults = [$continuousTestResultsElement]; $expectedResponse = new ListContinuousTestResultsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setContinuousTestResults($continuousTestResults); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - $response = $gapicClient->listContinuousTestResults($formattedParent); + $request = (new ListContinuousTestResultsRequest())->setParent($formattedParent); + $response = $gapicClient->listContinuousTestResults($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -494,17 +530,21 @@ public function listContinuousTestResultsExceptionTest() $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); + $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->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); + $request = (new ListContinuousTestResultsRequest())->setParent($formattedParent); try { - $gapicClient->listContinuousTestResults($formattedParent); + $gapicClient->listContinuousTestResults($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -527,16 +567,15 @@ public function listEnvironmentsTest() // Mock response $nextPageToken = ''; $environmentsElement = new Environment(); - $environments = [ - $environmentsElement, - ]; + $environments = [$environmentsElement]; $expectedResponse = new ListEnvironmentsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setEnvironments($environments); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->listEnvironments($formattedParent); + $request = (new ListEnvironmentsRequest())->setParent($formattedParent); + $response = $gapicClient->listEnvironments($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -562,17 +601,21 @@ public function listEnvironmentsExceptionTest() $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); + $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]'); + $request = (new ListEnvironmentsRequest())->setParent($formattedParent); try { - $gapicClient->listEnvironments($formattedParent); + $gapicClient->listEnvironments($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -595,16 +638,15 @@ public function lookupEnvironmentHistoryTest() // Mock response $nextPageToken = ''; $environmentsElement = new Environment(); - $environments = [ - $environmentsElement, - ]; + $environments = [$environmentsElement]; $expectedResponse = new LookupEnvironmentHistoryResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setEnvironments($environments); $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - $response = $gapicClient->lookupEnvironmentHistory($formattedName); + $request = (new LookupEnvironmentHistoryRequest())->setName($formattedName); + $response = $gapicClient->lookupEnvironmentHistory($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -630,17 +672,21 @@ public function lookupEnvironmentHistoryExceptionTest() $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); + $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->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); + $request = (new LookupEnvironmentHistoryRequest())->setName($formattedName); try { - $gapicClient->lookupEnvironmentHistory($formattedName); + $gapicClient->lookupEnvironmentHistory($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -683,7 +729,8 @@ public function runContinuousTestTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedEnvironment = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - $response = $gapicClient->runContinuousTest($formattedEnvironment); + $request = (new RunContinuousTestRequest())->setEnvironment($formattedEnvironment); + $response = $gapicClient->runContinuousTest($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -738,16 +785,20 @@ public function runContinuousTestExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedEnvironment = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - $response = $gapicClient->runContinuousTest($formattedEnvironment); + $request = (new RunContinuousTestRequest())->setEnvironment($formattedEnvironment); + $response = $gapicClient->runContinuousTest($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -809,7 +860,8 @@ public function updateEnvironmentTest() $environmentDisplayName = 'environmentDisplayName747655770'; $environment->setDisplayName($environmentDisplayName); $updateMask = new FieldMask(); - $response = $gapicClient->updateEnvironment($environment, $updateMask); + $request = (new UpdateEnvironmentRequest())->setEnvironment($environment)->setUpdateMask($updateMask); + $response = $gapicClient->updateEnvironment($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -866,19 +918,23 @@ public function updateEnvironmentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $environment = new Environment(); $environmentDisplayName = 'environmentDisplayName747655770'; $environment->setDisplayName($environmentDisplayName); $updateMask = new FieldMask(); - $response = $gapicClient->updateEnvironment($environment, $updateMask); + $request = (new UpdateEnvironmentRequest())->setEnvironment($environment)->setUpdateMask($updateMask); + $response = $gapicClient->updateEnvironment($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -917,7 +973,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -938,15 +995,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -969,14 +1030,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -1000,15 +1060,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -1019,4 +1083,78 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function createEnvironmentAsyncTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createEnvironmentTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $description = 'description-1724546052'; + $expectedResponse = new Environment(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDescription($description); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createEnvironmentTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $environment = new Environment(); + $environmentDisplayName = 'environmentDisplayName747655770'; + $environment->setDisplayName($environmentDisplayName); + $request = (new CreateEnvironmentRequest())->setParent($formattedParent)->setEnvironment($environment); + $response = $gapicClient->createEnvironmentAsync($request)->wait(); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.dialogflow.cx.v3.Environments/CreateEnvironment', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getEnvironment(); + $this->assertProtobufEquals($environment, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createEnvironmentTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/ExperimentsClientTest.php b/DialogflowCx/tests/Unit/V3/Client/ExperimentsClientTest.php similarity index 71% rename from DialogflowCx/tests/Unit/V3/ExperimentsClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/ExperimentsClientTest.php index efdfc0f6824c..39a90c7f633d 100644 --- a/DialogflowCx/tests/Unit/V3/ExperimentsClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/ExperimentsClientTest.php @@ -20,15 +20,24 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\Client\ExperimentsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateExperimentRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeleteExperimentRequest; use Google\Cloud\Dialogflow\Cx\V3\Experiment; -use Google\Cloud\Dialogflow\Cx\V3\ExperimentsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetExperimentRequest; +use Google\Cloud\Dialogflow\Cx\V3\ListExperimentsRequest; use Google\Cloud\Dialogflow\Cx\V3\ListExperimentsResponse; +use Google\Cloud\Dialogflow\Cx\V3\StartExperimentRequest; +use Google\Cloud\Dialogflow\Cx\V3\StopExperimentRequest; +use Google\Cloud\Dialogflow\Cx\V3\UpdateExperimentRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\Protobuf\FieldMask; @@ -52,7 +61,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return ExperimentsClient */ @@ -88,7 +99,8 @@ public function createExperimentTest() $experiment = new Experiment(); $experimentDisplayName = 'experimentDisplayName-1508560336'; $experiment->setDisplayName($experimentDisplayName); - $response = $gapicClient->createExperiment($formattedParent, $experiment); + $request = (new CreateExperimentRequest())->setParent($formattedParent)->setExperiment($experiment); + $response = $gapicClient->createExperiment($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -113,20 +125,24 @@ public function createExperimentExceptionTest() $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); + $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->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); $experiment = new Experiment(); $experimentDisplayName = 'experimentDisplayName-1508560336'; $experiment->setDisplayName($experimentDisplayName); + $request = (new CreateExperimentRequest())->setParent($formattedParent)->setExperiment($experiment); try { - $gapicClient->createExperiment($formattedParent, $experiment); + $gapicClient->createExperiment($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -150,8 +166,15 @@ public function deleteExperimentTest() $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->experimentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[EXPERIMENT]'); - $gapicClient->deleteExperiment($formattedName); + $formattedName = $gapicClient->experimentName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[ENVIRONMENT]', + '[EXPERIMENT]' + ); + $request = (new DeleteExperimentRequest())->setName($formattedName); + $gapicClient->deleteExperiment($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); @@ -173,17 +196,27 @@ public function deleteExperimentExceptionTest() $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); + $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->experimentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[EXPERIMENT]'); + $formattedName = $gapicClient->experimentName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[ENVIRONMENT]', + '[EXPERIMENT]' + ); + $request = (new DeleteExperimentRequest())->setName($formattedName); try { - $gapicClient->deleteExperiment($formattedName); + $gapicClient->deleteExperiment($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -215,8 +248,15 @@ public function getExperimentTest() $expectedResponse->setRolloutFailureReason($rolloutFailureReason); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->experimentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[EXPERIMENT]'); - $response = $gapicClient->getExperiment($formattedName); + $formattedName = $gapicClient->experimentName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[ENVIRONMENT]', + '[EXPERIMENT]' + ); + $request = (new GetExperimentRequest())->setName($formattedName); + $response = $gapicClient->getExperiment($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -239,17 +279,27 @@ public function getExperimentExceptionTest() $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); + $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->experimentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[EXPERIMENT]'); + $formattedName = $gapicClient->experimentName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[ENVIRONMENT]', + '[EXPERIMENT]' + ); + $request = (new GetExperimentRequest())->setName($formattedName); try { - $gapicClient->getExperiment($formattedName); + $gapicClient->getExperiment($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -272,16 +322,15 @@ public function listExperimentsTest() // Mock response $nextPageToken = ''; $experimentsElement = new Experiment(); - $experiments = [ - $experimentsElement, - ]; + $experiments = [$experimentsElement]; $expectedResponse = new ListExperimentsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setExperiments($experiments); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); - $response = $gapicClient->listExperiments($formattedParent); + $request = (new ListExperimentsRequest())->setParent($formattedParent); + $response = $gapicClient->listExperiments($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -307,17 +356,21 @@ public function listExperimentsExceptionTest() $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); + $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->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); + $request = (new ListExperimentsRequest())->setParent($formattedParent); try { - $gapicClient->listExperiments($formattedParent); + $gapicClient->listExperiments($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -349,8 +402,15 @@ public function startExperimentTest() $expectedResponse->setRolloutFailureReason($rolloutFailureReason); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->experimentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[EXPERIMENT]'); - $response = $gapicClient->startExperiment($formattedName); + $formattedName = $gapicClient->experimentName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[ENVIRONMENT]', + '[EXPERIMENT]' + ); + $request = (new StartExperimentRequest())->setName($formattedName); + $response = $gapicClient->startExperiment($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -373,17 +433,27 @@ public function startExperimentExceptionTest() $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); + $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->experimentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[EXPERIMENT]'); + $formattedName = $gapicClient->experimentName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[ENVIRONMENT]', + '[EXPERIMENT]' + ); + $request = (new StartExperimentRequest())->setName($formattedName); try { - $gapicClient->startExperiment($formattedName); + $gapicClient->startExperiment($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -415,8 +485,15 @@ public function stopExperimentTest() $expectedResponse->setRolloutFailureReason($rolloutFailureReason); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->experimentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[EXPERIMENT]'); - $response = $gapicClient->stopExperiment($formattedName); + $formattedName = $gapicClient->experimentName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[ENVIRONMENT]', + '[EXPERIMENT]' + ); + $request = (new StopExperimentRequest())->setName($formattedName); + $response = $gapicClient->stopExperiment($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -439,17 +516,27 @@ public function stopExperimentExceptionTest() $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); + $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->experimentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]', '[EXPERIMENT]'); + $formattedName = $gapicClient->experimentName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[ENVIRONMENT]', + '[EXPERIMENT]' + ); + $request = (new StopExperimentRequest())->setName($formattedName); try { - $gapicClient->stopExperiment($formattedName); + $gapicClient->stopExperiment($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -485,7 +572,8 @@ public function updateExperimentTest() $experimentDisplayName = 'experimentDisplayName-1508560336'; $experiment->setDisplayName($experimentDisplayName); $updateMask = new FieldMask(); - $response = $gapicClient->updateExperiment($experiment, $updateMask); + $request = (new UpdateExperimentRequest())->setExperiment($experiment)->setUpdateMask($updateMask); + $response = $gapicClient->updateExperiment($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -510,20 +598,24 @@ public function updateExperimentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $experiment = new Experiment(); $experimentDisplayName = 'experimentDisplayName-1508560336'; $experiment->setDisplayName($experimentDisplayName); $updateMask = new FieldMask(); + $request = (new UpdateExperimentRequest())->setExperiment($experiment)->setUpdateMask($updateMask); try { - $gapicClient->updateExperiment($experiment, $updateMask); + $gapicClient->updateExperiment($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -552,7 +644,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -573,15 +666,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -604,14 +701,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -635,15 +731,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -654,4 +754,43 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function createExperimentAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $description = 'description-1724546052'; + $rolloutFailureReason = 'rolloutFailureReason-379444505'; + $expectedResponse = new Experiment(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDescription($description); + $expectedResponse->setRolloutFailureReason($rolloutFailureReason); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->environmentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[ENVIRONMENT]'); + $experiment = new Experiment(); + $experimentDisplayName = 'experimentDisplayName-1508560336'; + $experiment->setDisplayName($experimentDisplayName); + $request = (new CreateExperimentRequest())->setParent($formattedParent)->setExperiment($experiment); + $response = $gapicClient->createExperimentAsync($request)->wait(); + $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.Experiments/CreateExperiment', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getExperiment(); + $this->assertProtobufEquals($experiment, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/FlowsClientTest.php b/DialogflowCx/tests/Unit/V3/Client/FlowsClientTest.php similarity index 81% rename from DialogflowCx/tests/Unit/V3/FlowsClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/FlowsClientTest.php index d3480baa97f6..722f13118178 100644 --- a/DialogflowCx/tests/Unit/V3/FlowsClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/FlowsClientTest.php @@ -20,19 +20,31 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\Client\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateFlowRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeleteFlowRequest; +use Google\Cloud\Dialogflow\Cx\V3\ExportFlowRequest; use Google\Cloud\Dialogflow\Cx\V3\ExportFlowResponse; use Google\Cloud\Dialogflow\Cx\V3\Flow; use Google\Cloud\Dialogflow\Cx\V3\FlowValidationResult; -use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetFlowRequest; +use Google\Cloud\Dialogflow\Cx\V3\GetFlowValidationResultRequest; +use Google\Cloud\Dialogflow\Cx\V3\ImportFlowRequest; use Google\Cloud\Dialogflow\Cx\V3\ImportFlowResponse; +use Google\Cloud\Dialogflow\Cx\V3\ListFlowsRequest; use Google\Cloud\Dialogflow\Cx\V3\ListFlowsResponse; +use Google\Cloud\Dialogflow\Cx\V3\TrainFlowRequest; +use Google\Cloud\Dialogflow\Cx\V3\UpdateFlowRequest; +use Google\Cloud\Dialogflow\Cx\V3\ValidateFlowRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\LongRunning\GetOperationRequest; @@ -58,7 +70,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return FlowsClient */ @@ -92,7 +106,8 @@ public function createFlowTest() $flow = new Flow(); $flowDisplayName = 'flowDisplayName-554265505'; $flow->setDisplayName($flowDisplayName); - $response = $gapicClient->createFlow($formattedParent, $flow); + $request = (new CreateFlowRequest())->setParent($formattedParent)->setFlow($flow); + $response = $gapicClient->createFlow($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -117,20 +132,24 @@ public function createFlowExceptionTest() $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); + $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]'); $flow = new Flow(); $flowDisplayName = 'flowDisplayName-554265505'; $flow->setDisplayName($flowDisplayName); + $request = (new CreateFlowRequest())->setParent($formattedParent)->setFlow($flow); try { - $gapicClient->createFlow($formattedParent, $flow); + $gapicClient->createFlow($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -155,7 +174,8 @@ public function deleteFlowTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - $gapicClient->deleteFlow($formattedName); + $request = (new DeleteFlowRequest())->setName($formattedName); + $gapicClient->deleteFlow($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); @@ -177,17 +197,21 @@ public function deleteFlowExceptionTest() $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); + $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->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); + $request = (new DeleteFlowRequest())->setName($formattedName); try { - $gapicClient->deleteFlow($formattedName); + $gapicClient->deleteFlow($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -232,7 +256,8 @@ public function exportFlowTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - $response = $gapicClient->exportFlow($formattedName); + $request = (new ExportFlowRequest())->setName($formattedName); + $response = $gapicClient->exportFlow($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -287,16 +312,20 @@ public function exportFlowExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedName = $gapicClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - $response = $gapicClient->exportFlow($formattedName); + $request = (new ExportFlowRequest())->setName($formattedName); + $response = $gapicClient->exportFlow($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -337,7 +366,8 @@ public function getFlowTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - $response = $gapicClient->getFlow($formattedName); + $request = (new GetFlowRequest())->setName($formattedName); + $response = $gapicClient->getFlow($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -360,17 +390,21 @@ public function getFlowExceptionTest() $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); + $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->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); + $request = (new GetFlowRequest())->setName($formattedName); try { - $gapicClient->getFlow($formattedName); + $gapicClient->getFlow($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -397,7 +431,8 @@ public function getFlowValidationResultTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->flowValidationResultName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - $response = $gapicClient->getFlowValidationResult($formattedName); + $request = (new GetFlowValidationResultRequest())->setName($formattedName); + $response = $gapicClient->getFlowValidationResult($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -420,17 +455,21 @@ public function getFlowValidationResultExceptionTest() $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); + $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->flowValidationResultName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); + $request = (new GetFlowValidationResultRequest())->setName($formattedName); try { - $gapicClient->getFlowValidationResult($formattedName); + $gapicClient->getFlowValidationResult($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -475,7 +514,8 @@ public function importFlowTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->importFlow($formattedParent); + $request = (new ImportFlowRequest())->setParent($formattedParent); + $response = $gapicClient->importFlow($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -530,16 +570,20 @@ public function importFlowExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->importFlow($formattedParent); + $request = (new ImportFlowRequest())->setParent($formattedParent); + $response = $gapicClient->importFlow($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -572,16 +616,15 @@ public function listFlowsTest() // Mock response $nextPageToken = ''; $flowsElement = new Flow(); - $flows = [ - $flowsElement, - ]; + $flows = [$flowsElement]; $expectedResponse = new ListFlowsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setFlows($flows); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->listFlows($formattedParent); + $request = (new ListFlowsRequest())->setParent($formattedParent); + $response = $gapicClient->listFlows($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -607,17 +650,21 @@ public function listFlowsExceptionTest() $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); + $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]'); + $request = (new ListFlowsRequest())->setParent($formattedParent); try { - $gapicClient->listFlows($formattedParent); + $gapicClient->listFlows($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -660,7 +707,8 @@ public function trainFlowTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - $response = $gapicClient->trainFlow($formattedName); + $request = (new TrainFlowRequest())->setName($formattedName); + $response = $gapicClient->trainFlow($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -715,16 +763,20 @@ public function trainFlowExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedName = $gapicClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - $response = $gapicClient->trainFlow($formattedName); + $request = (new TrainFlowRequest())->setName($formattedName); + $response = $gapicClient->trainFlow($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -767,7 +819,8 @@ public function updateFlowTest() $flow = new Flow(); $flowDisplayName = 'flowDisplayName-554265505'; $flow->setDisplayName($flowDisplayName); - $response = $gapicClient->updateFlow($flow); + $request = (new UpdateFlowRequest())->setFlow($flow); + $response = $gapicClient->updateFlow($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -790,19 +843,23 @@ public function updateFlowExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $flow = new Flow(); $flowDisplayName = 'flowDisplayName-554265505'; $flow->setDisplayName($flowDisplayName); + $request = (new UpdateFlowRequest())->setFlow($flow); try { - $gapicClient->updateFlow($flow); + $gapicClient->updateFlow($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -829,7 +886,8 @@ public function validateFlowTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - $response = $gapicClient->validateFlow($formattedName); + $request = (new ValidateFlowRequest())->setName($formattedName); + $response = $gapicClient->validateFlow($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -852,17 +910,21 @@ public function validateFlowExceptionTest() $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); + $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->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); + $request = (new ValidateFlowRequest())->setName($formattedName); try { - $gapicClient->validateFlow($formattedName); + $gapicClient->validateFlow($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -891,7 +953,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -912,15 +975,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -943,14 +1010,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -974,15 +1040,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -993,4 +1063,41 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function createFlowAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $description = 'description-1724546052'; + $expectedResponse = new Flow(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDescription($description); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $flow = new Flow(); + $flowDisplayName = 'flowDisplayName-554265505'; + $flow->setDisplayName($flowDisplayName); + $request = (new CreateFlowRequest())->setParent($formattedParent)->setFlow($flow); + $response = $gapicClient->createFlowAsync($request)->wait(); + $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.Flows/CreateFlow', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getFlow(); + $this->assertProtobufEquals($flow, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/GeneratorsClientTest.php b/DialogflowCx/tests/Unit/V3/Client/GeneratorsClientTest.php similarity index 75% rename from DialogflowCx/tests/Unit/V3/GeneratorsClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/GeneratorsClientTest.php index f1b422a65d87..9fc2dd030356 100644 --- a/DialogflowCx/tests/Unit/V3/GeneratorsClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/GeneratorsClientTest.php @@ -20,16 +20,23 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\Client\GeneratorsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateGeneratorRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeleteGeneratorRequest; use Google\Cloud\Dialogflow\Cx\V3\Generator; -use Google\Cloud\Dialogflow\Cx\V3\GeneratorsClient; +use Google\Cloud\Dialogflow\Cx\V3\GetGeneratorRequest; +use Google\Cloud\Dialogflow\Cx\V3\ListGeneratorsRequest; use Google\Cloud\Dialogflow\Cx\V3\ListGeneratorsResponse; use Google\Cloud\Dialogflow\Cx\V3\Phrase; +use Google\Cloud\Dialogflow\Cx\V3\UpdateGeneratorRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\Protobuf\GPBEmpty; @@ -52,7 +59,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return GeneratorsClient */ @@ -88,7 +97,8 @@ public function createGeneratorTest() $promptTextText = 'promptTextText-1712080514'; $generatorPromptText->setText($promptTextText); $generator->setPromptText($generatorPromptText); - $response = $gapicClient->createGenerator($formattedParent, $generator); + $request = (new CreateGeneratorRequest())->setParent($formattedParent)->setGenerator($generator); + $response = $gapicClient->createGenerator($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -113,12 +123,15 @@ public function createGeneratorExceptionTest() $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); + $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]'); @@ -129,8 +142,9 @@ public function createGeneratorExceptionTest() $promptTextText = 'promptTextText-1712080514'; $generatorPromptText->setText($promptTextText); $generator->setPromptText($generatorPromptText); + $request = (new CreateGeneratorRequest())->setParent($formattedParent)->setGenerator($generator); try { - $gapicClient->createGenerator($formattedParent, $generator); + $gapicClient->createGenerator($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -155,7 +169,8 @@ public function deleteGeneratorTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->generatorName('[PROJECT]', '[LOCATION]', '[AGENT]', '[GENERATOR]'); - $gapicClient->deleteGenerator($formattedName); + $request = (new DeleteGeneratorRequest())->setName($formattedName); + $gapicClient->deleteGenerator($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); @@ -177,17 +192,21 @@ public function deleteGeneratorExceptionTest() $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); + $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]'); + $request = (new DeleteGeneratorRequest())->setName($formattedName); try { - $gapicClient->deleteGenerator($formattedName); + $gapicClient->deleteGenerator($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -216,7 +235,8 @@ public function getGeneratorTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->generatorName('[PROJECT]', '[LOCATION]', '[AGENT]', '[GENERATOR]'); - $response = $gapicClient->getGenerator($formattedName); + $request = (new GetGeneratorRequest())->setName($formattedName); + $response = $gapicClient->getGenerator($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -239,17 +259,21 @@ public function getGeneratorExceptionTest() $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); + $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]'); + $request = (new GetGeneratorRequest())->setName($formattedName); try { - $gapicClient->getGenerator($formattedName); + $gapicClient->getGenerator($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -272,16 +296,15 @@ public function listGeneratorsTest() // Mock response $nextPageToken = ''; $generatorsElement = new Generator(); - $generators = [ - $generatorsElement, - ]; + $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); + $request = (new ListGeneratorsRequest())->setParent($formattedParent); + $response = $gapicClient->listGenerators($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -307,17 +330,21 @@ public function listGeneratorsExceptionTest() $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); + $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]'); + $request = (new ListGeneratorsRequest())->setParent($formattedParent); try { - $gapicClient->listGenerators($formattedParent); + $gapicClient->listGenerators($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -352,7 +379,8 @@ public function updateGeneratorTest() $promptTextText = 'promptTextText-1712080514'; $generatorPromptText->setText($promptTextText); $generator->setPromptText($generatorPromptText); - $response = $gapicClient->updateGenerator($generator); + $request = (new UpdateGeneratorRequest())->setGenerator($generator); + $response = $gapicClient->updateGenerator($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -375,12 +403,15 @@ public function updateGeneratorExceptionTest() $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); + $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(); @@ -390,8 +421,9 @@ public function updateGeneratorExceptionTest() $promptTextText = 'promptTextText-1712080514'; $generatorPromptText->setText($promptTextText); $generator->setPromptText($generatorPromptText); + $request = (new UpdateGeneratorRequest())->setGenerator($generator); try { - $gapicClient->updateGenerator($generator); + $gapicClient->updateGenerator($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -420,7 +452,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -441,15 +474,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -472,14 +509,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -503,15 +539,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -522,4 +562,43 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function createGeneratorAsyncTest() + { + $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); + $request = (new CreateGeneratorRequest())->setParent($formattedParent)->setGenerator($generator); + $response = $gapicClient->createGeneratorAsync($request)->wait(); + $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()); + } } diff --git a/DialogflowCx/tests/Unit/V3/IntentsClientTest.php b/DialogflowCx/tests/Unit/V3/Client/IntentsClientTest.php similarity index 80% rename from DialogflowCx/tests/Unit/V3/IntentsClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/IntentsClientTest.php index 5391774852c2..2b55dc9486ea 100644 --- a/DialogflowCx/tests/Unit/V3/IntentsClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/IntentsClientTest.php @@ -20,18 +20,27 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\Client\IntentsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateIntentRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeleteIntentRequest; +use Google\Cloud\Dialogflow\Cx\V3\ExportIntentsRequest; use Google\Cloud\Dialogflow\Cx\V3\ExportIntentsResponse; +use Google\Cloud\Dialogflow\Cx\V3\GetIntentRequest; +use Google\Cloud\Dialogflow\Cx\V3\ImportIntentsRequest; use Google\Cloud\Dialogflow\Cx\V3\ImportIntentsResponse; use Google\Cloud\Dialogflow\Cx\V3\Intent; -use Google\Cloud\Dialogflow\Cx\V3\IntentsClient; +use Google\Cloud\Dialogflow\Cx\V3\ListIntentsRequest; use Google\Cloud\Dialogflow\Cx\V3\ListIntentsResponse; +use Google\Cloud\Dialogflow\Cx\V3\UpdateIntentRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\LongRunning\GetOperationRequest; @@ -57,7 +66,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return IntentsClient */ @@ -95,7 +106,8 @@ public function createIntentTest() $intent = new Intent(); $intentDisplayName = 'intentDisplayName-1733865935'; $intent->setDisplayName($intentDisplayName); - $response = $gapicClient->createIntent($formattedParent, $intent); + $request = (new CreateIntentRequest())->setParent($formattedParent)->setIntent($intent); + $response = $gapicClient->createIntent($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -120,20 +132,24 @@ public function createIntentExceptionTest() $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); + $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]'); $intent = new Intent(); $intentDisplayName = 'intentDisplayName-1733865935'; $intent->setDisplayName($intentDisplayName); + $request = (new CreateIntentRequest())->setParent($formattedParent)->setIntent($intent); try { - $gapicClient->createIntent($formattedParent, $intent); + $gapicClient->createIntent($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -158,7 +174,8 @@ public function deleteIntentTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->intentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[INTENT]'); - $gapicClient->deleteIntent($formattedName); + $request = (new DeleteIntentRequest())->setName($formattedName); + $gapicClient->deleteIntent($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); @@ -180,17 +197,21 @@ public function deleteIntentExceptionTest() $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); + $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->intentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[INTENT]'); + $request = (new DeleteIntentRequest())->setName($formattedName); try { - $gapicClient->deleteIntent($formattedName); + $gapicClient->deleteIntent($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -236,7 +257,8 @@ public function exportIntentsTest() // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); $intents = []; - $response = $gapicClient->exportIntents($formattedParent, $intents); + $request = (new ExportIntentsRequest())->setParent($formattedParent)->setIntents($intents); + $response = $gapicClient->exportIntents($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -293,17 +315,21 @@ public function exportIntentsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); $intents = []; - $response = $gapicClient->exportIntents($formattedParent, $intents); + $request = (new ExportIntentsRequest())->setParent($formattedParent)->setIntents($intents); + $response = $gapicClient->exportIntents($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -348,7 +374,8 @@ public function getIntentTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->intentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[INTENT]'); - $response = $gapicClient->getIntent($formattedName); + $request = (new GetIntentRequest())->setName($formattedName); + $response = $gapicClient->getIntent($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -371,17 +398,21 @@ public function getIntentExceptionTest() $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); + $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->intentName('[PROJECT]', '[LOCATION]', '[AGENT]', '[INTENT]'); + $request = (new GetIntentRequest())->setName($formattedName); try { - $gapicClient->getIntent($formattedName); + $gapicClient->getIntent($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -424,7 +455,8 @@ public function importIntentsTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->importIntents($formattedParent); + $request = (new ImportIntentsRequest())->setParent($formattedParent); + $response = $gapicClient->importIntents($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -479,16 +511,20 @@ public function importIntentsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->importIntents($formattedParent); + $request = (new ImportIntentsRequest())->setParent($formattedParent); + $response = $gapicClient->importIntents($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -521,16 +557,15 @@ public function listIntentsTest() // Mock response $nextPageToken = ''; $intentsElement = new Intent(); - $intents = [ - $intentsElement, - ]; + $intents = [$intentsElement]; $expectedResponse = new ListIntentsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setIntents($intents); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->listIntents($formattedParent); + $request = (new ListIntentsRequest())->setParent($formattedParent); + $response = $gapicClient->listIntents($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -556,17 +591,21 @@ public function listIntentsExceptionTest() $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); + $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]'); + $request = (new ListIntentsRequest())->setParent($formattedParent); try { - $gapicClient->listIntents($formattedParent); + $gapicClient->listIntents($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -603,7 +642,8 @@ public function updateIntentTest() $intent = new Intent(); $intentDisplayName = 'intentDisplayName-1733865935'; $intent->setDisplayName($intentDisplayName); - $response = $gapicClient->updateIntent($intent); + $request = (new UpdateIntentRequest())->setIntent($intent); + $response = $gapicClient->updateIntent($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -626,19 +666,23 @@ public function updateIntentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $intent = new Intent(); $intentDisplayName = 'intentDisplayName-1733865935'; $intent->setDisplayName($intentDisplayName); + $request = (new UpdateIntentRequest())->setIntent($intent); try { - $gapicClient->updateIntent($intent); + $gapicClient->updateIntent($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -667,7 +711,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -688,15 +733,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -719,14 +768,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -750,15 +798,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -769,4 +821,45 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function createIntentAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $priority = 1165461084; + $isFallback = false; + $description = 'description-1724546052'; + $expectedResponse = new Intent(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setPriority($priority); + $expectedResponse->setIsFallback($isFallback); + $expectedResponse->setDescription($description); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $intent = new Intent(); + $intentDisplayName = 'intentDisplayName-1733865935'; + $intent->setDisplayName($intentDisplayName); + $request = (new CreateIntentRequest())->setParent($formattedParent)->setIntent($intent); + $response = $gapicClient->createIntentAsync($request)->wait(); + $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.Intents/CreateIntent', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getIntent(); + $this->assertProtobufEquals($intent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/PagesClientTest.php b/DialogflowCx/tests/Unit/V3/Client/PagesClientTest.php similarity index 75% rename from DialogflowCx/tests/Unit/V3/PagesClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/PagesClientTest.php index f1448e3b08df..7983382c7038 100644 --- a/DialogflowCx/tests/Unit/V3/PagesClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/PagesClientTest.php @@ -20,15 +20,22 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\Client\PagesClient; +use Google\Cloud\Dialogflow\Cx\V3\CreatePageRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeletePageRequest; +use Google\Cloud\Dialogflow\Cx\V3\GetPageRequest; +use Google\Cloud\Dialogflow\Cx\V3\ListPagesRequest; use Google\Cloud\Dialogflow\Cx\V3\ListPagesResponse; use Google\Cloud\Dialogflow\Cx\V3\Page; -use Google\Cloud\Dialogflow\Cx\V3\PagesClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdatePageRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\Protobuf\GPBEmpty; @@ -51,7 +58,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return PagesClient */ @@ -83,7 +92,8 @@ public function createPageTest() $page = new Page(); $pageDisplayName = 'pageDisplayName-1368703906'; $page->setDisplayName($pageDisplayName); - $response = $gapicClient->createPage($formattedParent, $page); + $request = (new CreatePageRequest())->setParent($formattedParent)->setPage($page); + $response = $gapicClient->createPage($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -108,20 +118,24 @@ public function createPageExceptionTest() $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); + $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->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); $page = new Page(); $pageDisplayName = 'pageDisplayName-1368703906'; $page->setDisplayName($pageDisplayName); + $request = (new CreatePageRequest())->setParent($formattedParent)->setPage($page); try { - $gapicClient->createPage($formattedParent, $page); + $gapicClient->createPage($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -146,7 +160,8 @@ public function deletePageTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->pageName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[PAGE]'); - $gapicClient->deletePage($formattedName); + $request = (new DeletePageRequest())->setName($formattedName); + $gapicClient->deletePage($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); @@ -168,17 +183,21 @@ public function deletePageExceptionTest() $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); + $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->pageName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[PAGE]'); + $request = (new DeletePageRequest())->setName($formattedName); try { - $gapicClient->deletePage($formattedName); + $gapicClient->deletePage($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -207,7 +226,8 @@ public function getPageTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->pageName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[PAGE]'); - $response = $gapicClient->getPage($formattedName); + $request = (new GetPageRequest())->setName($formattedName); + $response = $gapicClient->getPage($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -230,17 +250,21 @@ public function getPageExceptionTest() $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); + $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->pageName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[PAGE]'); + $request = (new GetPageRequest())->setName($formattedName); try { - $gapicClient->getPage($formattedName); + $gapicClient->getPage($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -263,16 +287,15 @@ public function listPagesTest() // Mock response $nextPageToken = ''; $pagesElement = new Page(); - $pages = [ - $pagesElement, - ]; + $pages = [$pagesElement]; $expectedResponse = new ListPagesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setPages($pages); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - $response = $gapicClient->listPages($formattedParent); + $request = (new ListPagesRequest())->setParent($formattedParent); + $response = $gapicClient->listPages($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -298,17 +321,21 @@ public function listPagesExceptionTest() $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); + $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->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); + $request = (new ListPagesRequest())->setParent($formattedParent); try { - $gapicClient->listPages($formattedParent); + $gapicClient->listPages($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -339,7 +366,8 @@ public function updatePageTest() $page = new Page(); $pageDisplayName = 'pageDisplayName-1368703906'; $page->setDisplayName($pageDisplayName); - $response = $gapicClient->updatePage($page); + $request = (new UpdatePageRequest())->setPage($page); + $response = $gapicClient->updatePage($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -362,19 +390,23 @@ public function updatePageExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $page = new Page(); $pageDisplayName = 'pageDisplayName-1368703906'; $page->setDisplayName($pageDisplayName); + $request = (new UpdatePageRequest())->setPage($page); try { - $gapicClient->updatePage($page); + $gapicClient->updatePage($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -403,7 +435,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -424,15 +457,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -455,14 +492,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -486,15 +522,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -505,4 +545,39 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function createPageAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $expectedResponse = new Page(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); + $page = new Page(); + $pageDisplayName = 'pageDisplayName-1368703906'; + $page->setDisplayName($pageDisplayName); + $request = (new CreatePageRequest())->setParent($formattedParent)->setPage($page); + $response = $gapicClient->createPageAsync($request)->wait(); + $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.Pages/CreatePage', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getPage(); + $this->assertProtobufEquals($page, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/SecuritySettingsServiceClientTest.php b/DialogflowCx/tests/Unit/V3/Client/SecuritySettingsServiceClientTest.php similarity index 71% rename from DialogflowCx/tests/Unit/V3/SecuritySettingsServiceClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/SecuritySettingsServiceClientTest.php index 16347d3d1071..65feddca6d1b 100644 --- a/DialogflowCx/tests/Unit/V3/SecuritySettingsServiceClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/SecuritySettingsServiceClientTest.php @@ -20,15 +20,22 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\Client\SecuritySettingsServiceClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateSecuritySettingsRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeleteSecuritySettingsRequest; +use Google\Cloud\Dialogflow\Cx\V3\GetSecuritySettingsRequest; +use Google\Cloud\Dialogflow\Cx\V3\ListSecuritySettingsRequest; use Google\Cloud\Dialogflow\Cx\V3\ListSecuritySettingsResponse; use Google\Cloud\Dialogflow\Cx\V3\SecuritySettings; -use Google\Cloud\Dialogflow\Cx\V3\SecuritySettingsServiceClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateSecuritySettingsRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\Protobuf\FieldMask; @@ -52,7 +59,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return SecuritySettingsServiceClient */ @@ -90,13 +99,19 @@ public function createSecuritySettingsTest() $securitySettings = new SecuritySettings(); $securitySettingsDisplayName = 'securitySettingsDisplayName1233938154'; $securitySettings->setDisplayName($securitySettingsDisplayName); - $response = $gapicClient->createSecuritySettings($formattedParent, $securitySettings); + $request = (new CreateSecuritySettingsRequest()) + ->setParent($formattedParent) + ->setSecuritySettings($securitySettings); + $response = $gapicClient->createSecuritySettings($request); $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.SecuritySettingsService/CreateSecuritySettings', $actualFuncCall); + $this->assertSame( + '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/CreateSecuritySettings', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getSecuritySettings(); @@ -115,20 +130,26 @@ public function createSecuritySettingsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); $securitySettings = new SecuritySettings(); $securitySettingsDisplayName = 'securitySettingsDisplayName1233938154'; $securitySettings->setDisplayName($securitySettingsDisplayName); + $request = (new CreateSecuritySettingsRequest()) + ->setParent($formattedParent) + ->setSecuritySettings($securitySettings); try { - $gapicClient->createSecuritySettings($formattedParent, $securitySettings); + $gapicClient->createSecuritySettings($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -153,12 +174,16 @@ public function deleteSecuritySettingsTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->securitySettingsName('[PROJECT]', '[LOCATION]', '[SECURITY_SETTINGS]'); - $gapicClient->deleteSecuritySettings($formattedName); + $request = (new DeleteSecuritySettingsRequest())->setName($formattedName); + $gapicClient->deleteSecuritySettings($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.dialogflow.cx.v3.SecuritySettingsService/DeleteSecuritySettings', $actualFuncCall); + $this->assertSame( + '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/DeleteSecuritySettings', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -175,17 +200,21 @@ public function deleteSecuritySettingsExceptionTest() $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); + $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->securitySettingsName('[PROJECT]', '[LOCATION]', '[SECURITY_SETTINGS]'); + $request = (new DeleteSecuritySettingsRequest())->setName($formattedName); try { - $gapicClient->deleteSecuritySettings($formattedName); + $gapicClient->deleteSecuritySettings($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -220,13 +249,17 @@ public function getSecuritySettingsTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->securitySettingsName('[PROJECT]', '[LOCATION]', '[SECURITY_SETTINGS]'); - $response = $gapicClient->getSecuritySettings($formattedName); + $request = (new GetSecuritySettingsRequest())->setName($formattedName); + $response = $gapicClient->getSecuritySettings($request); $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.SecuritySettingsService/GetSecuritySettings', $actualFuncCall); + $this->assertSame( + '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/GetSecuritySettings', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -243,17 +276,21 @@ public function getSecuritySettingsExceptionTest() $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); + $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->securitySettingsName('[PROJECT]', '[LOCATION]', '[SECURITY_SETTINGS]'); + $request = (new GetSecuritySettingsRequest())->setName($formattedName); try { - $gapicClient->getSecuritySettings($formattedName); + $gapicClient->getSecuritySettings($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -276,16 +313,15 @@ public function listSecuritySettingsTest() // Mock response $nextPageToken = ''; $securitySettingsElement = new SecuritySettings(); - $securitySettings = [ - $securitySettingsElement, - ]; + $securitySettings = [$securitySettingsElement]; $expectedResponse = new ListSecuritySettingsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setSecuritySettings($securitySettings); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $response = $gapicClient->listSecuritySettings($formattedParent); + $request = (new ListSecuritySettingsRequest())->setParent($formattedParent); + $response = $gapicClient->listSecuritySettings($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -294,7 +330,10 @@ public function listSecuritySettingsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.dialogflow.cx.v3.SecuritySettingsService/ListSecuritySettings', $actualFuncCall); + $this->assertSame( + '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/ListSecuritySettings', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -311,17 +350,21 @@ public function listSecuritySettingsExceptionTest() $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); + $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->locationName('[PROJECT]', '[LOCATION]'); + $request = (new ListSecuritySettingsRequest())->setParent($formattedParent); try { - $gapicClient->listSecuritySettings($formattedParent); + $gapicClient->listSecuritySettings($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -359,13 +402,19 @@ public function updateSecuritySettingsTest() $securitySettingsDisplayName = 'securitySettingsDisplayName1233938154'; $securitySettings->setDisplayName($securitySettingsDisplayName); $updateMask = new FieldMask(); - $response = $gapicClient->updateSecuritySettings($securitySettings, $updateMask); + $request = (new UpdateSecuritySettingsRequest()) + ->setSecuritySettings($securitySettings) + ->setUpdateMask($updateMask); + $response = $gapicClient->updateSecuritySettings($request); $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.SecuritySettingsService/UpdateSecuritySettings', $actualFuncCall); + $this->assertSame( + '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/UpdateSecuritySettings', + $actualFuncCall + ); $actualValue = $actualRequestObject->getSecuritySettings(); $this->assertProtobufEquals($securitySettings, $actualValue); $actualValue = $actualRequestObject->getUpdateMask(); @@ -384,20 +433,26 @@ public function updateSecuritySettingsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $securitySettings = new SecuritySettings(); $securitySettingsDisplayName = 'securitySettingsDisplayName1233938154'; $securitySettings->setDisplayName($securitySettingsDisplayName); $updateMask = new FieldMask(); + $request = (new UpdateSecuritySettingsRequest()) + ->setSecuritySettings($securitySettings) + ->setUpdateMask($updateMask); try { - $gapicClient->updateSecuritySettings($securitySettings, $updateMask); + $gapicClient->updateSecuritySettings($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -426,7 +481,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -447,15 +503,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -478,14 +538,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -509,15 +568,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -528,4 +591,50 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function createSecuritySettingsAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $inspectTemplate = 'inspectTemplate-159468987'; + $deidentifyTemplate = 'deidentifyTemplate1397891564'; + $retentionWindowDays = 810238885; + $expectedResponse = new SecuritySettings(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setInspectTemplate($inspectTemplate); + $expectedResponse->setDeidentifyTemplate($deidentifyTemplate); + $expectedResponse->setRetentionWindowDays($retentionWindowDays); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $securitySettings = new SecuritySettings(); + $securitySettingsDisplayName = 'securitySettingsDisplayName1233938154'; + $securitySettings->setDisplayName($securitySettingsDisplayName); + $request = (new CreateSecuritySettingsRequest()) + ->setParent($formattedParent) + ->setSecuritySettings($securitySettings); + $response = $gapicClient->createSecuritySettingsAsync($request)->wait(); + $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.SecuritySettingsService/CreateSecuritySettings', + $actualFuncCall + ); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getSecuritySettings(); + $this->assertProtobufEquals($securitySettings, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/SessionEntityTypesClientTest.php b/DialogflowCx/tests/Unit/V3/Client/SessionEntityTypesClientTest.php similarity index 71% rename from DialogflowCx/tests/Unit/V3/SessionEntityTypesClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/SessionEntityTypesClientTest.php index f22ed62e8c95..8761cfc1f4a7 100644 --- a/DialogflowCx/tests/Unit/V3/SessionEntityTypesClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/SessionEntityTypesClientTest.php @@ -20,16 +20,23 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionEntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateSessionEntityTypeRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeleteSessionEntityTypeRequest; +use Google\Cloud\Dialogflow\Cx\V3\GetSessionEntityTypeRequest; +use Google\Cloud\Dialogflow\Cx\V3\ListSessionEntityTypesRequest; use Google\Cloud\Dialogflow\Cx\V3\ListSessionEntityTypesResponse; use Google\Cloud\Dialogflow\Cx\V3\SessionEntityType; use Google\Cloud\Dialogflow\Cx\V3\SessionEntityType\EntityOverrideMode; -use Google\Cloud\Dialogflow\Cx\V3\SessionEntityTypesClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateSessionEntityTypeRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\Protobuf\GPBEmpty; @@ -52,7 +59,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return SessionEntityTypesClient */ @@ -86,7 +95,10 @@ public function createSessionEntityTypeTest() $sessionEntityType->setEntityOverrideMode($sessionEntityTypeEntityOverrideMode); $sessionEntityTypeEntities = []; $sessionEntityType->setEntities($sessionEntityTypeEntities); - $response = $gapicClient->createSessionEntityType($formattedParent, $sessionEntityType); + $request = (new CreateSessionEntityTypeRequest()) + ->setParent($formattedParent) + ->setSessionEntityType($sessionEntityType); + $response = $gapicClient->createSessionEntityType($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -111,12 +123,15 @@ public function createSessionEntityTypeExceptionTest() $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); + $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->sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); @@ -127,8 +142,11 @@ public function createSessionEntityTypeExceptionTest() $sessionEntityType->setEntityOverrideMode($sessionEntityTypeEntityOverrideMode); $sessionEntityTypeEntities = []; $sessionEntityType->setEntities($sessionEntityTypeEntities); + $request = (new CreateSessionEntityTypeRequest()) + ->setParent($formattedParent) + ->setSessionEntityType($sessionEntityType); try { - $gapicClient->createSessionEntityType($formattedParent, $sessionEntityType); + $gapicClient->createSessionEntityType($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -152,8 +170,15 @@ public function deleteSessionEntityTypeTest() $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->sessionEntityTypeName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]', '[ENTITY_TYPE]'); - $gapicClient->deleteSessionEntityType($formattedName); + $formattedName = $gapicClient->sessionEntityTypeName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[SESSION]', + '[ENTITY_TYPE]' + ); + $request = (new DeleteSessionEntityTypeRequest())->setName($formattedName); + $gapicClient->deleteSessionEntityType($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); @@ -175,17 +200,27 @@ public function deleteSessionEntityTypeExceptionTest() $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); + $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->sessionEntityTypeName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]', '[ENTITY_TYPE]'); + $formattedName = $gapicClient->sessionEntityTypeName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[SESSION]', + '[ENTITY_TYPE]' + ); + $request = (new DeleteSessionEntityTypeRequest())->setName($formattedName); try { - $gapicClient->deleteSessionEntityType($formattedName); + $gapicClient->deleteSessionEntityType($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -211,8 +246,15 @@ public function getSessionEntityTypeTest() $expectedResponse->setName($name2); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->sessionEntityTypeName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]', '[ENTITY_TYPE]'); - $response = $gapicClient->getSessionEntityType($formattedName); + $formattedName = $gapicClient->sessionEntityTypeName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[SESSION]', + '[ENTITY_TYPE]' + ); + $request = (new GetSessionEntityTypeRequest())->setName($formattedName); + $response = $gapicClient->getSessionEntityType($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -235,17 +277,27 @@ public function getSessionEntityTypeExceptionTest() $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); + $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->sessionEntityTypeName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]', '[ENTITY_TYPE]'); + $formattedName = $gapicClient->sessionEntityTypeName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[SESSION]', + '[ENTITY_TYPE]' + ); + $request = (new GetSessionEntityTypeRequest())->setName($formattedName); try { - $gapicClient->getSessionEntityType($formattedName); + $gapicClient->getSessionEntityType($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -268,16 +320,15 @@ public function listSessionEntityTypesTest() // Mock response $nextPageToken = ''; $sessionEntityTypesElement = new SessionEntityType(); - $sessionEntityTypes = [ - $sessionEntityTypesElement, - ]; + $sessionEntityTypes = [$sessionEntityTypesElement]; $expectedResponse = new ListSessionEntityTypesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setSessionEntityTypes($sessionEntityTypes); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); - $response = $gapicClient->listSessionEntityTypes($formattedParent); + $request = (new ListSessionEntityTypesRequest())->setParent($formattedParent); + $response = $gapicClient->listSessionEntityTypes($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -303,17 +354,21 @@ public function listSessionEntityTypesExceptionTest() $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); + $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->sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); + $request = (new ListSessionEntityTypesRequest())->setParent($formattedParent); try { - $gapicClient->listSessionEntityTypes($formattedParent); + $gapicClient->listSessionEntityTypes($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -346,7 +401,8 @@ public function updateSessionEntityTypeTest() $sessionEntityType->setEntityOverrideMode($sessionEntityTypeEntityOverrideMode); $sessionEntityTypeEntities = []; $sessionEntityType->setEntities($sessionEntityTypeEntities); - $response = $gapicClient->updateSessionEntityType($sessionEntityType); + $request = (new UpdateSessionEntityTypeRequest())->setSessionEntityType($sessionEntityType); + $response = $gapicClient->updateSessionEntityType($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -369,12 +425,15 @@ public function updateSessionEntityTypeExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $sessionEntityType = new SessionEntityType(); @@ -384,8 +443,9 @@ public function updateSessionEntityTypeExceptionTest() $sessionEntityType->setEntityOverrideMode($sessionEntityTypeEntityOverrideMode); $sessionEntityTypeEntities = []; $sessionEntityType->setEntities($sessionEntityTypeEntities); + $request = (new UpdateSessionEntityTypeRequest())->setSessionEntityType($sessionEntityType); try { - $gapicClient->updateSessionEntityType($sessionEntityType); + $gapicClient->updateSessionEntityType($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -414,7 +474,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -435,15 +496,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -466,14 +531,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -497,15 +561,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -516,4 +584,43 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function createSessionEntityTypeAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $expectedResponse = new SessionEntityType(); + $expectedResponse->setName($name); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); + $sessionEntityType = new SessionEntityType(); + $sessionEntityTypeName = 'sessionEntityTypeName-916646370'; + $sessionEntityType->setName($sessionEntityTypeName); + $sessionEntityTypeEntityOverrideMode = EntityOverrideMode::ENTITY_OVERRIDE_MODE_UNSPECIFIED; + $sessionEntityType->setEntityOverrideMode($sessionEntityTypeEntityOverrideMode); + $sessionEntityTypeEntities = []; + $sessionEntityType->setEntities($sessionEntityTypeEntities); + $request = (new CreateSessionEntityTypeRequest()) + ->setParent($formattedParent) + ->setSessionEntityType($sessionEntityType); + $response = $gapicClient->createSessionEntityTypeAsync($request)->wait(); + $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.SessionEntityTypes/CreateSessionEntityType', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getSessionEntityType(); + $this->assertProtobufEquals($sessionEntityType, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/SessionsClientTest.php b/DialogflowCx/tests/Unit/V3/Client/SessionsClientTest.php similarity index 76% rename from DialogflowCx/tests/Unit/V3/SessionsClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/SessionsClientTest.php index bfd1f68f9b74..a553dbce1965 100644 --- a/DialogflowCx/tests/Unit/V3/SessionsClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/SessionsClientTest.php @@ -20,7 +20,7 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\BidiStream; @@ -28,13 +28,19 @@ use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; use Google\Cloud\Dialogflow\Cx\V3\AnswerFeedback; +use Google\Cloud\Dialogflow\Cx\V3\Client\SessionsClient; +use Google\Cloud\Dialogflow\Cx\V3\DetectIntentRequest; use Google\Cloud\Dialogflow\Cx\V3\DetectIntentResponse; +use Google\Cloud\Dialogflow\Cx\V3\FulfillIntentRequest; use Google\Cloud\Dialogflow\Cx\V3\FulfillIntentResponse; +use Google\Cloud\Dialogflow\Cx\V3\MatchIntentRequest; use Google\Cloud\Dialogflow\Cx\V3\MatchIntentResponse; use Google\Cloud\Dialogflow\Cx\V3\QueryInput; -use Google\Cloud\Dialogflow\Cx\V3\SessionsClient; 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\Rpc\Code; @@ -56,7 +62,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return SessionsClient */ @@ -90,7 +98,8 @@ public function detectIntentTest() $queryInput = new QueryInput(); $queryInputLanguageCode = 'queryInputLanguageCode478766695'; $queryInput->setLanguageCode($queryInputLanguageCode); - $response = $gapicClient->detectIntent($formattedSession, $queryInput); + $request = (new DetectIntentRequest())->setSession($formattedSession)->setQueryInput($queryInput); + $response = $gapicClient->detectIntent($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -115,20 +124,24 @@ public function detectIntentExceptionTest() $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); + $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]'); $queryInput = new QueryInput(); $queryInputLanguageCode = 'queryInputLanguageCode478766695'; $queryInput->setLanguageCode($queryInputLanguageCode); + $request = (new DetectIntentRequest())->setSession($formattedSession)->setQueryInput($queryInput); try { - $gapicClient->detectIntent($formattedSession, $queryInput); + $gapicClient->detectIntent($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -155,7 +168,8 @@ public function fulfillIntentTest() $expectedResponse->setResponseId($responseId); $expectedResponse->setOutputAudio($outputAudio); $transport->addResponse($expectedResponse); - $response = $gapicClient->fulfillIntent(); + $request = new FulfillIntentRequest(); + $response = $gapicClient->fulfillIntent($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -176,15 +190,19 @@ public function fulfillIntentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new FulfillIntentRequest(); try { - $gapicClient->fulfillIntent(); + $gapicClient->fulfillIntent($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -214,7 +232,8 @@ public function matchIntentTest() $queryInput = new QueryInput(); $queryInputLanguageCode = 'queryInputLanguageCode478766695'; $queryInput->setLanguageCode($queryInputLanguageCode); - $response = $gapicClient->matchIntent($formattedSession, $queryInput); + $request = (new MatchIntentRequest())->setSession($formattedSession)->setQueryInput($queryInput); + $response = $gapicClient->matchIntent($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -239,20 +258,24 @@ public function matchIntentExceptionTest() $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); + $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]'); $queryInput = new QueryInput(); $queryInputLanguageCode = 'queryInputLanguageCode478766695'; $queryInput->setLanguageCode($queryInputLanguageCode); + $request = (new MatchIntentRequest())->setSession($formattedSession)->setQueryInput($queryInput); try { - $gapicClient->matchIntent($formattedSession, $queryInput); + $gapicClient->matchIntent($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -300,10 +323,7 @@ public function streamingDetectIntentTest() $bidi->write($request); $responses = []; $responses[] = $bidi->read(); - $bidi->writeAll([ - $request2, - $request3, - ]); + $bidi->writeAll([$request2, $request3]); foreach ($bidi->closeWriteAndReadAll() as $response) { $responses[] = $response; } @@ -341,12 +361,15 @@ public function streamingDetectIntentExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->setStreamingStatus($status); $this->assertTrue($transport->isExhausted()); $bidi = $gapicClient->streamingDetectIntent(); @@ -381,7 +404,11 @@ public function submitAnswerFeedbackTest() $formattedSession = $gapicClient->sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); $responseId = 'responseId1847552473'; $answerFeedback = new AnswerFeedback(); - $response = $gapicClient->submitAnswerFeedback($formattedSession, $responseId, $answerFeedback); + $request = (new SubmitAnswerFeedbackRequest()) + ->setSession($formattedSession) + ->setResponseId($responseId) + ->setAnswerFeedback($answerFeedback); + $response = $gapicClient->submitAnswerFeedback($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -408,19 +435,26 @@ public function submitAnswerFeedbackExceptionTest() $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); + $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(); + $request = (new SubmitAnswerFeedbackRequest()) + ->setSession($formattedSession) + ->setResponseId($responseId) + ->setAnswerFeedback($answerFeedback); try { - $gapicClient->submitAnswerFeedback($formattedSession, $responseId, $answerFeedback); + $gapicClient->submitAnswerFeedback($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -449,7 +483,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -470,15 +505,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -501,14 +540,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -532,15 +570,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -551,4 +593,41 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function detectIntentAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $responseId = 'responseId1847552473'; + $outputAudio = '24'; + $allowCancellation = false; + $expectedResponse = new DetectIntentResponse(); + $expectedResponse->setResponseId($responseId); + $expectedResponse->setOutputAudio($outputAudio); + $expectedResponse->setAllowCancellation($allowCancellation); + $transport->addResponse($expectedResponse); + // Mock request + $formattedSession = $gapicClient->sessionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[SESSION]'); + $queryInput = new QueryInput(); + $queryInputLanguageCode = 'queryInputLanguageCode478766695'; + $queryInput->setLanguageCode($queryInputLanguageCode); + $request = (new DetectIntentRequest())->setSession($formattedSession)->setQueryInput($queryInput); + $response = $gapicClient->detectIntentAsync($request)->wait(); + $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/DetectIntent', $actualFuncCall); + $actualValue = $actualRequestObject->getSession(); + $this->assertProtobufEquals($formattedSession, $actualValue); + $actualValue = $actualRequestObject->getQueryInput(); + $this->assertProtobufEquals($queryInput, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/TestCasesClientTest.php b/DialogflowCx/tests/Unit/V3/Client/TestCasesClientTest.php similarity index 81% rename from DialogflowCx/tests/Unit/V3/TestCasesClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/TestCasesClientTest.php index d73d4aebcfb7..dafed7bde7e6 100644 --- a/DialogflowCx/tests/Unit/V3/TestCasesClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/TestCasesClientTest.php @@ -20,23 +20,37 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\BatchDeleteTestCasesRequest; +use Google\Cloud\Dialogflow\Cx\V3\BatchRunTestCasesRequest; use Google\Cloud\Dialogflow\Cx\V3\BatchRunTestCasesResponse; +use Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageRequest; use Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageRequest\CoverageType; use Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageResponse; +use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateTestCaseRequest; +use Google\Cloud\Dialogflow\Cx\V3\ExportTestCasesRequest; use Google\Cloud\Dialogflow\Cx\V3\ExportTestCasesResponse; +use Google\Cloud\Dialogflow\Cx\V3\GetTestCaseRequest; +use Google\Cloud\Dialogflow\Cx\V3\GetTestCaseResultRequest; +use Google\Cloud\Dialogflow\Cx\V3\ImportTestCasesRequest; use Google\Cloud\Dialogflow\Cx\V3\ImportTestCasesResponse; +use Google\Cloud\Dialogflow\Cx\V3\ListTestCaseResultsRequest; use Google\Cloud\Dialogflow\Cx\V3\ListTestCaseResultsResponse; +use Google\Cloud\Dialogflow\Cx\V3\ListTestCasesRequest; use Google\Cloud\Dialogflow\Cx\V3\ListTestCasesResponse; +use Google\Cloud\Dialogflow\Cx\V3\RunTestCaseRequest; use Google\Cloud\Dialogflow\Cx\V3\RunTestCaseResponse; use Google\Cloud\Dialogflow\Cx\V3\TestCaseResult; -use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateTestCaseRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\LongRunning\GetOperationRequest; @@ -63,7 +77,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return TestCasesClient */ @@ -88,10 +104,9 @@ public function batchDeleteTestCasesTest() $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $formattedNames = [ - $gapicClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'), - ]; - $gapicClient->batchDeleteTestCases($formattedParent, $formattedNames); + $formattedNames = [$gapicClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]')]; + $request = (new BatchDeleteTestCasesRequest())->setParent($formattedParent)->setNames($formattedNames); + $gapicClient->batchDeleteTestCases($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); @@ -115,20 +130,22 @@ public function batchDeleteTestCasesExceptionTest() $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); + $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]'); - $formattedNames = [ - $gapicClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'), - ]; + $formattedNames = [$gapicClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]')]; + $request = (new BatchDeleteTestCasesRequest())->setParent($formattedParent)->setNames($formattedNames); try { - $gapicClient->batchDeleteTestCases($formattedParent, $formattedNames); + $gapicClient->batchDeleteTestCases($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -171,10 +188,9 @@ public function batchRunTestCasesTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $formattedTestCases = [ - $gapicClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'), - ]; - $response = $gapicClient->batchRunTestCases($formattedParent, $formattedTestCases); + $formattedTestCases = [$gapicClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]')]; + $request = (new BatchRunTestCasesRequest())->setParent($formattedParent)->setTestCases($formattedTestCases); + $response = $gapicClient->batchRunTestCases($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -231,19 +247,21 @@ public function batchRunTestCasesExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $formattedTestCases = [ - $gapicClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'), - ]; - $response = $gapicClient->batchRunTestCases($formattedParent, $formattedTestCases); + $formattedTestCases = [$gapicClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]')]; + $request = (new BatchRunTestCasesRequest())->setParent($formattedParent)->setTestCases($formattedTestCases); + $response = $gapicClient->batchRunTestCases($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -281,7 +299,8 @@ public function calculateCoverageTest() // Mock request $formattedAgent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); $type = CoverageType::COVERAGE_TYPE_UNSPECIFIED; - $response = $gapicClient->calculateCoverage($formattedAgent, $type); + $request = (new CalculateCoverageRequest())->setAgent($formattedAgent)->setType($type); + $response = $gapicClient->calculateCoverage($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -306,18 +325,22 @@ public function calculateCoverageExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedAgent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); $type = CoverageType::COVERAGE_TYPE_UNSPECIFIED; + $request = (new CalculateCoverageRequest())->setAgent($formattedAgent)->setType($type); try { - $gapicClient->calculateCoverage($formattedAgent, $type); + $gapicClient->calculateCoverage($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -351,7 +374,8 @@ public function createTestCaseTest() $testCase = new \Google\Cloud\Dialogflow\Cx\V3\TestCase(); $testCaseDisplayName = 'testCaseDisplayName1109893675'; $testCase->setDisplayName($testCaseDisplayName); - $response = $gapicClient->createTestCase($formattedParent, $testCase); + $request = (new CreateTestCaseRequest())->setParent($formattedParent)->setTestCase($testCase); + $response = $gapicClient->createTestCase($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -376,20 +400,24 @@ public function createTestCaseExceptionTest() $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); + $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]'); $testCase = new \Google\Cloud\Dialogflow\Cx\V3\TestCase(); $testCaseDisplayName = 'testCaseDisplayName1109893675'; $testCase->setDisplayName($testCaseDisplayName); + $request = (new CreateTestCaseRequest())->setParent($formattedParent)->setTestCase($testCase); try { - $gapicClient->createTestCase($formattedParent, $testCase); + $gapicClient->createTestCase($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -434,7 +462,8 @@ public function exportTestCasesTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->exportTestCases($formattedParent); + $request = (new ExportTestCasesRequest())->setParent($formattedParent); + $response = $gapicClient->exportTestCases($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -489,16 +518,20 @@ public function exportTestCasesExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->exportTestCases($formattedParent); + $request = (new ExportTestCasesRequest())->setParent($formattedParent); + $response = $gapicClient->exportTestCases($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -539,7 +572,8 @@ public function getTestCaseTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'); - $response = $gapicClient->getTestCase($formattedName); + $request = (new GetTestCaseRequest())->setName($formattedName); + $response = $gapicClient->getTestCase($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -562,17 +596,21 @@ public function getTestCaseExceptionTest() $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); + $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->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'); + $request = (new GetTestCaseRequest())->setName($formattedName); try { - $gapicClient->getTestCase($formattedName); + $gapicClient->getTestCase($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -600,8 +638,15 @@ public function getTestCaseResultTest() $expectedResponse->setEnvironment($environment); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->testCaseResultName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]', '[RESULT]'); - $response = $gapicClient->getTestCaseResult($formattedName); + $formattedName = $gapicClient->testCaseResultName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[TEST_CASE]', + '[RESULT]' + ); + $request = (new GetTestCaseResultRequest())->setName($formattedName); + $response = $gapicClient->getTestCaseResult($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -624,17 +669,27 @@ public function getTestCaseResultExceptionTest() $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); + $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->testCaseResultName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]', '[RESULT]'); + $formattedName = $gapicClient->testCaseResultName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[TEST_CASE]', + '[RESULT]' + ); + $request = (new GetTestCaseResultRequest())->setName($formattedName); try { - $gapicClient->getTestCaseResult($formattedName); + $gapicClient->getTestCaseResult($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -677,7 +732,8 @@ public function importTestCasesTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->importTestCases($formattedParent); + $request = (new ImportTestCasesRequest())->setParent($formattedParent); + $response = $gapicClient->importTestCases($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -732,16 +788,20 @@ public function importTestCasesExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->importTestCases($formattedParent); + $request = (new ImportTestCasesRequest())->setParent($formattedParent); + $response = $gapicClient->importTestCases($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -774,16 +834,15 @@ public function listTestCaseResultsTest() // Mock response $nextPageToken = ''; $testCaseResultsElement = new TestCaseResult(); - $testCaseResults = [ - $testCaseResultsElement, - ]; + $testCaseResults = [$testCaseResultsElement]; $expectedResponse = new ListTestCaseResultsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setTestCaseResults($testCaseResults); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'); - $response = $gapicClient->listTestCaseResults($formattedParent); + $request = (new ListTestCaseResultsRequest())->setParent($formattedParent); + $response = $gapicClient->listTestCaseResults($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -809,17 +868,21 @@ public function listTestCaseResultsExceptionTest() $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); + $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->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'); + $request = (new ListTestCaseResultsRequest())->setParent($formattedParent); try { - $gapicClient->listTestCaseResults($formattedParent); + $gapicClient->listTestCaseResults($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -842,16 +905,15 @@ public function listTestCasesTest() // Mock response $nextPageToken = ''; $testCasesElement = new \Google\Cloud\Dialogflow\Cx\V3\TestCase(); - $testCases = [ - $testCasesElement, - ]; + $testCases = [$testCasesElement]; $expectedResponse = new ListTestCasesResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setTestCases($testCases); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->listTestCases($formattedParent); + $request = (new ListTestCasesRequest())->setParent($formattedParent); + $response = $gapicClient->listTestCases($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -877,17 +939,21 @@ public function listTestCasesExceptionTest() $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); + $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]'); + $request = (new ListTestCasesRequest())->setParent($formattedParent); try { - $gapicClient->listTestCases($formattedParent); + $gapicClient->listTestCases($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -930,7 +996,8 @@ public function runTestCaseTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'); - $response = $gapicClient->runTestCase($formattedName); + $request = (new RunTestCaseRequest())->setName($formattedName); + $response = $gapicClient->runTestCase($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -985,16 +1052,20 @@ public function runTestCaseExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedName = $gapicClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'); - $response = $gapicClient->runTestCase($formattedName); + $request = (new RunTestCaseRequest())->setName($formattedName); + $response = $gapicClient->runTestCase($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -1038,7 +1109,8 @@ public function updateTestCaseTest() $testCaseDisplayName = 'testCaseDisplayName1109893675'; $testCase->setDisplayName($testCaseDisplayName); $updateMask = new FieldMask(); - $response = $gapicClient->updateTestCase($testCase, $updateMask); + $request = (new UpdateTestCaseRequest())->setTestCase($testCase)->setUpdateMask($updateMask); + $response = $gapicClient->updateTestCase($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -1063,20 +1135,24 @@ public function updateTestCaseExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $testCase = new \Google\Cloud\Dialogflow\Cx\V3\TestCase(); $testCaseDisplayName = 'testCaseDisplayName1109893675'; $testCase->setDisplayName($testCaseDisplayName); $updateMask = new FieldMask(); + $request = (new UpdateTestCaseRequest())->setTestCase($testCase)->setUpdateMask($updateMask); try { - $gapicClient->updateTestCase($testCase, $updateMask); + $gapicClient->updateTestCase($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -1105,7 +1181,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -1126,15 +1203,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -1157,14 +1238,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -1188,15 +1268,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -1207,4 +1291,32 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function batchDeleteTestCasesAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $formattedNames = [$gapicClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]')]; + $request = (new BatchDeleteTestCasesRequest())->setParent($formattedParent)->setNames($formattedNames); + $gapicClient->batchDeleteTestCasesAsync($request)->wait(); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.dialogflow.cx.v3.TestCases/BatchDeleteTestCases', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getNames(); + $this->assertProtobufEquals($formattedNames, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/TransitionRouteGroupsClientTest.php b/DialogflowCx/tests/Unit/V3/Client/TransitionRouteGroupsClientTest.php similarity index 68% rename from DialogflowCx/tests/Unit/V3/TransitionRouteGroupsClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/TransitionRouteGroupsClientTest.php index 118b1ed3c3e1..512da1f6c646 100644 --- a/DialogflowCx/tests/Unit/V3/TransitionRouteGroupsClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/TransitionRouteGroupsClientTest.php @@ -20,15 +20,22 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\Client\TransitionRouteGroupsClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateTransitionRouteGroupRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeleteTransitionRouteGroupRequest; +use Google\Cloud\Dialogflow\Cx\V3\GetTransitionRouteGroupRequest; +use Google\Cloud\Dialogflow\Cx\V3\ListTransitionRouteGroupsRequest; use Google\Cloud\Dialogflow\Cx\V3\ListTransitionRouteGroupsResponse; use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroup; -use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroupsClient; +use Google\Cloud\Dialogflow\Cx\V3\UpdateTransitionRouteGroupRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\Protobuf\GPBEmpty; @@ -51,7 +58,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return TransitionRouteGroupsClient */ @@ -83,13 +92,19 @@ public function createTransitionRouteGroupTest() $transitionRouteGroup = new TransitionRouteGroup(); $transitionRouteGroupDisplayName = 'transitionRouteGroupDisplayName-1406267262'; $transitionRouteGroup->setDisplayName($transitionRouteGroupDisplayName); - $response = $gapicClient->createTransitionRouteGroup($formattedParent, $transitionRouteGroup); + $request = (new CreateTransitionRouteGroupRequest()) + ->setParent($formattedParent) + ->setTransitionRouteGroup($transitionRouteGroup); + $response = $gapicClient->createTransitionRouteGroup($request); $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.TransitionRouteGroups/CreateTransitionRouteGroup', $actualFuncCall); + $this->assertSame( + '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/CreateTransitionRouteGroup', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $actualValue = $actualRequestObject->getTransitionRouteGroup(); @@ -108,20 +123,26 @@ public function createTransitionRouteGroupExceptionTest() $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); + $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->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); $transitionRouteGroup = new TransitionRouteGroup(); $transitionRouteGroupDisplayName = 'transitionRouteGroupDisplayName-1406267262'; $transitionRouteGroup->setDisplayName($transitionRouteGroupDisplayName); + $request = (new CreateTransitionRouteGroupRequest()) + ->setParent($formattedParent) + ->setTransitionRouteGroup($transitionRouteGroup); try { - $gapicClient->createTransitionRouteGroup($formattedParent, $transitionRouteGroup); + $gapicClient->createTransitionRouteGroup($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -145,13 +166,23 @@ public function deleteTransitionRouteGroupTest() $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->transitionRouteGroupName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[TRANSITION_ROUTE_GROUP]'); - $gapicClient->deleteTransitionRouteGroup($formattedName); + $formattedName = $gapicClient->transitionRouteGroupName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[FLOW]', + '[TRANSITION_ROUTE_GROUP]' + ); + $request = (new DeleteTransitionRouteGroupRequest())->setName($formattedName); + $gapicClient->deleteTransitionRouteGroup($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/DeleteTransitionRouteGroup', $actualFuncCall); + $this->assertSame( + '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/DeleteTransitionRouteGroup', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -168,17 +199,27 @@ public function deleteTransitionRouteGroupExceptionTest() $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); + $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->transitionRouteGroupName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[TRANSITION_ROUTE_GROUP]'); + $formattedName = $gapicClient->transitionRouteGroupName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[FLOW]', + '[TRANSITION_ROUTE_GROUP]' + ); + $request = (new DeleteTransitionRouteGroupRequest())->setName($formattedName); try { - $gapicClient->deleteTransitionRouteGroup($formattedName); + $gapicClient->deleteTransitionRouteGroup($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -206,14 +247,24 @@ public function getTransitionRouteGroupTest() $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); // Mock request - $formattedName = $gapicClient->transitionRouteGroupName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[TRANSITION_ROUTE_GROUP]'); - $response = $gapicClient->getTransitionRouteGroup($formattedName); + $formattedName = $gapicClient->transitionRouteGroupName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[FLOW]', + '[TRANSITION_ROUTE_GROUP]' + ); + $request = (new GetTransitionRouteGroupRequest())->setName($formattedName); + $response = $gapicClient->getTransitionRouteGroup($request); $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.TransitionRouteGroups/GetTransitionRouteGroup', $actualFuncCall); + $this->assertSame( + '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/GetTransitionRouteGroup', + $actualFuncCall + ); $actualValue = $actualRequestObject->getName(); $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -230,17 +281,27 @@ public function getTransitionRouteGroupExceptionTest() $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); + $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->transitionRouteGroupName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[TRANSITION_ROUTE_GROUP]'); + $formattedName = $gapicClient->transitionRouteGroupName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[FLOW]', + '[TRANSITION_ROUTE_GROUP]' + ); + $request = (new GetTransitionRouteGroupRequest())->setName($formattedName); try { - $gapicClient->getTransitionRouteGroup($formattedName); + $gapicClient->getTransitionRouteGroup($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -263,16 +324,15 @@ public function listTransitionRouteGroupsTest() // Mock response $nextPageToken = ''; $transitionRouteGroupsElement = new TransitionRouteGroup(); - $transitionRouteGroups = [ - $transitionRouteGroupsElement, - ]; + $transitionRouteGroups = [$transitionRouteGroupsElement]; $expectedResponse = new ListTransitionRouteGroupsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setTransitionRouteGroups($transitionRouteGroups); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - $response = $gapicClient->listTransitionRouteGroups($formattedParent); + $request = (new ListTransitionRouteGroupsRequest())->setParent($formattedParent); + $response = $gapicClient->listTransitionRouteGroups($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -281,7 +341,10 @@ public function listTransitionRouteGroupsTest() $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/ListTransitionRouteGroups', $actualFuncCall); + $this->assertSame( + '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/ListTransitionRouteGroups', + $actualFuncCall + ); $actualValue = $actualRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -298,17 +361,21 @@ public function listTransitionRouteGroupsExceptionTest() $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); + $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->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); + $request = (new ListTransitionRouteGroupsRequest())->setParent($formattedParent); try { - $gapicClient->listTransitionRouteGroups($formattedParent); + $gapicClient->listTransitionRouteGroups($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -339,13 +406,17 @@ public function updateTransitionRouteGroupTest() $transitionRouteGroup = new TransitionRouteGroup(); $transitionRouteGroupDisplayName = 'transitionRouteGroupDisplayName-1406267262'; $transitionRouteGroup->setDisplayName($transitionRouteGroupDisplayName); - $response = $gapicClient->updateTransitionRouteGroup($transitionRouteGroup); + $request = (new UpdateTransitionRouteGroupRequest())->setTransitionRouteGroup($transitionRouteGroup); + $response = $gapicClient->updateTransitionRouteGroup($request); $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.TransitionRouteGroups/UpdateTransitionRouteGroup', $actualFuncCall); + $this->assertSame( + '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/UpdateTransitionRouteGroup', + $actualFuncCall + ); $actualValue = $actualRequestObject->getTransitionRouteGroup(); $this->assertProtobufEquals($transitionRouteGroup, $actualValue); $this->assertTrue($transport->isExhausted()); @@ -362,19 +433,23 @@ public function updateTransitionRouteGroupExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $transitionRouteGroup = new TransitionRouteGroup(); $transitionRouteGroupDisplayName = 'transitionRouteGroupDisplayName-1406267262'; $transitionRouteGroup->setDisplayName($transitionRouteGroupDisplayName); + $request = (new UpdateTransitionRouteGroupRequest())->setTransitionRouteGroup($transitionRouteGroup); try { - $gapicClient->updateTransitionRouteGroup($transitionRouteGroup); + $gapicClient->updateTransitionRouteGroup($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -403,7 +478,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -424,15 +500,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -455,14 +535,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -486,15 +565,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -505,4 +588,44 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function createTransitionRouteGroupAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $expectedResponse = new TransitionRouteGroup(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); + $transitionRouteGroup = new TransitionRouteGroup(); + $transitionRouteGroupDisplayName = 'transitionRouteGroupDisplayName-1406267262'; + $transitionRouteGroup->setDisplayName($transitionRouteGroupDisplayName); + $request = (new CreateTransitionRouteGroupRequest()) + ->setParent($formattedParent) + ->setTransitionRouteGroup($transitionRouteGroup); + $response = $gapicClient->createTransitionRouteGroupAsync($request)->wait(); + $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.TransitionRouteGroups/CreateTransitionRouteGroup', + $actualFuncCall + ); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getTransitionRouteGroup(); + $this->assertProtobufEquals($transitionRouteGroup, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/VersionsClientTest.php b/DialogflowCx/tests/Unit/V3/Client/VersionsClientTest.php similarity index 78% rename from DialogflowCx/tests/Unit/V3/VersionsClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/VersionsClientTest.php index 88492e913750..886f7af0a9e3 100644 --- a/DialogflowCx/tests/Unit/V3/VersionsClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/VersionsClientTest.php @@ -20,17 +20,26 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\Client\VersionsClient; +use Google\Cloud\Dialogflow\Cx\V3\CompareVersionsRequest; use Google\Cloud\Dialogflow\Cx\V3\CompareVersionsResponse; +use Google\Cloud\Dialogflow\Cx\V3\CreateVersionRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeleteVersionRequest; +use Google\Cloud\Dialogflow\Cx\V3\GetVersionRequest; +use Google\Cloud\Dialogflow\Cx\V3\ListVersionsRequest; use Google\Cloud\Dialogflow\Cx\V3\ListVersionsResponse; +use Google\Cloud\Dialogflow\Cx\V3\LoadVersionRequest; +use Google\Cloud\Dialogflow\Cx\V3\UpdateVersionRequest; use Google\Cloud\Dialogflow\Cx\V3\Version; -use Google\Cloud\Dialogflow\Cx\V3\VersionsClient; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\LongRunning\GetOperationRequest; @@ -57,7 +66,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return VersionsClient */ @@ -86,8 +97,17 @@ public function compareVersionsTest() $transport->addResponse($expectedResponse); // Mock request $formattedBaseVersion = $gapicClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - $formattedTargetVersion = $gapicClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - $response = $gapicClient->compareVersions($formattedBaseVersion, $formattedTargetVersion); + $formattedTargetVersion = $gapicClient->versionName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[FLOW]', + '[VERSION]' + ); + $request = (new CompareVersionsRequest()) + ->setBaseVersion($formattedBaseVersion) + ->setTargetVersion($formattedTargetVersion); + $response = $gapicClient->compareVersions($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -112,18 +132,30 @@ public function compareVersionsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $formattedBaseVersion = $gapicClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - $formattedTargetVersion = $gapicClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); + $formattedTargetVersion = $gapicClient->versionName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[FLOW]', + '[VERSION]' + ); + $request = (new CompareVersionsRequest()) + ->setBaseVersion($formattedBaseVersion) + ->setTargetVersion($formattedTargetVersion); try { - $gapicClient->compareVersions($formattedBaseVersion, $formattedTargetVersion); + $gapicClient->compareVersions($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -175,7 +207,8 @@ public function createVersionTest() $version = new Version(); $versionDisplayName = 'versionDisplayName1702521461'; $version->setDisplayName($versionDisplayName); - $response = $gapicClient->createVersion($formattedParent, $version); + $request = (new CreateVersionRequest())->setParent($formattedParent)->setVersion($version); + $response = $gapicClient->createVersion($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -232,19 +265,23 @@ public function createVersionExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedParent = $gapicClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); $version = new Version(); $versionDisplayName = 'versionDisplayName1702521461'; $version->setDisplayName($versionDisplayName); - $response = $gapicClient->createVersion($formattedParent, $version); + $request = (new CreateVersionRequest())->setParent($formattedParent)->setVersion($version); + $response = $gapicClient->createVersion($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -279,7 +316,8 @@ public function deleteVersionTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - $gapicClient->deleteVersion($formattedName); + $request = (new DeleteVersionRequest())->setName($formattedName); + $gapicClient->deleteVersion($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); @@ -301,17 +339,21 @@ public function deleteVersionExceptionTest() $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); + $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->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); + $request = (new DeleteVersionRequest())->setName($formattedName); try { - $gapicClient->deleteVersion($formattedName); + $gapicClient->deleteVersion($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -342,7 +384,8 @@ public function getVersionTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - $response = $gapicClient->getVersion($formattedName); + $request = (new GetVersionRequest())->setName($formattedName); + $response = $gapicClient->getVersion($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -365,17 +408,21 @@ public function getVersionExceptionTest() $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); + $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->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); + $request = (new GetVersionRequest())->setName($formattedName); try { - $gapicClient->getVersion($formattedName); + $gapicClient->getVersion($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -398,16 +445,15 @@ public function listVersionsTest() // Mock response $nextPageToken = ''; $versionsElement = new Version(); - $versions = [ - $versionsElement, - ]; + $versions = [$versionsElement]; $expectedResponse = new ListVersionsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setVersions($versions); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); - $response = $gapicClient->listVersions($formattedParent); + $request = (new ListVersionsRequest())->setParent($formattedParent); + $response = $gapicClient->listVersions($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -433,17 +479,21 @@ public function listVersionsExceptionTest() $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); + $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->flowName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]'); + $request = (new ListVersionsRequest())->setParent($formattedParent); try { - $gapicClient->listVersions($formattedParent); + $gapicClient->listVersions($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -486,7 +536,8 @@ public function loadVersionTest() $operationsTransport->addResponse($completeOperation); // Mock request $formattedName = $gapicClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - $response = $gapicClient->loadVersion($formattedName); + $request = (new LoadVersionRequest())->setName($formattedName); + $response = $gapicClient->loadVersion($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -541,16 +592,20 @@ public function loadVersionExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $operationsTransport->addResponse(null, $status); // Mock request $formattedName = $gapicClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); - $response = $gapicClient->loadVersion($formattedName); + $request = (new LoadVersionRequest())->setName($formattedName); + $response = $gapicClient->loadVersion($request); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $expectedOperationsRequestObject = new GetOperationRequest(); @@ -594,7 +649,8 @@ public function updateVersionTest() $versionDisplayName = 'versionDisplayName1702521461'; $version->setDisplayName($versionDisplayName); $updateMask = new FieldMask(); - $response = $gapicClient->updateVersion($version, $updateMask); + $request = (new UpdateVersionRequest())->setVersion($version)->setUpdateMask($updateMask); + $response = $gapicClient->updateVersion($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -619,20 +675,24 @@ public function updateVersionExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $version = new Version(); $versionDisplayName = 'versionDisplayName1702521461'; $version->setDisplayName($versionDisplayName); $updateMask = new FieldMask(); + $request = (new UpdateVersionRequest())->setVersion($version)->setUpdateMask($updateMask); try { - $gapicClient->updateVersion($version, $updateMask); + $gapicClient->updateVersion($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -661,7 +721,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -682,15 +743,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -713,14 +778,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -744,15 +808,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -763,4 +831,45 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function compareVersionsAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $baseVersionContentJson = 'baseVersionContentJson359428515'; + $targetVersionContentJson = 'targetVersionContentJson-1079099677'; + $expectedResponse = new CompareVersionsResponse(); + $expectedResponse->setBaseVersionContentJson($baseVersionContentJson); + $expectedResponse->setTargetVersionContentJson($targetVersionContentJson); + $transport->addResponse($expectedResponse); + // Mock request + $formattedBaseVersion = $gapicClient->versionName('[PROJECT]', '[LOCATION]', '[AGENT]', '[FLOW]', '[VERSION]'); + $formattedTargetVersion = $gapicClient->versionName( + '[PROJECT]', + '[LOCATION]', + '[AGENT]', + '[FLOW]', + '[VERSION]' + ); + $request = (new CompareVersionsRequest()) + ->setBaseVersion($formattedBaseVersion) + ->setTargetVersion($formattedTargetVersion); + $response = $gapicClient->compareVersionsAsync($request)->wait(); + $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.Versions/CompareVersions', $actualFuncCall); + $actualValue = $actualRequestObject->getBaseVersion(); + $this->assertProtobufEquals($formattedBaseVersion, $actualValue); + $actualValue = $actualRequestObject->getTargetVersion(); + $this->assertProtobufEquals($formattedTargetVersion, $actualValue); + $this->assertTrue($transport->isExhausted()); + } } diff --git a/DialogflowCx/tests/Unit/V3/WebhooksClientTest.php b/DialogflowCx/tests/Unit/V3/Client/WebhooksClientTest.php similarity index 74% rename from DialogflowCx/tests/Unit/V3/WebhooksClientTest.php rename to DialogflowCx/tests/Unit/V3/Client/WebhooksClientTest.php index 246826ec9b6b..1e64d859af55 100644 --- a/DialogflowCx/tests/Unit/V3/WebhooksClientTest.php +++ b/DialogflowCx/tests/Unit/V3/Client/WebhooksClientTest.php @@ -20,15 +20,22 @@ * This file was automatically generated - do not edit! */ -namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3; +namespace Google\Cloud\Dialogflow\Cx\Tests\Unit\V3\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Dialogflow\Cx\V3\Client\WebhooksClient; +use Google\Cloud\Dialogflow\Cx\V3\CreateWebhookRequest; +use Google\Cloud\Dialogflow\Cx\V3\DeleteWebhookRequest; +use Google\Cloud\Dialogflow\Cx\V3\GetWebhookRequest; +use Google\Cloud\Dialogflow\Cx\V3\ListWebhooksRequest; use Google\Cloud\Dialogflow\Cx\V3\ListWebhooksResponse; +use Google\Cloud\Dialogflow\Cx\V3\UpdateWebhookRequest; use Google\Cloud\Dialogflow\Cx\V3\Webhook; -use Google\Cloud\Dialogflow\Cx\V3\WebhooksClient; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\Protobuf\GPBEmpty; @@ -51,7 +58,9 @@ private function createTransport($deserialize = null) /** @return CredentialsWrapper */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); } /** @return WebhooksClient */ @@ -85,7 +94,8 @@ public function createWebhookTest() $webhook = new Webhook(); $webhookDisplayName = 'webhookDisplayName1755228022'; $webhook->setDisplayName($webhookDisplayName); - $response = $gapicClient->createWebhook($formattedParent, $webhook); + $request = (new CreateWebhookRequest())->setParent($formattedParent)->setWebhook($webhook); + $response = $gapicClient->createWebhook($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -110,20 +120,24 @@ public function createWebhookExceptionTest() $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); + $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]'); $webhook = new Webhook(); $webhookDisplayName = 'webhookDisplayName1755228022'; $webhook->setDisplayName($webhookDisplayName); + $request = (new CreateWebhookRequest())->setParent($formattedParent)->setWebhook($webhook); try { - $gapicClient->createWebhook($formattedParent, $webhook); + $gapicClient->createWebhook($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -148,7 +162,8 @@ public function deleteWebhookTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->webhookName('[PROJECT]', '[LOCATION]', '[AGENT]', '[WEBHOOK]'); - $gapicClient->deleteWebhook($formattedName); + $request = (new DeleteWebhookRequest())->setName($formattedName); + $gapicClient->deleteWebhook($request); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); @@ -170,17 +185,21 @@ public function deleteWebhookExceptionTest() $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); + $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->webhookName('[PROJECT]', '[LOCATION]', '[AGENT]', '[WEBHOOK]'); + $request = (new DeleteWebhookRequest())->setName($formattedName); try { - $gapicClient->deleteWebhook($formattedName); + $gapicClient->deleteWebhook($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -211,7 +230,8 @@ public function getWebhookTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->webhookName('[PROJECT]', '[LOCATION]', '[AGENT]', '[WEBHOOK]'); - $response = $gapicClient->getWebhook($formattedName); + $request = (new GetWebhookRequest())->setName($formattedName); + $response = $gapicClient->getWebhook($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -234,17 +254,21 @@ public function getWebhookExceptionTest() $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); + $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->webhookName('[PROJECT]', '[LOCATION]', '[AGENT]', '[WEBHOOK]'); + $request = (new GetWebhookRequest())->setName($formattedName); try { - $gapicClient->getWebhook($formattedName); + $gapicClient->getWebhook($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -267,16 +291,15 @@ public function listWebhooksTest() // Mock response $nextPageToken = ''; $webhooksElement = new Webhook(); - $webhooks = [ - $webhooksElement, - ]; + $webhooks = [$webhooksElement]; $expectedResponse = new ListWebhooksResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setWebhooks($webhooks); $transport->addResponse($expectedResponse); // Mock request $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); - $response = $gapicClient->listWebhooks($formattedParent); + $request = (new ListWebhooksRequest())->setParent($formattedParent); + $response = $gapicClient->listWebhooks($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -302,17 +325,21 @@ public function listWebhooksExceptionTest() $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); + $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]'); + $request = (new ListWebhooksRequest())->setParent($formattedParent); try { - $gapicClient->listWebhooks($formattedParent); + $gapicClient->listWebhooks($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -345,7 +372,8 @@ public function updateWebhookTest() $webhook = new Webhook(); $webhookDisplayName = 'webhookDisplayName1755228022'; $webhook->setDisplayName($webhookDisplayName); - $response = $gapicClient->updateWebhook($webhook); + $request = (new UpdateWebhookRequest())->setWebhook($webhook); + $response = $gapicClient->updateWebhook($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -368,19 +396,23 @@ public function updateWebhookExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); // Mock request $webhook = new Webhook(); $webhookDisplayName = 'webhookDisplayName1755228022'; $webhook->setDisplayName($webhookDisplayName); + $request = (new UpdateWebhookRequest())->setWebhook($webhook); try { - $gapicClient->updateWebhook($webhook); + $gapicClient->updateWebhook($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -409,7 +441,8 @@ public function getLocationTest() $expectedResponse->setLocationId($locationId); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - $response = $gapicClient->getLocation(); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -430,15 +463,19 @@ public function getLocationExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new GetLocationRequest(); try { - $gapicClient->getLocation(); + $gapicClient->getLocation($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -461,14 +498,13 @@ public function listLocationsTest() // Mock response $nextPageToken = ''; $locationsElement = new Location(); - $locations = [ - $locationsElement, - ]; + $locations = [$locationsElement]; $expectedResponse = new ListLocationsResponse(); $expectedResponse->setNextPageToken($nextPageToken); $expectedResponse->setLocations($locations); $transport->addResponse($expectedResponse); - $response = $gapicClient->listLocations(); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); @@ -492,15 +528,19 @@ public function listLocationsExceptionTest() $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); + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); $transport->addResponse(null, $status); + $request = new ListLocationsRequest(); try { - $gapicClient->listLocations(); + $gapicClient->listLocations($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -511,4 +551,41 @@ public function listLocationsExceptionTest() $transport->popReceivedCalls(); $this->assertTrue($transport->isExhausted()); } + + /** @test */ + public function createWebhookAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $disabled = true; + $expectedResponse = new Webhook(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDisabled($disabled); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]'); + $webhook = new Webhook(); + $webhookDisplayName = 'webhookDisplayName1755228022'; + $webhook->setDisplayName($webhookDisplayName); + $request = (new CreateWebhookRequest())->setParent($formattedParent)->setWebhook($webhook); + $response = $gapicClient->createWebhookAsync($request)->wait(); + $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.Webhooks/CreateWebhook', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getWebhook(); + $this->assertProtobufEquals($webhook, $actualValue); + $this->assertTrue($transport->isExhausted()); + } }