Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [Many APIs] add new client surface to preview clients #6203

Merged
merged 2 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START dataform_v1beta1_generated_Dataform_CancelWorkflowInvocation_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\CancelWorkflowInvocationRequest;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;

/**
* Requests cancellation of a running WorkflowInvocation.
Expand All @@ -37,9 +38,13 @@ function cancel_workflow_invocation_sample(string $formattedName): void
// Create a client.
$dataformClient = new DataformClient();

// Prepare the request message.
$request = (new CancelWorkflowInvocationRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
$dataformClient->cancelWorkflowInvocation($formattedName);
$dataformClient->cancelWorkflowInvocation($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 dataform_v1beta1_generated_Dataform_CommitWorkspaceChanges_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\CommitAuthor;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\CommitWorkspaceChangesRequest;

/**
* Applies a Git commit for uncommitted files in a Workspace.
Expand All @@ -43,14 +44,17 @@ function commit_workspace_changes_sample(
// Create a client.
$dataformClient = new DataformClient();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$author = (new CommitAuthor())
->setName($authorName)
->setEmailAddress($authorEmailAddress);
$request = (new CommitWorkspaceChangesRequest())
->setName($formattedName)
->setAuthor($author);

// Call the API and handle any network failures.
try {
$dataformClient->commitWorkspaceChanges($formattedName, $author);
$dataformClient->commitWorkspaceChanges($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 dataform_v1beta1_generated_Dataform_CreateCompilationResult_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\CompilationResult;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\CreateCompilationResultRequest;

/**
* Creates a new CompilationResult in a given project and location.
Expand All @@ -39,13 +40,16 @@ function create_compilation_result_sample(string $formattedParent): void
// Create a client.
$dataformClient = new DataformClient();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$compilationResult = new CompilationResult();
$request = (new CreateCompilationResultRequest())
->setParent($formattedParent)
->setCompilationResult($compilationResult);

// Call the API and handle any network failures.
try {
/** @var CompilationResult $response */
$response = $dataformClient->createCompilationResult($formattedParent, $compilationResult);
$response = $dataformClient->createCompilationResult($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
Expand Down
11 changes: 8 additions & 3 deletions Dataform/samples/V1beta1/DataformClient/create_repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START dataform_v1beta1_generated_Dataform_CreateRepository_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\CreateRepositoryRequest;
use Google\Cloud\Dataform\V1beta1\Repository;

/**
Expand All @@ -41,13 +42,17 @@ function create_repository_sample(string $formattedParent, string $repositoryId)
// Create a client.
$dataformClient = new DataformClient();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$repository = new Repository();
$request = (new CreateRepositoryRequest())
->setParent($formattedParent)
->setRepository($repository)
->setRepositoryId($repositoryId);

// Call the API and handle any network failures.
try {
/** @var Repository $response */
$response = $dataformClient->createRepository($formattedParent, $repository, $repositoryId);
$response = $dataformClient->createRepository($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,7 +24,8 @@

// [START dataform_v1beta1_generated_Dataform_CreateWorkflowInvocation_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\CreateWorkflowInvocationRequest;
use Google\Cloud\Dataform\V1beta1\WorkflowInvocation;

/**
Expand All @@ -39,13 +40,16 @@ function create_workflow_invocation_sample(string $formattedParent): void
// Create a client.
$dataformClient = new DataformClient();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$workflowInvocation = new WorkflowInvocation();
$request = (new CreateWorkflowInvocationRequest())
->setParent($formattedParent)
->setWorkflowInvocation($workflowInvocation);

// Call the API and handle any network failures.
try {
/** @var WorkflowInvocation $response */
$response = $dataformClient->createWorkflowInvocation($formattedParent, $workflowInvocation);
$response = $dataformClient->createWorkflowInvocation($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
Expand Down
11 changes: 8 additions & 3 deletions Dataform/samples/V1beta1/DataformClient/create_workspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START dataform_v1beta1_generated_Dataform_CreateWorkspace_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\CreateWorkspaceRequest;
use Google\Cloud\Dataform\V1beta1\Workspace;

/**
Expand All @@ -41,13 +42,17 @@ function create_workspace_sample(string $formattedParent, string $workspaceId):
// Create a client.
$dataformClient = new DataformClient();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$workspace = new Workspace();
$request = (new CreateWorkspaceRequest())
->setParent($formattedParent)
->setWorkspace($workspace)
->setWorkspaceId($workspaceId);

// Call the API and handle any network failures.
try {
/** @var Workspace $response */
$response = $dataformClient->createWorkspace($formattedParent, $workspace, $workspaceId);
$response = $dataformClient->createWorkspace($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,7 +24,8 @@

// [START dataform_v1beta1_generated_Dataform_DeleteRepository_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\DeleteRepositoryRequest;

/**
* Deletes a single Repository.
Expand All @@ -37,9 +38,13 @@ function delete_repository_sample(string $formattedName): void
// Create a client.
$dataformClient = new DataformClient();

// Prepare the request message.
$request = (new DeleteRepositoryRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
$dataformClient->deleteRepository($formattedName);
$dataformClient->deleteRepository($request);
printf('Call completed successfully.' . PHP_EOL);
} 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,7 +24,8 @@

// [START dataform_v1beta1_generated_Dataform_DeleteWorkflowInvocation_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\DeleteWorkflowInvocationRequest;

/**
* Deletes a single WorkflowInvocation.
Expand All @@ -37,9 +38,13 @@ function delete_workflow_invocation_sample(string $formattedName): void
// Create a client.
$dataformClient = new DataformClient();

// Prepare the request message.
$request = (new DeleteWorkflowInvocationRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
$dataformClient->deleteWorkflowInvocation($formattedName);
$dataformClient->deleteWorkflowInvocation($request);
printf('Call completed successfully.' . PHP_EOL);
} 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,7 +24,8 @@

// [START dataform_v1beta1_generated_Dataform_DeleteWorkspace_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\DeleteWorkspaceRequest;

/**
* Deletes a single Workspace.
Expand All @@ -37,9 +38,13 @@ function delete_workspace_sample(string $formattedName): void
// Create a client.
$dataformClient = new DataformClient();

// Prepare the request message.
$request = (new DeleteWorkspaceRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
$dataformClient->deleteWorkspace($formattedName);
$dataformClient->deleteWorkspace($request);
printf('Call completed successfully.' . PHP_EOL);
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
Expand Down
10 changes: 8 additions & 2 deletions Dataform/samples/V1beta1/DataformClient/fetch_file_diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START dataform_v1beta1_generated_Dataform_FetchFileDiff_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\FetchFileDiffRequest;
use Google\Cloud\Dataform\V1beta1\FetchFileDiffResponse;

/**
Expand All @@ -39,10 +40,15 @@ function fetch_file_diff_sample(string $formattedWorkspace, string $path): void
// Create a client.
$dataformClient = new DataformClient();

// Prepare the request message.
$request = (new FetchFileDiffRequest())
->setWorkspace($formattedWorkspace)
->setPath($path);

// Call the API and handle any network failures.
try {
/** @var FetchFileDiffResponse $response */
$response = $dataformClient->fetchFileDiff($formattedWorkspace, $path);
$response = $dataformClient->fetchFileDiff($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,7 +24,8 @@

// [START dataform_v1beta1_generated_Dataform_FetchFileGitStatuses_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\FetchFileGitStatusesRequest;
use Google\Cloud\Dataform\V1beta1\FetchFileGitStatusesResponse;

/**
Expand All @@ -38,10 +39,14 @@ function fetch_file_git_statuses_sample(string $formattedName): void
// Create a client.
$dataformClient = new DataformClient();

// Prepare the request message.
$request = (new FetchFileGitStatusesRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var FetchFileGitStatusesResponse $response */
$response = $dataformClient->fetchFileGitStatuses($formattedName);
$response = $dataformClient->fetchFileGitStatuses($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,7 +24,8 @@

// [START dataform_v1beta1_generated_Dataform_FetchGitAheadBehind_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\FetchGitAheadBehindRequest;
use Google\Cloud\Dataform\V1beta1\FetchGitAheadBehindResponse;

/**
Expand All @@ -38,10 +39,14 @@ function fetch_git_ahead_behind_sample(string $formattedName): void
// Create a client.
$dataformClient = new DataformClient();

// Prepare the request message.
$request = (new FetchGitAheadBehindRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var FetchGitAheadBehindResponse $response */
$response = $dataformClient->fetchGitAheadBehind($formattedName);
$response = $dataformClient->fetchGitAheadBehind($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,7 +24,8 @@

// [START dataform_v1beta1_generated_Dataform_FetchRemoteBranches_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\FetchRemoteBranchesRequest;
use Google\Cloud\Dataform\V1beta1\FetchRemoteBranchesResponse;

/**
Expand All @@ -38,10 +39,14 @@ function fetch_remote_branches_sample(string $formattedName): void
// Create a client.
$dataformClient = new DataformClient();

// Prepare the request message.
$request = (new FetchRemoteBranchesRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var FetchRemoteBranchesResponse $response */
$response = $dataformClient->fetchRemoteBranches($formattedName);
$response = $dataformClient->fetchRemoteBranches($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 dataform_v1beta1_generated_Dataform_GetCompilationResult_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\CompilationResult;
use Google\Cloud\Dataform\V1beta1\DataformClient;
use Google\Cloud\Dataform\V1beta1\GetCompilationResultRequest;

/**
* Fetches a single CompilationResult.
Expand All @@ -38,10 +39,14 @@ function get_compilation_result_sample(string $formattedName): void
// Create a client.
$dataformClient = new DataformClient();

// Prepare the request message.
$request = (new GetCompilationResultRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var CompilationResult $response */
$response = $dataformClient->getCompilationResult($formattedName);
$response = $dataformClient->getCompilationResult($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