Skip to content

Commit 0980b8f

Browse files
feat: [Kms] add the SingleTenantHsm functionality including the management API and resource types (#8871)
* feat: add the SingleTenantHsm functionality including the management API and resource types docs: A comment for field `crypto_key_backend` in message `.google.cloud.kms.v1.CryptoKey` is expanded to include SingleTenantHsmInstances docs: A comment for enum value `MODIFIED_CUSTOMER_INITIATED_ACCESS` in enum `AccessReason` is changed docs: A comment for enum value `MODIFIED_GOOGLE_INITIATED_SYSTEM_OPERATION` in enum `AccessReason` is changed PiperOrigin-RevId: 858582271 Source-Link: googleapis/googleapis@d9f058d Source-Link: googleapis/googleapis-gen@6399b00 Copy-Tag: eyJwIjoiS21zLy5Pd2xCb3QueWFtbCIsImgiOiI2Mzk5YjAwYThkMDhlYWUwZGU5ODJhZGY3NTNkYjYxZjFjMzg0N2UyIn0= * 🦉 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 278bfc7 commit 0980b8f

63 files changed

Lines changed: 9231 additions & 12 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.

Kms/metadata/V1/HsmManagement.php

10.4 KB
Binary file not shown.

Kms/metadata/V1/Resources.php

63 Bytes
Binary file not shown.

Kms/metadata/V1/Service.php

37 Bytes
Binary file not shown.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
/*
3+
* Copyright 2026 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 cloudkms_v1_generated_HsmManagement_ApproveSingleTenantHsmInstanceProposal_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Cloud\Kms\V1\ApproveSingleTenantHsmInstanceProposalRequest;
28+
use Google\Cloud\Kms\V1\ApproveSingleTenantHsmInstanceProposalRequest\QuorumReply;
29+
use Google\Cloud\Kms\V1\ApproveSingleTenantHsmInstanceProposalResponse;
30+
use Google\Cloud\Kms\V1\ChallengeReply;
31+
use Google\Cloud\Kms\V1\Client\HsmManagementClient;
32+
33+
/**
34+
* Approves a
35+
* [SingleTenantHsmInstanceProposal][google.cloud.kms.v1.SingleTenantHsmInstanceProposal]
36+
* for a given
37+
* [SingleTenantHsmInstance][google.cloud.kms.v1.SingleTenantHsmInstance]. The
38+
* proposal must be in the
39+
* [PENDING][google.cloud.kms.v1.SingleTenantHsmInstanceProposal.State.PENDING]
40+
* state.
41+
*
42+
* @param string $formattedName The
43+
* [name][google.cloud.kms.v1.SingleTenantHsmInstanceProposal.name] of the
44+
* [SingleTenantHsmInstanceProposal][google.cloud.kms.v1.SingleTenantHsmInstanceProposal]
45+
* to approve. Please see
46+
* {@see HsmManagementClient::singleTenantHsmInstanceProposalName()} for help formatting this field.
47+
* @param string $quorumReplyChallengeRepliesSignedChallenge The signed challenge associated with the 2FA key.
48+
* The signature must be RSASSA-PKCS1 v1.5 with a SHA256 digest.
49+
* @param string $quorumReplyChallengeRepliesPublicKeyPem The public key associated with the 2FA key.
50+
*/
51+
function approve_single_tenant_hsm_instance_proposal_sample(
52+
string $formattedName,
53+
string $quorumReplyChallengeRepliesSignedChallenge,
54+
string $quorumReplyChallengeRepliesPublicKeyPem
55+
): void {
56+
// Create a client.
57+
$hsmManagementClient = new HsmManagementClient();
58+
59+
// Prepare the request message.
60+
$challengeReply = (new ChallengeReply())
61+
->setSignedChallenge($quorumReplyChallengeRepliesSignedChallenge)
62+
->setPublicKeyPem($quorumReplyChallengeRepliesPublicKeyPem);
63+
$quorumReplyChallengeReplies = [$challengeReply,];
64+
$quorumReply = (new QuorumReply())
65+
->setChallengeReplies($quorumReplyChallengeReplies);
66+
$request = (new ApproveSingleTenantHsmInstanceProposalRequest())
67+
->setName($formattedName)
68+
->setQuorumReply($quorumReply);
69+
70+
// Call the API and handle any network failures.
71+
try {
72+
/** @var ApproveSingleTenantHsmInstanceProposalResponse $response */
73+
$response = $hsmManagementClient->approveSingleTenantHsmInstanceProposal($request);
74+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
75+
} catch (ApiException $ex) {
76+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
77+
}
78+
}
79+
80+
/**
81+
* Helper to execute the sample.
82+
*
83+
* This sample has been automatically generated and should be regarded as a code
84+
* template only. It will require modifications to work:
85+
* - It may require correct/in-range values for request initialization.
86+
* - It may require specifying regional endpoints when creating the service client,
87+
* please see the apiEndpoint client configuration option for more details.
88+
*/
89+
function callSample(): void
90+
{
91+
$formattedName = HsmManagementClient::singleTenantHsmInstanceProposalName(
92+
'[PROJECT]',
93+
'[LOCATION]',
94+
'[SINGLE_TENANT_HSM_INSTANCE]',
95+
'[PROPOSAL]'
96+
);
97+
$quorumReplyChallengeRepliesSignedChallenge = '...';
98+
$quorumReplyChallengeRepliesPublicKeyPem = '[PUBLIC_KEY_PEM]';
99+
100+
approve_single_tenant_hsm_instance_proposal_sample(
101+
$formattedName,
102+
$quorumReplyChallengeRepliesSignedChallenge,
103+
$quorumReplyChallengeRepliesPublicKeyPem
104+
);
105+
}
106+
// [END cloudkms_v1_generated_HsmManagement_ApproveSingleTenantHsmInstanceProposal_sync]
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
/*
3+
* Copyright 2026 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 cloudkms_v1_generated_HsmManagement_CreateSingleTenantHsmInstance_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\Kms\V1\Client\HsmManagementClient;
29+
use Google\Cloud\Kms\V1\CreateSingleTenantHsmInstanceRequest;
30+
use Google\Cloud\Kms\V1\SingleTenantHsmInstance;
31+
use Google\Cloud\Kms\V1\SingleTenantHsmInstance\QuorumAuth;
32+
use Google\Rpc\Status;
33+
34+
/**
35+
* Creates a new
36+
* [SingleTenantHsmInstance][google.cloud.kms.v1.SingleTenantHsmInstance] in a
37+
* given Project and Location. User must create a RegisterTwoFactorAuthKeys
38+
* proposal with this single-tenant HSM instance to finish setup of the
39+
* instance.
40+
*
41+
* @param string $formattedParent The resource name of the location associated with the
42+
* [SingleTenantHsmInstance][google.cloud.kms.v1.SingleTenantHsmInstance], in
43+
* the format `projects/&#42;/locations/*`. Please see
44+
* {@see HsmManagementClient::locationName()} for help formatting this field.
45+
* @param int $singleTenantHsmInstanceQuorumAuthTotalApproverCount The total number of approvers. This is the N value used
46+
* for M of N quorum auth. Must be greater than or equal to 3 and less than
47+
* or equal to 16.
48+
*/
49+
function create_single_tenant_hsm_instance_sample(
50+
string $formattedParent,
51+
int $singleTenantHsmInstanceQuorumAuthTotalApproverCount
52+
): void {
53+
// Create a client.
54+
$hsmManagementClient = new HsmManagementClient();
55+
56+
// Prepare the request message.
57+
$singleTenantHsmInstanceQuorumAuth = (new QuorumAuth())
58+
->setTotalApproverCount($singleTenantHsmInstanceQuorumAuthTotalApproverCount);
59+
$singleTenantHsmInstance = (new SingleTenantHsmInstance())
60+
->setQuorumAuth($singleTenantHsmInstanceQuorumAuth);
61+
$request = (new CreateSingleTenantHsmInstanceRequest())
62+
->setParent($formattedParent)
63+
->setSingleTenantHsmInstance($singleTenantHsmInstance);
64+
65+
// Call the API and handle any network failures.
66+
try {
67+
/** @var OperationResponse $response */
68+
$response = $hsmManagementClient->createSingleTenantHsmInstance($request);
69+
$response->pollUntilComplete();
70+
71+
if ($response->operationSucceeded()) {
72+
/** @var SingleTenantHsmInstance $result */
73+
$result = $response->getResult();
74+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
75+
} else {
76+
/** @var Status $error */
77+
$error = $response->getError();
78+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
79+
}
80+
} catch (ApiException $ex) {
81+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
82+
}
83+
}
84+
85+
/**
86+
* Helper to execute the sample.
87+
*
88+
* This sample has been automatically generated and should be regarded as a code
89+
* template only. It will require modifications to work:
90+
* - It may require correct/in-range values for request initialization.
91+
* - It may require specifying regional endpoints when creating the service client,
92+
* please see the apiEndpoint client configuration option for more details.
93+
*/
94+
function callSample(): void
95+
{
96+
$formattedParent = HsmManagementClient::locationName('[PROJECT]', '[LOCATION]');
97+
$singleTenantHsmInstanceQuorumAuthTotalApproverCount = 0;
98+
99+
create_single_tenant_hsm_instance_sample(
100+
$formattedParent,
101+
$singleTenantHsmInstanceQuorumAuthTotalApproverCount
102+
);
103+
}
104+
// [END cloudkms_v1_generated_HsmManagement_CreateSingleTenantHsmInstance_sync]
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
/*
3+
* Copyright 2026 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 cloudkms_v1_generated_HsmManagement_CreateSingleTenantHsmInstanceProposal_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\Kms\V1\Client\HsmManagementClient;
29+
use Google\Cloud\Kms\V1\CreateSingleTenantHsmInstanceProposalRequest;
30+
use Google\Cloud\Kms\V1\SingleTenantHsmInstanceProposal;
31+
use Google\Rpc\Status;
32+
33+
/**
34+
* Creates a new
35+
* [SingleTenantHsmInstanceProposal][google.cloud.kms.v1.SingleTenantHsmInstanceProposal]
36+
* for a given
37+
* [SingleTenantHsmInstance][google.cloud.kms.v1.SingleTenantHsmInstance].
38+
*
39+
* @param string $formattedParent The [name][google.cloud.kms.v1.SingleTenantHsmInstance.name] of
40+
* the [SingleTenantHsmInstance][google.cloud.kms.v1.SingleTenantHsmInstance]
41+
* associated with the
42+
* [SingleTenantHsmInstanceProposals][google.cloud.kms.v1.SingleTenantHsmInstanceProposal]. Please see
43+
* {@see HsmManagementClient::singleTenantHsmInstanceName()} for help formatting this field.
44+
*/
45+
function create_single_tenant_hsm_instance_proposal_sample(string $formattedParent): void
46+
{
47+
// Create a client.
48+
$hsmManagementClient = new HsmManagementClient();
49+
50+
// Prepare the request message.
51+
$singleTenantHsmInstanceProposal = new SingleTenantHsmInstanceProposal();
52+
$request = (new CreateSingleTenantHsmInstanceProposalRequest())
53+
->setParent($formattedParent)
54+
->setSingleTenantHsmInstanceProposal($singleTenantHsmInstanceProposal);
55+
56+
// Call the API and handle any network failures.
57+
try {
58+
/** @var OperationResponse $response */
59+
$response = $hsmManagementClient->createSingleTenantHsmInstanceProposal($request);
60+
$response->pollUntilComplete();
61+
62+
if ($response->operationSucceeded()) {
63+
/** @var SingleTenantHsmInstanceProposal $result */
64+
$result = $response->getResult();
65+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
66+
} else {
67+
/** @var Status $error */
68+
$error = $response->getError();
69+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
70+
}
71+
} catch (ApiException $ex) {
72+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
73+
}
74+
}
75+
76+
/**
77+
* Helper to execute the sample.
78+
*
79+
* This sample has been automatically generated and should be regarded as a code
80+
* template only. It will require modifications to work:
81+
* - It may require correct/in-range values for request initialization.
82+
* - It may require specifying regional endpoints when creating the service client,
83+
* please see the apiEndpoint client configuration option for more details.
84+
*/
85+
function callSample(): void
86+
{
87+
$formattedParent = HsmManagementClient::singleTenantHsmInstanceName(
88+
'[PROJECT]',
89+
'[LOCATION]',
90+
'[SINGLE_TENANT_HSM_INSTANCE]'
91+
);
92+
93+
create_single_tenant_hsm_instance_proposal_sample($formattedParent);
94+
}
95+
// [END cloudkms_v1_generated_HsmManagement_CreateSingleTenantHsmInstanceProposal_sync]
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
/*
3+
* Copyright 2026 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 cloudkms_v1_generated_HsmManagement_DeleteSingleTenantHsmInstanceProposal_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Cloud\Kms\V1\Client\HsmManagementClient;
28+
use Google\Cloud\Kms\V1\DeleteSingleTenantHsmInstanceProposalRequest;
29+
30+
/**
31+
* Deletes a
32+
* [SingleTenantHsmInstanceProposal][google.cloud.kms.v1.SingleTenantHsmInstanceProposal].
33+
*
34+
* @param string $formattedName The
35+
* [name][google.cloud.kms.v1.SingleTenantHsmInstanceProposal.name] of the
36+
* [SingleTenantHsmInstanceProposal][google.cloud.kms.v1.SingleTenantHsmInstanceProposal]
37+
* to delete. Please see
38+
* {@see HsmManagementClient::singleTenantHsmInstanceProposalName()} for help formatting this field.
39+
*/
40+
function delete_single_tenant_hsm_instance_proposal_sample(string $formattedName): void
41+
{
42+
// Create a client.
43+
$hsmManagementClient = new HsmManagementClient();
44+
45+
// Prepare the request message.
46+
$request = (new DeleteSingleTenantHsmInstanceProposalRequest())
47+
->setName($formattedName);
48+
49+
// Call the API and handle any network failures.
50+
try {
51+
$hsmManagementClient->deleteSingleTenantHsmInstanceProposal($request);
52+
printf('Call completed successfully.' . PHP_EOL);
53+
} catch (ApiException $ex) {
54+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
55+
}
56+
}
57+
58+
/**
59+
* Helper to execute the sample.
60+
*
61+
* This sample has been automatically generated and should be regarded as a code
62+
* template only. It will require modifications to work:
63+
* - It may require correct/in-range values for request initialization.
64+
* - It may require specifying regional endpoints when creating the service client,
65+
* please see the apiEndpoint client configuration option for more details.
66+
*/
67+
function callSample(): void
68+
{
69+
$formattedName = HsmManagementClient::singleTenantHsmInstanceProposalName(
70+
'[PROJECT]',
71+
'[LOCATION]',
72+
'[SINGLE_TENANT_HSM_INSTANCE]',
73+
'[PROPOSAL]'
74+
);
75+
76+
delete_single_tenant_hsm_instance_proposal_sample($formattedName);
77+
}
78+
// [END cloudkms_v1_generated_HsmManagement_DeleteSingleTenantHsmInstanceProposal_sync]

0 commit comments

Comments
 (0)