Skip to content

Commit

Permalink
feat: Log Analytics features of the Cloud Logging API (#6189)
Browse files Browse the repository at this point in the history
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
gcf-owl-bot[bot] authored May 6, 2023
1 parent de72b94 commit be76df8
Show file tree
Hide file tree
Showing 64 changed files with 4,929 additions and 628 deletions.
Binary file modified Logging/metadata/V2/Logging.php
Binary file not shown.
Binary file modified Logging/metadata/V2/LoggingConfig.php
Binary file not shown.
Binary file modified Logging/metadata/V2/LoggingMetrics.php
Binary file not shown.
6 changes: 3 additions & 3 deletions Logging/samples/V2/ConfigServiceV2Client/create_bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
*
* `"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.
* @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_sample(string $formattedParent, string $bucketId): void
{
Expand Down
93 changes: 93 additions & 0 deletions Logging/samples/V2/ConfigServiceV2Client/create_bucket_async.php
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]
8 changes: 4 additions & 4 deletions Logging/samples/V2/ConfigServiceV2Client/create_exclusion.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
* `"projects/my-logging-project"`
* `"organizations/123456789"`
* Please see {@see ConfigServiceV2Client::projectName()} for help formatting this field.
* @param string $exclusionName A client-assigned identifier, such as `"load-balancer-exclusion"`.
* Identifiers are limited to 100 characters and can include only letters,
* digits, underscores, hyphens, and periods. First character has to be
* alphanumeric.
* @param string $exclusionName A client-assigned identifier, such as
* `"load-balancer-exclusion"`. Identifiers are limited to 100 characters and
* can include only letters, digits, underscores, hyphens, and periods. First
* character has to be alphanumeric.
* @param string $exclusionFilter An [advanced logs
* filter](https://cloud.google.com/logging/docs/view/advanced-queries) that
* matches the log entries to be excluded. By using the [sample
Expand Down
92 changes: 92 additions & 0 deletions Logging/samples/V2/ConfigServiceV2Client/create_link.php
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]
4 changes: 3 additions & 1 deletion Logging/samples/V2/ConfigServiceV2Client/create_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
* For example:
*
* `"projects/my-project/locations/global/buckets/my-bucket"`
* @param string $viewId The id to use for this view.
* @param string $viewId A client-assigned identifier such as `"my-view"`. Identifiers are
* limited to 100 characters and can include only letters, digits,
* underscores, hyphens, and periods.
*/
function create_view_sample(string $parent, string $viewId): void
{
Expand Down
81 changes: 81 additions & 0 deletions Logging/samples/V2/ConfigServiceV2Client/delete_link.php
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]
4 changes: 2 additions & 2 deletions Logging/samples/V2/ConfigServiceV2Client/delete_sink.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
* Deletes a sink. If the sink has a unique `writer_identity`, then that
* service account is also deleted.
*
* @param string $formattedSinkName The full resource name of the sink to delete, including the parent
* resource and the sink identifier:
* @param string $formattedSinkName The full resource name of the sink to delete, including the
* parent resource and the sink identifier:
*
* "projects/[PROJECT_ID]/sinks/[SINK_ID]"
* "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
Expand Down
71 changes: 71 additions & 0 deletions Logging/samples/V2/ConfigServiceV2Client/get_link.php
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]
Loading

0 comments on commit be76df8

Please sign in to comment.