Skip to content

Commit

Permalink
chore: migrate samples to new surface (#6931)
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 595432418
Source-Link: googleapis/googleapis@4795a45
Source-Link: https://github.com/googleapis/googleapis-gen/commit/743615e580bab1815edba43a02c561face631c5f
Copy-Tag: eyJwIjoiRGVidWdnZXIvLk93bEJvdC55YW1sIiwiaCI6Ijc0MzYxNWU1ODBiYWIxODE1ZWRiYTQzYTAyYzU2MWZhY2U2MzFjNWYifQ==
Copy-Tag: eyJwIjoiRGlhbG9nZmxvdy8uT3dsQm90LnlhbWwiLCJoIjoiNzQzNjE1ZTU4MGJhYjE4MTVlZGJhNDNhMDJjNTYxZmFjZTYzMWM1ZiJ9
Copy-Tag: eyJwIjoiRGxwLy5Pd2xCb3QueWFtbCIsImgiOiI3NDM2MTVlNTgwYmFiMTgxNWVkYmE0M2EwMmM1NjFmYWNlNjMxYzVmIn0=
Copy-Tag: eyJwIjoiRG1zLy5Pd2xCb3QueWFtbCIsImgiOiI3NDM2MTVlNTgwYmFiMTgxNWVkYmE0M2EwMmM1NjFmYWNlNjMxYzVmIn0=
Copy-Tag: eyJwIjoiRG9jdW1lbnRBaS8uT3dsQm90LnlhbWwiLCJoIjoiNzQzNjE1ZTU4MGJhYjE4MTVlZGJhNDNhMDJjNTYxZmFjZTYzMWM1ZiJ9
Copy-Tag: eyJwIjoiRXZlbnRhcmMvLk93bEJvdC55YW1sIiwiaCI6Ijc0MzYxNWU1ODBiYWIxODE1ZWRiYTQzYTAyYzU2MWZhY2U2MzFjNWYifQ==
Copy-Tag: eyJwIjoiRmlsZXN0b3JlLy5Pd2xCb3QueWFtbCIsImgiOiI3NDM2MTVlNTgwYmFiMTgxNWVkYmE0M2EwMmM1NjFmYWNlNjMxYzVmIn0=
Copy-Tag: eyJwIjoiRmlyZXN0b3JlLy5Pd2xCb3QueWFtbCIsImgiOiI3NDM2MTVlNTgwYmFiMTgxNWVkYmE0M2EwMmM1NjFmYWNlNjMxYzVmI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29ya0Nvbm5lY3Rpdml0eS8uT3dsQm90LnlhbWwiLCJoIjoiNzQzNjE1ZTU4MGJhYjE4MTVlZGJhNDNhMDJjNTYxZmFjZTYzMWM1ZiJ9
Copy-Tag: eyJwIjoiTmV0d29ya01hbmFnZW1lbnQvLk93bEJvdC55YW1sIiwiaCI6Ijc0MzYxNWU1ODBiYWIxODE1ZWRiYTQzYTAyYzU2MWZhY2U2MzFjNWYifQ==
Copy-Tag: eyJwIjoiT3JjaGVzdHJhdGlvbkFpcmZsb3cvLk93bEJvdC55YW1sIiwiaCI6Ijc0MzYxNWU1ODBiYWIxODE1ZWRiYTQzYTAyYzU2MWZhY2U2MzFjNWYifQ==
  • Loading branch information
gcf-owl-bot[bot] authored Jan 4, 2024
1 parent 06af527 commit 152983d
Show file tree
Hide file tree
Showing 46 changed files with 385 additions and 102 deletions.
10 changes: 8 additions & 2 deletions samples/V2/ConfigServiceV2Client/copy_log_entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
// [START logging_v2_generated_ConfigServiceV2_CopyLogEntries_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\CopyLogEntriesRequest;
use Google\Cloud\Logging\V2\CopyLogEntriesResponse;
use Google\Rpc\Status;

Expand All @@ -44,10 +45,15 @@ function copy_log_entries_sample(string $name, string $destination): void
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

// Prepare the request message.
$request = (new CopyLogEntriesRequest())
->setName($name)
->setDestination($destination);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $configServiceV2Client->copyLogEntries($name, $destination);
$response = $configServiceV2Client->copyLogEntries($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
Expand Down
11 changes: 8 additions & 3 deletions samples/V2/ConfigServiceV2Client/create_bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START logging_v2_generated_ConfigServiceV2_CreateBucket_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\CreateBucketRequest;
use Google\Cloud\Logging\V2\LogBucket;

/**
Expand All @@ -48,13 +49,17 @@ function create_bucket_sample(string $formattedParent, string $bucketId): void
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$bucket = new LogBucket();
$request = (new CreateBucketRequest())
->setParent($formattedParent)
->setBucketId($bucketId)
->setBucket($bucket);

// Call the API and handle any network failures.
try {
/** @var LogBucket $response */
$response = $configServiceV2Client->createBucket($formattedParent, $bucketId, $bucket);
$response = $configServiceV2Client->createBucket($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 samples/V2/ConfigServiceV2Client/create_bucket_async.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
// [START logging_v2_generated_ConfigServiceV2_CreateBucketAsync_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\CreateBucketRequest;
use Google\Cloud\Logging\V2\LogBucket;
use Google\Rpc\Status;

Expand All @@ -51,13 +52,17 @@ function create_bucket_async_sample(string $formattedParent, string $bucketId):
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$bucket = new LogBucket();
$request = (new CreateBucketRequest())
->setParent($formattedParent)
->setBucketId($bucketId)
->setBucket($bucket);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $configServiceV2Client->createBucketAsync($formattedParent, $bucketId, $bucket);
$response = $configServiceV2Client->createBucketAsync($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
Expand Down
10 changes: 7 additions & 3 deletions samples/V2/ConfigServiceV2Client/create_exclusion.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START logging_v2_generated_ConfigServiceV2_CreateExclusion_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\CreateExclusionRequest;
use Google\Cloud\Logging\V2\LogExclusion;

/**
Expand Down Expand Up @@ -67,15 +68,18 @@ function create_exclusion_sample(
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$exclusion = (new LogExclusion())
->setName($exclusionName)
->setFilter($exclusionFilter);
$request = (new CreateExclusionRequest())
->setParent($formattedParent)
->setExclusion($exclusion);

// Call the API and handle any network failures.
try {
/** @var LogExclusion $response */
$response = $configServiceV2Client->createExclusion($formattedParent, $exclusion);
$response = $configServiceV2Client->createExclusion($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 samples/V2/ConfigServiceV2Client/create_link.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
// [START logging_v2_generated_ConfigServiceV2_CreateLink_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\CreateLinkRequest;
use Google\Cloud\Logging\V2\Link;
use Google\Rpc\Status;

Expand All @@ -50,13 +51,17 @@ function create_link_sample(string $formattedParent, string $linkId): void
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$link = new Link();
$request = (new CreateLinkRequest())
->setParent($formattedParent)
->setLink($link)
->setLinkId($linkId);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $configServiceV2Client->createLink($formattedParent, $link, $linkId);
$response = $configServiceV2Client->createLink($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
Expand Down
10 changes: 7 additions & 3 deletions samples/V2/ConfigServiceV2Client/create_sink.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START logging_v2_generated_ConfigServiceV2_CreateSink_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\CreateSinkRequest;
use Google\Cloud\Logging\V2\LogSink;

/**
Expand Down Expand Up @@ -71,15 +72,18 @@ function create_sink_sample(
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$sink = (new LogSink())
->setName($sinkName)
->setDestination($sinkDestination);
$request = (new CreateSinkRequest())
->setParent($formattedParent)
->setSink($sink);

// Call the API and handle any network failures.
try {
/** @var LogSink $response */
$response = $configServiceV2Client->createSink($formattedParent, $sink);
$response = $configServiceV2Client->createSink($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 samples/V2/ConfigServiceV2Client/create_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START logging_v2_generated_ConfigServiceV2_CreateView_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\CreateViewRequest;
use Google\Cloud\Logging\V2\LogView;

/**
Expand All @@ -47,13 +48,17 @@ function create_view_sample(string $parent, string $viewId): void
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$view = new LogView();
$request = (new CreateViewRequest())
->setParent($parent)
->setViewId($viewId)
->setView($view);

// Call the API and handle any network failures.
try {
/** @var LogView $response */
$response = $configServiceV2Client->createView($parent, $viewId, $view);
$response = $configServiceV2Client->createView($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 samples/V2/ConfigServiceV2Client/delete_bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START logging_v2_generated_ConfigServiceV2_DeleteBucket_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\DeleteBucketRequest;

/**
* Deletes a log bucket.
Expand All @@ -50,9 +51,13 @@ function delete_bucket_sample(string $formattedName): void
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

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

// Call the API and handle any network failures.
try {
$configServiceV2Client->deleteBucket($formattedName);
$configServiceV2Client->deleteBucket($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 samples/V2/ConfigServiceV2Client/delete_exclusion.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START logging_v2_generated_ConfigServiceV2_DeleteExclusion_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\DeleteExclusionRequest;

/**
* Deletes an exclusion in the _Default sink.
Expand All @@ -46,9 +47,13 @@ function delete_exclusion_sample(string $formattedName): void
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

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

// Call the API and handle any network failures.
try {
$configServiceV2Client->deleteExclusion($formattedName);
$configServiceV2Client->deleteExclusion($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 samples/V2/ConfigServiceV2Client/delete_link.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
// [START logging_v2_generated_ConfigServiceV2_DeleteLink_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\DeleteLinkRequest;
use Google\Rpc\Status;

/**
Expand All @@ -45,10 +46,14 @@ function delete_link_sample(string $formattedName): void
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

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

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

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

// [START logging_v2_generated_ConfigServiceV2_DeleteSink_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\DeleteSinkRequest;

/**
* Deletes a sink. If the sink has a unique `writer_identity`, then that
Expand All @@ -48,9 +49,13 @@ function delete_sink_sample(string $formattedSinkName): void
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

// Prepare the request message.
$request = (new DeleteSinkRequest())
->setSinkName($formattedSinkName);

// Call the API and handle any network failures.
try {
$configServiceV2Client->deleteSink($formattedSinkName);
$configServiceV2Client->deleteSink($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 samples/V2/ConfigServiceV2Client/delete_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START logging_v2_generated_ConfigServiceV2_DeleteView_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\DeleteViewRequest;

/**
* Deletes a view on a log bucket.
Expand All @@ -46,9 +47,13 @@ function delete_view_sample(string $formattedName): void
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

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

// Call the API and handle any network failures.
try {
$configServiceV2Client->deleteView($formattedName);
$configServiceV2Client->deleteView($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 samples/V2/ConfigServiceV2Client/get_bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START logging_v2_generated_ConfigServiceV2_GetBucket_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\GetBucketRequest;
use Google\Cloud\Logging\V2\LogBucket;

/**
Expand All @@ -47,10 +48,14 @@ function get_bucket_sample(string $formattedName): void
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

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

// Call the API and handle any network failures.
try {
/** @var LogBucket $response */
$response = $configServiceV2Client->getBucket($formattedName);
$response = $configServiceV2Client->getBucket($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 samples/V2/ConfigServiceV2Client/get_cmek_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

// [START logging_v2_generated_ConfigServiceV2_GetCmekSettings_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Logging\V2\Client\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\CmekSettings;
use Google\Cloud\Logging\V2\ConfigServiceV2Client;
use Google\Cloud\Logging\V2\GetCmekSettingsRequest;

/**
* Gets the Logging CMEK settings for the given resource.
Expand All @@ -50,10 +51,13 @@ function get_cmek_settings_sample(): void
// Create a client.
$configServiceV2Client = new ConfigServiceV2Client();

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

// Call the API and handle any network failures.
try {
/** @var CmekSettings $response */
$response = $configServiceV2Client->getCmekSettings();
$response = $configServiceV2Client->getCmekSettings($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 152983d

Please sign in to comment.