-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Log Analytics features of the Cloud Logging API (#6189)
feat: Add ConfigServiceV2.CreateBucketAsync method for creating Log Buckets asynchronously feat: Add ConfigServiceV2.UpdateBucketAsync method for creating Log Buckets asynchronously feat: Add ConfigServiceV2.CreateLink method for creating linked datasets for Log Analytics Buckets feat: Add ConfigServiceV2.DeleteLink method for deleting linked datasets feat: Add ConfigServiceV2.ListLinks method for listing linked datasets feat: Add ConfigServiceV2.GetLink methods for describing linked datasets feat: Add LogBucket.analytics_enabled field that specifies whether Log Bucket's Analytics features are enabled feat: Add LogBucket.index_configs field that contains a list of Log Bucket's indexed fields and related configuration data docs: Documentation for the Log Analytics features of the Cloud Logging API PiperOrigin-RevId: 529851525 Source-Link: googleapis/googleapis@1c7ee99 Source-Link: googleapis/googleapis-gen@4a2a3a0 Copy-Tag: eyJwIjoiTG9nZ2luZy8uT3dsQm90LnlhbWwiLCJoIjoiNGEyYTNhMDViOTE4MDQzMzNhMWIzOWI2MzVkOGZlMjI0M2Q0YjRmZCJ9
- Loading branch information
1 parent
de72b94
commit be76df8
Showing
64 changed files
with
4,929 additions
and
628 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
Logging/samples/V2/ConfigServiceV2Client/create_bucket_async.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [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\LogBucket; | ||
use Google\Rpc\Status; | ||
|
||
/** | ||
* Creates a log bucket asynchronously that can be used to store log entries. | ||
* | ||
* After a bucket has been created, the bucket's location cannot be changed. | ||
* | ||
* @param string $formattedParent The resource in which to create the log bucket: | ||
* | ||
* "projects/[PROJECT_ID]/locations/[LOCATION_ID]" | ||
* | ||
* For example: | ||
* | ||
* `"projects/my-project/locations/global"` | ||
* Please see {@see ConfigServiceV2Client::organizationLocationName()} for help formatting this field. | ||
* @param string $bucketId A client-assigned identifier such as `"my-bucket"`. Identifiers | ||
* are limited to 100 characters and can include only letters, digits, | ||
* underscores, hyphens, and periods. | ||
*/ | ||
function create_bucket_async_sample(string $formattedParent, string $bucketId): void | ||
{ | ||
// Create a client. | ||
$configServiceV2Client = new ConfigServiceV2Client(); | ||
|
||
// Prepare any non-scalar elements to be passed along with the request. | ||
$bucket = new LogBucket(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var OperationResponse $response */ | ||
$response = $configServiceV2Client->createBucketAsync($formattedParent, $bucketId, $bucket); | ||
$response->pollUntilComplete(); | ||
|
||
if ($response->operationSucceeded()) { | ||
/** @var LogBucket $result */ | ||
$result = $response->getResult(); | ||
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); | ||
} else { | ||
/** @var Status $error */ | ||
$error = $response->getError(); | ||
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); | ||
} | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedParent = ConfigServiceV2Client::organizationLocationName('[ORGANIZATION]', '[LOCATION]'); | ||
$bucketId = '[BUCKET_ID]'; | ||
|
||
create_bucket_async_sample($formattedParent, $bucketId); | ||
} | ||
// [END logging_v2_generated_ConfigServiceV2_CreateBucketAsync_sync] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [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\Link; | ||
use Google\Rpc\Status; | ||
|
||
/** | ||
* Asynchronously creates a linked dataset in BigQuery which makes it possible | ||
* to use BigQuery to read the logs stored in the log bucket. A log bucket may | ||
* currently only contain one link. | ||
* | ||
* @param string $formattedParent The full resource name of the bucket to create a link for. | ||
* | ||
* "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" | ||
* "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" | ||
* "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" | ||
* "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" | ||
* Please see {@see ConfigServiceV2Client::logBucketName()} for help formatting this field. | ||
* @param string $linkId The ID to use for the link. The link_id can have up to 100 | ||
* characters. A valid link_id must only have alphanumeric characters and | ||
* underscores within it. | ||
*/ | ||
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. | ||
$link = new Link(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var OperationResponse $response */ | ||
$response = $configServiceV2Client->createLink($formattedParent, $link, $linkId); | ||
$response->pollUntilComplete(); | ||
|
||
if ($response->operationSucceeded()) { | ||
/** @var Link $result */ | ||
$result = $response->getResult(); | ||
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); | ||
} else { | ||
/** @var Status $error */ | ||
$error = $response->getError(); | ||
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); | ||
} | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedParent = ConfigServiceV2Client::logBucketName('[PROJECT]', '[LOCATION]', '[BUCKET]'); | ||
$linkId = '[LINK_ID]'; | ||
|
||
create_link_sample($formattedParent, $linkId); | ||
} | ||
// [END logging_v2_generated_ConfigServiceV2_CreateLink_sync] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START logging_v2_generated_ConfigServiceV2_DeleteLink_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\OperationResponse; | ||
use Google\Cloud\Logging\V2\ConfigServiceV2Client; | ||
use Google\Rpc\Status; | ||
|
||
/** | ||
* Deletes a link. This will also delete the corresponding BigQuery linked | ||
* dataset. | ||
* | ||
* @param string $formattedName The full resource name of the link to delete. | ||
* | ||
* "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" | ||
* "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" | ||
* "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" | ||
* "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" | ||
* Please see {@see ConfigServiceV2Client::linkName()} for help formatting this field. | ||
*/ | ||
function delete_link_sample(string $formattedName): void | ||
{ | ||
// Create a client. | ||
$configServiceV2Client = new ConfigServiceV2Client(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var OperationResponse $response */ | ||
$response = $configServiceV2Client->deleteLink($formattedName); | ||
$response->pollUntilComplete(); | ||
|
||
if ($response->operationSucceeded()) { | ||
printf('Operation completed successfully.' . PHP_EOL); | ||
} else { | ||
/** @var Status $error */ | ||
$error = $response->getError(); | ||
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); | ||
} | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedName = ConfigServiceV2Client::linkName('[PROJECT]', '[LOCATION]', '[BUCKET]', '[LINK]'); | ||
|
||
delete_link_sample($formattedName); | ||
} | ||
// [END logging_v2_generated_ConfigServiceV2_DeleteLink_sync] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START logging_v2_generated_ConfigServiceV2_GetLink_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Logging\V2\ConfigServiceV2Client; | ||
use Google\Cloud\Logging\V2\Link; | ||
|
||
/** | ||
* Gets a link. | ||
* | ||
* @param string $formattedName The resource name of the link: | ||
* | ||
* "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" | ||
* "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" | ||
* "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" | ||
* "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID] | ||
* Please see {@see ConfigServiceV2Client::linkName()} for help formatting this field. | ||
*/ | ||
function get_link_sample(string $formattedName): void | ||
{ | ||
// Create a client. | ||
$configServiceV2Client = new ConfigServiceV2Client(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var Link $response */ | ||
$response = $configServiceV2Client->getLink($formattedName); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedName = ConfigServiceV2Client::linkName('[PROJECT]', '[LOCATION]', '[BUCKET]', '[LINK]'); | ||
|
||
get_link_sample($formattedName); | ||
} | ||
// [END logging_v2_generated_ConfigServiceV2_GetLink_sync] |
Oops, something went wrong.