Skip to content

Commit 149fa25

Browse files
feat: add the beta component for Model Armor (#8404)
1 parent 36ca6d0 commit 149fa25

76 files changed

Lines changed: 10654 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ModelArmor/.OwlBot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
deep-copy-regex:
2-
- source: /google/cloud/modelarmor/(v1)/.*-php/(.*)
2+
- source: /google/cloud/modelarmor/(v1beta|v1)/.*-php/(.*)
33
dest: /owl-bot-staging/ModelArmor/$1/$2
44
api-name: ModelArmor
14.9 KB
Binary file not shown.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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 modelarmor_v1beta_generated_ModelArmor_CreateTemplate_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Cloud\ModelArmor\V1beta\Client\ModelArmorClient;
28+
use Google\Cloud\ModelArmor\V1beta\CreateTemplateRequest;
29+
use Google\Cloud\ModelArmor\V1beta\FilterConfig;
30+
use Google\Cloud\ModelArmor\V1beta\Template;
31+
32+
/**
33+
* Creates a new Template in a given project and location.
34+
*
35+
* @param string $formattedParent Value for parent. Please see
36+
* {@see ModelArmorClient::locationName()} for help formatting this field.
37+
* @param string $templateId Id of the requesting object
38+
* If auto-generating Id server-side, remove this field and
39+
* template_id from the method_signature of Create RPC
40+
*/
41+
function create_template_sample(string $formattedParent, string $templateId): void
42+
{
43+
// Create a client.
44+
$modelArmorClient = new ModelArmorClient();
45+
46+
// Prepare the request message.
47+
$templateFilterConfig = new FilterConfig();
48+
$template = (new Template())
49+
->setFilterConfig($templateFilterConfig);
50+
$request = (new CreateTemplateRequest())
51+
->setParent($formattedParent)
52+
->setTemplateId($templateId)
53+
->setTemplate($template);
54+
55+
// Call the API and handle any network failures.
56+
try {
57+
/** @var Template $response */
58+
$response = $modelArmorClient->createTemplate($request);
59+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
60+
} catch (ApiException $ex) {
61+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
62+
}
63+
}
64+
65+
/**
66+
* Helper to execute the sample.
67+
*
68+
* This sample has been automatically generated and should be regarded as a code
69+
* template only. It will require modifications to work:
70+
* - It may require correct/in-range values for request initialization.
71+
* - It may require specifying regional endpoints when creating the service client,
72+
* please see the apiEndpoint client configuration option for more details.
73+
*/
74+
function callSample(): void
75+
{
76+
$formattedParent = ModelArmorClient::locationName('[PROJECT]', '[LOCATION]');
77+
$templateId = '[TEMPLATE_ID]';
78+
79+
create_template_sample($formattedParent, $templateId);
80+
}
81+
// [END modelarmor_v1beta_generated_ModelArmor_CreateTemplate_sync]
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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 modelarmor_v1beta_generated_ModelArmor_DeleteTemplate_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Cloud\ModelArmor\V1beta\Client\ModelArmorClient;
28+
use Google\Cloud\ModelArmor\V1beta\DeleteTemplateRequest;
29+
30+
/**
31+
* Deletes a single Template.
32+
*
33+
* @param string $formattedName Name of the resource
34+
* Please see {@see ModelArmorClient::templateName()} for help formatting this field.
35+
*/
36+
function delete_template_sample(string $formattedName): void
37+
{
38+
// Create a client.
39+
$modelArmorClient = new ModelArmorClient();
40+
41+
// Prepare the request message.
42+
$request = (new DeleteTemplateRequest())
43+
->setName($formattedName);
44+
45+
// Call the API and handle any network failures.
46+
try {
47+
$modelArmorClient->deleteTemplate($request);
48+
printf('Call completed successfully.' . PHP_EOL);
49+
} catch (ApiException $ex) {
50+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
51+
}
52+
}
53+
54+
/**
55+
* Helper to execute the sample.
56+
*
57+
* This sample has been automatically generated and should be regarded as a code
58+
* template only. It will require modifications to work:
59+
* - It may require correct/in-range values for request initialization.
60+
* - It may require specifying regional endpoints when creating the service client,
61+
* please see the apiEndpoint client configuration option for more details.
62+
*/
63+
function callSample(): void
64+
{
65+
$formattedName = ModelArmorClient::templateName('[PROJECT]', '[LOCATION]', '[TEMPLATE]');
66+
67+
delete_template_sample($formattedName);
68+
}
69+
// [END modelarmor_v1beta_generated_ModelArmor_DeleteTemplate_sync]
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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 modelarmor_v1beta_generated_ModelArmor_GetFloorSetting_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Cloud\ModelArmor\V1beta\Client\ModelArmorClient;
28+
use Google\Cloud\ModelArmor\V1beta\FloorSetting;
29+
use Google\Cloud\ModelArmor\V1beta\GetFloorSettingRequest;
30+
31+
/**
32+
* Gets details of a single floor setting of a project
33+
*
34+
* @param string $formattedName The name of the floor setting to get, example
35+
* projects/123/floorsetting. Please see
36+
* {@see ModelArmorClient::floorSettingName()} for help formatting this field.
37+
*/
38+
function get_floor_setting_sample(string $formattedName): void
39+
{
40+
// Create a client.
41+
$modelArmorClient = new ModelArmorClient();
42+
43+
// Prepare the request message.
44+
$request = (new GetFloorSettingRequest())
45+
->setName($formattedName);
46+
47+
// Call the API and handle any network failures.
48+
try {
49+
/** @var FloorSetting $response */
50+
$response = $modelArmorClient->getFloorSetting($request);
51+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
52+
} catch (ApiException $ex) {
53+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
54+
}
55+
}
56+
57+
/**
58+
* Helper to execute the sample.
59+
*
60+
* This sample has been automatically generated and should be regarded as a code
61+
* template only. It will require modifications to work:
62+
* - It may require correct/in-range values for request initialization.
63+
* - It may require specifying regional endpoints when creating the service client,
64+
* please see the apiEndpoint client configuration option for more details.
65+
*/
66+
function callSample(): void
67+
{
68+
$formattedName = ModelArmorClient::floorSettingName('[PROJECT]', '[LOCATION]');
69+
70+
get_floor_setting_sample($formattedName);
71+
}
72+
// [END modelarmor_v1beta_generated_ModelArmor_GetFloorSetting_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 modelarmor_v1beta_generated_ModelArmor_GetLocation_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Cloud\Location\GetLocationRequest;
28+
use Google\Cloud\Location\Location;
29+
use Google\Cloud\ModelArmor\V1beta\Client\ModelArmorClient;
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+
$modelArmorClient = new ModelArmorClient();
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 = $modelArmorClient->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 modelarmor_v1beta_generated_ModelArmor_GetLocation_sync]
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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 modelarmor_v1beta_generated_ModelArmor_GetTemplate_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Cloud\ModelArmor\V1beta\Client\ModelArmorClient;
28+
use Google\Cloud\ModelArmor\V1beta\GetTemplateRequest;
29+
use Google\Cloud\ModelArmor\V1beta\Template;
30+
31+
/**
32+
* Gets details of a single Template.
33+
*
34+
* @param string $formattedName Name of the resource
35+
* Please see {@see ModelArmorClient::templateName()} for help formatting this field.
36+
*/
37+
function get_template_sample(string $formattedName): void
38+
{
39+
// Create a client.
40+
$modelArmorClient = new ModelArmorClient();
41+
42+
// Prepare the request message.
43+
$request = (new GetTemplateRequest())
44+
->setName($formattedName);
45+
46+
// Call the API and handle any network failures.
47+
try {
48+
/** @var Template $response */
49+
$response = $modelArmorClient->getTemplate($request);
50+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
51+
} catch (ApiException $ex) {
52+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
53+
}
54+
}
55+
56+
/**
57+
* Helper to execute the sample.
58+
*
59+
* This sample has been automatically generated and should be regarded as a code
60+
* template only. It will require modifications to work:
61+
* - It may require correct/in-range values for request initialization.
62+
* - It may require specifying regional endpoints when creating the service client,
63+
* please see the apiEndpoint client configuration option for more details.
64+
*/
65+
function callSample(): void
66+
{
67+
$formattedName = ModelArmorClient::templateName('[PROJECT]', '[LOCATION]', '[TEMPLATE]');
68+
69+
get_template_sample($formattedName);
70+
}
71+
// [END modelarmor_v1beta_generated_ModelArmor_GetTemplate_sync]

0 commit comments

Comments
 (0)