Skip to content

Commit

Permalink
feat: add new client surface to preview clients (#6205)
Browse files Browse the repository at this point in the history
chore: regenerate API index
Source-Link: googleapis/googleapis@a012f7c
Source-Link: googleapis/googleapis-gen@3dfb33d
Copy-Tag: eyJwIjoiUmVzb3VyY2VNYW5hZ2VyLy5Pd2xCb3QueWFtbCIsImgiOiIzZGZiMzNkYjQzY2EyZDFmNTJhYzg0YTY0NjBhNTU5YWVjYmRmZDE3In0=
  • Loading branch information
gcf-owl-bot[bot] authored May 10, 2023
1 parent 125110f commit e3420e7
Show file tree
Hide file tree
Showing 117 changed files with 10,987 additions and 124 deletions.
9 changes: 6 additions & 3 deletions ResourceManager/samples/V3/FoldersClient/create_folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
// [START cloudresourcemanager_v3_generated_Folders_CreateFolder_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ResourceManager\V3\Client\FoldersClient;
use Google\Cloud\ResourceManager\V3\CreateFolderRequest;
use Google\Cloud\ResourceManager\V3\Folder;
use Google\Cloud\ResourceManager\V3\FoldersClient;
use Google\Rpc\Status;

/**
Expand Down Expand Up @@ -67,14 +68,16 @@ function create_folder_sample(string $folderParent): void
// Create a client.
$foldersClient = new FoldersClient();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$folder = (new Folder())
->setParent($folderParent);
$request = (new CreateFolderRequest())
->setFolder($folder);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $foldersClient->createFolder($folder);
$response = $foldersClient->createFolder($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
Expand Down
9 changes: 7 additions & 2 deletions ResourceManager/samples/V3/FoldersClient/delete_folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
// [START cloudresourcemanager_v3_generated_Folders_DeleteFolder_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ResourceManager\V3\Client\FoldersClient;
use Google\Cloud\ResourceManager\V3\DeleteFolderRequest;
use Google\Cloud\ResourceManager\V3\Folder;
use Google\Cloud\ResourceManager\V3\FoldersClient;
use Google\Rpc\Status;

/**
Expand All @@ -51,10 +52,14 @@ function delete_folder_sample(string $formattedName): void
// Create a client.
$foldersClient = new FoldersClient();

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

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $foldersClient->deleteFolder($formattedName);
$response = $foldersClient->deleteFolder($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
Expand Down
9 changes: 7 additions & 2 deletions ResourceManager/samples/V3/FoldersClient/get_folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

// [START cloudresourcemanager_v3_generated_Folders_GetFolder_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\ResourceManager\V3\Client\FoldersClient;
use Google\Cloud\ResourceManager\V3\Folder;
use Google\Cloud\ResourceManager\V3\FoldersClient;
use Google\Cloud\ResourceManager\V3\GetFolderRequest;

/**
* Retrieves a folder identified by the supplied resource name.
Expand All @@ -43,10 +44,14 @@ function get_folder_sample(string $formattedName): void
// Create a client.
$foldersClient = new FoldersClient();

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

// Call the API and handle any network failures.
try {
/** @var Folder $response */
$response = $foldersClient->getFolder($formattedName);
$response = $foldersClient->getFolder($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 ResourceManager/samples/V3/FoldersClient/get_iam_policy.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

// [START cloudresourcemanager_v3_generated_Folders_GetIamPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
use Google\Cloud\Iam\V1\Policy;
use Google\Cloud\ResourceManager\V3\FoldersClient;
use Google\Cloud\ResourceManager\V3\Client\FoldersClient;

/**
* Gets the access control policy for a folder. The returned policy may be
Expand All @@ -42,10 +43,14 @@ function get_iam_policy_sample(string $resource): void
// Create a client.
$foldersClient = new FoldersClient();

// Prepare the request message.
$request = (new GetIamPolicyRequest())
->setResource($resource);

// Call the API and handle any network failures.
try {
/** @var Policy $response */
$response = $foldersClient->getIamPolicy($resource);
$response = $foldersClient->getIamPolicy($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 ResourceManager/samples/V3/FoldersClient/list_folders.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
// [START cloudresourcemanager_v3_generated_Folders_ListFolders_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\ResourceManager\V3\Client\FoldersClient;
use Google\Cloud\ResourceManager\V3\Folder;
use Google\Cloud\ResourceManager\V3\FoldersClient;
use Google\Cloud\ResourceManager\V3\ListFoldersRequest;

/**
* Lists the folders that are direct descendants of supplied parent resource.
Expand All @@ -52,10 +53,14 @@ function list_folders_sample(string $parent): void
// Create a client.
$foldersClient = new FoldersClient();

// Prepare the request message.
$request = (new ListFoldersRequest())
->setParent($parent);

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $foldersClient->listFolders($parent);
$response = $foldersClient->listFolders($request);

/** @var Folder $element */
foreach ($response as $element) {
Expand Down
10 changes: 8 additions & 2 deletions ResourceManager/samples/V3/FoldersClient/move_folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
// [START cloudresourcemanager_v3_generated_Folders_MoveFolder_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ResourceManager\V3\Client\FoldersClient;
use Google\Cloud\ResourceManager\V3\Folder;
use Google\Cloud\ResourceManager\V3\FoldersClient;
use Google\Cloud\ResourceManager\V3\MoveFolderRequest;
use Google\Rpc\Status;

/**
Expand Down Expand Up @@ -60,10 +61,15 @@ function move_folder_sample(string $formattedName, string $destinationParent): v
// Create a client.
$foldersClient = new FoldersClient();

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

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $foldersClient->moveFolder($formattedName, $destinationParent);
$response = $foldersClient->moveFolder($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
Expand Down
8 changes: 6 additions & 2 deletions ResourceManager/samples/V3/FoldersClient/search_folders.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
// [START cloudresourcemanager_v3_generated_Folders_SearchFolders_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\ResourceManager\V3\Client\FoldersClient;
use Google\Cloud\ResourceManager\V3\Folder;
use Google\Cloud\ResourceManager\V3\FoldersClient;
use Google\Cloud\ResourceManager\V3\SearchFoldersRequest;

/**
* Search for folders that match specific filter criteria.
Expand All @@ -47,10 +48,13 @@ function search_folders_sample(): void
// Create a client.
$foldersClient = new FoldersClient();

// Prepare the request message.
$request = new SearchFoldersRequest();

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $foldersClient->searchFolders();
$response = $foldersClient->searchFolders($request);

/** @var Folder $element */
foreach ($response as $element) {
Expand Down
10 changes: 7 additions & 3 deletions ResourceManager/samples/V3/FoldersClient/set_iam_policy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
// [START cloudresourcemanager_v3_generated_Folders_SetIamPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Iam\V1\Policy;
use Google\Cloud\ResourceManager\V3\FoldersClient;
use Google\Cloud\Iam\V1\SetIamPolicyRequest;
use Google\Cloud\ResourceManager\V3\Client\FoldersClient;

/**
* Sets the access control policy on a folder, replacing any existing policy.
Expand All @@ -42,13 +43,16 @@ function set_iam_policy_sample(string $resource): void
// Create a client.
$foldersClient = new FoldersClient();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$policy = new Policy();
$request = (new SetIamPolicyRequest())
->setResource($resource)
->setPolicy($policy);

// Call the API and handle any network failures.
try {
/** @var Policy $response */
$response = $foldersClient->setIamPolicy($resource, $policy);
$response = $foldersClient->setIamPolicy($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 cloudresourcemanager_v3_generated_Folders_TestIamPermissions_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Iam\V1\TestIamPermissionsRequest;
use Google\Cloud\Iam\V1\TestIamPermissionsResponse;
use Google\Cloud\ResourceManager\V3\FoldersClient;
use Google\Cloud\ResourceManager\V3\Client\FoldersClient;

/**
* Returns permissions that a caller has on the specified folder.
Expand All @@ -46,13 +47,16 @@ function test_iam_permissions_sample(string $resource, string $permissionsElemen
// Create a client.
$foldersClient = new FoldersClient();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$permissions = [$permissionsElement,];
$request = (new TestIamPermissionsRequest())
->setResource($resource)
->setPermissions($permissions);

// Call the API and handle any network failures.
try {
/** @var TestIamPermissionsResponse $response */
$response = $foldersClient->testIamPermissions($resource, $permissions);
$response = $foldersClient->testIamPermissions($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 ResourceManager/samples/V3/FoldersClient/undelete_folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
// [START cloudresourcemanager_v3_generated_Folders_UndeleteFolder_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ResourceManager\V3\Client\FoldersClient;
use Google\Cloud\ResourceManager\V3\Folder;
use Google\Cloud\ResourceManager\V3\FoldersClient;
use Google\Cloud\ResourceManager\V3\UndeleteFolderRequest;
use Google\Rpc\Status;

/**
Expand All @@ -51,10 +52,14 @@ function undelete_folder_sample(string $formattedName): void
// Create a client.
$foldersClient = new FoldersClient();

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

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $foldersClient->undeleteFolder($formattedName);
$response = $foldersClient->undeleteFolder($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
Expand Down
10 changes: 7 additions & 3 deletions ResourceManager/samples/V3/FoldersClient/update_folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
// [START cloudresourcemanager_v3_generated_Folders_UpdateFolder_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ResourceManager\V3\Client\FoldersClient;
use Google\Cloud\ResourceManager\V3\Folder;
use Google\Cloud\ResourceManager\V3\FoldersClient;
use Google\Cloud\ResourceManager\V3\UpdateFolderRequest;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

Expand Down Expand Up @@ -58,15 +59,18 @@ function update_folder_sample(string $folderParent): void
// Create a client.
$foldersClient = new FoldersClient();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$folder = (new Folder())
->setParent($folderParent);
$updateMask = new FieldMask();
$request = (new UpdateFolderRequest())
->setFolder($folder)
->setUpdateMask($updateMask);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $foldersClient->updateFolder($folder, $updateMask);
$response = $foldersClient->updateFolder($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

// [START cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
use Google\Cloud\Iam\V1\Policy;
use Google\Cloud\ResourceManager\V3\OrganizationsClient;
use Google\Cloud\ResourceManager\V3\Client\OrganizationsClient;

/**
* Gets the access control policy for an organization resource. The policy may
Expand All @@ -43,10 +44,14 @@ function get_iam_policy_sample(string $resource): void
// Create a client.
$organizationsClient = new OrganizationsClient();

// Prepare the request message.
$request = (new GetIamPolicyRequest())
->setResource($resource);

// Call the API and handle any network failures.
try {
/** @var Policy $response */
$response = $organizationsClient->getIamPolicy($resource);
$response = $organizationsClient->getIamPolicy($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 cloudresourcemanager_v3_generated_Organizations_GetOrganization_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\ResourceManager\V3\Client\OrganizationsClient;
use Google\Cloud\ResourceManager\V3\GetOrganizationRequest;
use Google\Cloud\ResourceManager\V3\Organization;
use Google\Cloud\ResourceManager\V3\OrganizationsClient;

/**
* Fetches an organization resource identified by the specified resource name.
Expand All @@ -40,10 +41,14 @@ function get_organization_sample(string $formattedName): void
// Create a client.
$organizationsClient = new OrganizationsClient();

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

// Call the API and handle any network failures.
try {
/** @var Organization $response */
$response = $organizationsClient->getOrganization($formattedName);
$response = $organizationsClient->getOrganization($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,8 +25,9 @@
// [START cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\ResourceManager\V3\Client\OrganizationsClient;
use Google\Cloud\ResourceManager\V3\Organization;
use Google\Cloud\ResourceManager\V3\OrganizationsClient;
use Google\Cloud\ResourceManager\V3\SearchOrganizationsRequest;

/**
* Searches organization resources that are visible to the user and satisfy
Expand All @@ -48,10 +49,13 @@ function search_organizations_sample(): void
// Create a client.
$organizationsClient = new OrganizationsClient();

// Prepare the request message.
$request = new SearchOrganizationsRequest();

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $organizationsClient->searchOrganizations();
$response = $organizationsClient->searchOrganizations($request);

/** @var Organization $element */
foreach ($response as $element) {
Expand Down
Loading

0 comments on commit e3420e7

Please sign in to comment.