Skip to content

Commit 11e4068

Browse files
feat: [SecurityCompliance] add Audit API surface (#8697)
* feat: add Audit API surface docs: Changes to few fields are also made PiperOrigin-RevId: 824893251 Source-Link: googleapis/googleapis@0654a03 Source-Link: googleapis/googleapis-gen@2a18f43 Copy-Tag: eyJwIjoiU2VjdXJpdHlDb21wbGlhbmNlLy5Pd2xCb3QueWFtbCIsImgiOiIyYTE4ZjQzNGRmYmMyYzEwOWUyY2YwNTI1M2Y3Mjg4ZDBkMjdlZWVkIn0= * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent b56fe9b commit 11e4068

129 files changed

Lines changed: 9152 additions & 1301 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
8.18 KB
Binary file not shown.
3.23 KB
Binary file not shown.
248 Bytes
Binary file not shown.

SecurityCompliance/metadata/V1/Config.php

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START cloudsecuritycompliance_v1_generated_Audit_CreateFrameworkAudit_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\CloudSecurityCompliance\V1\Client\AuditClient;
29+
use Google\Cloud\CloudSecurityCompliance\V1\CreateFrameworkAuditRequest;
30+
use Google\Cloud\CloudSecurityCompliance\V1\FrameworkAudit;
31+
use Google\Cloud\CloudSecurityCompliance\V1\FrameworkAuditDestination;
32+
use Google\Rpc\Status;
33+
34+
/**
35+
* Creates an audit scope report for a framework.
36+
*
37+
* @param string $formattedParent The parent resource where this framework audit is created.
38+
*
39+
* Supported formats are the following:
40+
*
41+
* * `organizations/{organization_id}/locations/{location}`
42+
* * `folders/{folder_id}/locations/{location}`
43+
* * `projects/{project_id}/locations/{location}`
44+
* Please see {@see AuditClient::organizationLocationName()} for help formatting this field.
45+
*/
46+
function create_framework_audit_sample(string $formattedParent): void
47+
{
48+
// Create a client.
49+
$auditClient = new AuditClient();
50+
51+
// Prepare the request message.
52+
$frameworkAuditFrameworkAuditDestination = new FrameworkAuditDestination();
53+
$frameworkAudit = (new FrameworkAudit())
54+
->setFrameworkAuditDestination($frameworkAuditFrameworkAuditDestination);
55+
$request = (new CreateFrameworkAuditRequest())
56+
->setParent($formattedParent)
57+
->setFrameworkAudit($frameworkAudit);
58+
59+
// Call the API and handle any network failures.
60+
try {
61+
/** @var OperationResponse $response */
62+
$response = $auditClient->createFrameworkAudit($request);
63+
$response->pollUntilComplete();
64+
65+
if ($response->operationSucceeded()) {
66+
/** @var FrameworkAudit $result */
67+
$result = $response->getResult();
68+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
69+
} else {
70+
/** @var Status $error */
71+
$error = $response->getError();
72+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
73+
}
74+
} catch (ApiException $ex) {
75+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
76+
}
77+
}
78+
79+
/**
80+
* Helper to execute the sample.
81+
*
82+
* This sample has been automatically generated and should be regarded as a code
83+
* template only. It will require modifications to work:
84+
* - It may require correct/in-range values for request initialization.
85+
* - It may require specifying regional endpoints when creating the service client,
86+
* please see the apiEndpoint client configuration option for more details.
87+
*/
88+
function callSample(): void
89+
{
90+
$formattedParent = AuditClient::organizationLocationName('[ORGANIZATION]', '[LOCATION]');
91+
92+
create_framework_audit_sample($formattedParent);
93+
}
94+
// [END cloudsecuritycompliance_v1_generated_Audit_CreateFrameworkAudit_sync]
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START cloudsecuritycompliance_v1_generated_Audit_GenerateFrameworkAuditScopeReport_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Cloud\CloudSecurityCompliance\V1\Client\AuditClient;
28+
use Google\Cloud\CloudSecurityCompliance\V1\GenerateFrameworkAuditScopeReportRequest;
29+
use Google\Cloud\CloudSecurityCompliance\V1\GenerateFrameworkAuditScopeReportRequest\Format;
30+
use Google\Cloud\CloudSecurityCompliance\V1\GenerateFrameworkAuditScopeReportResponse;
31+
32+
/**
33+
* Generates an audit scope report for a framework.
34+
*
35+
* @param string $scope The organization, folder or project for the audit report.
36+
*
37+
* Supported formats are the following:
38+
*
39+
* * `projects/{project_id}/locations/{location}`
40+
* * `folders/{folder_id}/locations/{location}`
41+
* * `organizations/{organization_id}/locations/{location}`
42+
* @param int $reportFormat The format that the scope report bytes is returned in.
43+
* @param string $complianceFramework The compliance framework that the scope report is generated for.
44+
*/
45+
function generate_framework_audit_scope_report_sample(
46+
string $scope,
47+
int $reportFormat,
48+
string $complianceFramework
49+
): void {
50+
// Create a client.
51+
$auditClient = new AuditClient();
52+
53+
// Prepare the request message.
54+
$request = (new GenerateFrameworkAuditScopeReportRequest())
55+
->setScope($scope)
56+
->setReportFormat($reportFormat)
57+
->setComplianceFramework($complianceFramework);
58+
59+
// Call the API and handle any network failures.
60+
try {
61+
/** @var GenerateFrameworkAuditScopeReportResponse $response */
62+
$response = $auditClient->generateFrameworkAuditScopeReport($request);
63+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
64+
} catch (ApiException $ex) {
65+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
66+
}
67+
}
68+
69+
/**
70+
* Helper to execute the sample.
71+
*
72+
* This sample has been automatically generated and should be regarded as a code
73+
* template only. It will require modifications to work:
74+
* - It may require correct/in-range values for request initialization.
75+
* - It may require specifying regional endpoints when creating the service client,
76+
* please see the apiEndpoint client configuration option for more details.
77+
*/
78+
function callSample(): void
79+
{
80+
$scope = '[SCOPE]';
81+
$reportFormat = Format::FORMAT_UNSPECIFIED;
82+
$complianceFramework = '[COMPLIANCE_FRAMEWORK]';
83+
84+
generate_framework_audit_scope_report_sample($scope, $reportFormat, $complianceFramework);
85+
}
86+
// [END cloudsecuritycompliance_v1_generated_Audit_GenerateFrameworkAuditScopeReport_sync]
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START cloudsecuritycompliance_v1_generated_Audit_GetFrameworkAudit_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Cloud\CloudSecurityCompliance\V1\Client\AuditClient;
28+
use Google\Cloud\CloudSecurityCompliance\V1\FrameworkAudit;
29+
use Google\Cloud\CloudSecurityCompliance\V1\GetFrameworkAuditRequest;
30+
31+
/**
32+
* Gets the details for a framework audit.
33+
*
34+
* @param string $formattedName The name of the framework audit to retrieve.
35+
*
36+
* Supported formats are the following:
37+
*
38+
* * `organizations/{organization_id}/locations/{location}/frameworkAudits/{frameworkAuditName}`
39+
* * `folders/{folder_id}/locations/{location}/frameworkAudits/{frameworkAuditName}`
40+
* * `projects/{project_id}/locations/{location}/frameworkAudits/{frameworkAuditName}`
41+
* Please see {@see AuditClient::frameworkAuditName()} for help formatting this field.
42+
*/
43+
function get_framework_audit_sample(string $formattedName): void
44+
{
45+
// Create a client.
46+
$auditClient = new AuditClient();
47+
48+
// Prepare the request message.
49+
$request = (new GetFrameworkAuditRequest())
50+
->setName($formattedName);
51+
52+
// Call the API and handle any network failures.
53+
try {
54+
/** @var FrameworkAudit $response */
55+
$response = $auditClient->getFrameworkAudit($request);
56+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
57+
} catch (ApiException $ex) {
58+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
59+
}
60+
}
61+
62+
/**
63+
* Helper to execute the sample.
64+
*
65+
* This sample has been automatically generated and should be regarded as a code
66+
* template only. It will require modifications to work:
67+
* - It may require correct/in-range values for request initialization.
68+
* - It may require specifying regional endpoints when creating the service client,
69+
* please see the apiEndpoint client configuration option for more details.
70+
*/
71+
function callSample(): void
72+
{
73+
$formattedName = AuditClient::frameworkAuditName('[PROJECT]', '[LOCATION]', '[FRAMEWORK_AUDIT]');
74+
75+
get_framework_audit_sample($formattedName);
76+
}
77+
// [END cloudsecuritycompliance_v1_generated_Audit_GetFrameworkAudit_sync]
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START cloudsecuritycompliance_v1_generated_Audit_GetLocation_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Cloud\CloudSecurityCompliance\V1\Client\AuditClient;
28+
use Google\Cloud\Location\GetLocationRequest;
29+
use Google\Cloud\Location\Location;
30+
31+
/**
32+
* Gets information about a location.
33+
*
34+
* This sample has been automatically generated and should be regarded as a code
35+
* template only. It will require modifications to work:
36+
* - It may require correct/in-range values for request initialization.
37+
* - It may require specifying regional endpoints when creating the service client,
38+
* please see the apiEndpoint client configuration option for more details.
39+
*/
40+
function get_location_sample(): void
41+
{
42+
// Create a client.
43+
$auditClient = new AuditClient();
44+
45+
// Prepare the request message.
46+
$request = new GetLocationRequest();
47+
48+
// Call the API and handle any network failures.
49+
try {
50+
/** @var Location $response */
51+
$response = $auditClient->getLocation($request);
52+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
53+
} catch (ApiException $ex) {
54+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
55+
}
56+
}
57+
// [END cloudsecuritycompliance_v1_generated_Audit_GetLocation_sync]

0 commit comments

Comments
 (0)