Skip to content

Commit

Permalink
feat: add new client library surface for Dialogflow CX PHP (#6906)
Browse files Browse the repository at this point in the history
feat!: remove previous client surfaces in favor of new Client surfaces (see Client namespace)
PiperOrigin-RevId: 592861461
Source-Link: googleapis/googleapis@1c2be6e
Source-Link: googleapis/googleapis-gen@81d3123
Copy-Tag: eyJwIjoiRGlhbG9nZmxvd0N4Ly5Pd2xCb3QueWFtbCIsImgiOiI4MWQzMTIzODFmZGEyZmMxOGYxOGI3MWY0NjA1MWIzNmNmNWU3MWNmIn0=

* remove previous surface client
Co-authored-by: Brent Shaffer <[email protected]>
  • Loading branch information
gcf-owl-bot[bot] and bshaffer authored Dec 22, 2023
1 parent 515a9f6 commit 4042b12
Show file tree
Hide file tree
Showing 313 changed files with 17,254 additions and 18,562 deletions.
10 changes: 7 additions & 3 deletions DialogflowCx/samples/V3/AgentsClient/create_agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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());
Expand Down
9 changes: 7 additions & 2 deletions DialogflowCx/samples/V3/AgentsClient/delete_agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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());
Expand Down
9 changes: 7 additions & 2 deletions DialogflowCx/samples/V3/AgentsClient/export_agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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()) {
Expand Down
9 changes: 7 additions & 2 deletions DialogflowCx/samples/V3/AgentsClient/get_agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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());
Expand Down
10 changes: 8 additions & 2 deletions DialogflowCx/samples/V3/AgentsClient/get_generative_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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());
Expand Down
8 changes: 6 additions & 2 deletions DialogflowCx/samples/V3/AgentsClient/get_location.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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());
Expand Down
9 changes: 7 additions & 2 deletions DialogflowCx/samples/V3/AgentsClient/list_agents.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions DialogflowCx/samples/V3/AgentsClient/list_locations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions DialogflowCx/samples/V3/AgentsClient/restore_agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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()) {
Expand Down
9 changes: 6 additions & 3 deletions DialogflowCx/samples/V3/AgentsClient/update_agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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());
Expand Down
9 changes: 7 additions & 2 deletions DialogflowCx/samples/V3/AgentsClient/validate_agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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());
Expand Down
9 changes: 7 additions & 2 deletions DialogflowCx/samples/V3/ChangelogsClient/get_changelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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());
Expand Down
Loading

0 comments on commit 4042b12

Please sign in to comment.