Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions kms/api/Kms.Samples/DeleteKey.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2026 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.

// [START kms_delete_key]
using Google.Cloud.Kms.V1;
using Google.LongRunning;
using Google.Protobuf.WellKnownTypes;

public class DeleteKeySample
{
public Operation<Empty, DeleteCryptoKeyMetadata> DeleteKey(string projectId = "my-project", string locationId = "us-east1", string keyRingId = "my-key-ring", string keyId = "my-key")
{
// Create the client.
KeyManagementServiceClient client = KeyManagementServiceClient.Create();

// Build the key name.
CryptoKeyName keyName = new CryptoKeyName(projectId, locationId, keyRingId, keyId);

// Call the API.
Operation<Empty, DeleteCryptoKeyMetadata> result = client.DeleteCryptoKey(keyName);

// Return the result.
return result;
}
}
// [END kms_delete_key]
37 changes: 37 additions & 0 deletions kms/api/Kms.Samples/DeleteKeyVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2026 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.

// [START kms_delete_key_version]
using Google.Cloud.Kms.V1;
using Google.LongRunning;
using Google.Protobuf.WellKnownTypes;

public class DeleteKeyVersionSample
{
public Operation<Empty, DeleteCryptoKeyVersionMetadata> DeleteKeyVersion(string projectId = "my-project", string locationId = "us-east1", string keyRingId = "my-key-ring", string keyId = "my-key", string versionId = "123")
{
// Create the client.
KeyManagementServiceClient client = KeyManagementServiceClient.Create();

// Build the key version name.
CryptoKeyVersionName versionName = new CryptoKeyVersionName(projectId, locationId, keyRingId, keyId, versionId);

// Call the API.
Operation<Empty, DeleteCryptoKeyVersionMetadata> result = client.DeleteCryptoKeyVersion(versionName);

// Return the result.
return result;
}
}
// [END kms_delete_key_version]
37 changes: 37 additions & 0 deletions kms/api/Kms.Samples/GetRetiredResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2026 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.

// [START kms_get_retired_resource]
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Kms.V1;

public class GetRetiredResourceSample
{
public RetiredResource GetRetiredResource(
string projectId = "my-project", string locationId = "us-east1", string retiredResourceId = "my-retired-resource")
{
// Create the client.
KeyManagementServiceClient client = KeyManagementServiceClient.Create();

// Build the retired resource name.
RetiredResourceName name = new RetiredResourceName(projectId, locationId, retiredResourceId);

// Call the API.
RetiredResource result = client.GetRetiredResource(name);

// Return the result.
return result;
}
}
// [END kms_get_retired_resource]
2 changes: 1 addition & 1 deletion kms/api/Kms.Samples/Kms.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Cloud.Kms.V1" Version="3.21.0" />
<PackageReference Include="Google.Cloud.Kms.V1" Version="3.22.0" />
</ItemGroup>
</Project>
39 changes: 39 additions & 0 deletions kms/api/Kms.Samples/ListRetiredResources.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2026 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.

// [START kms_list_retired_resources]
using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Kms.V1;
using System.Collections.Generic;

public class ListRetiredResourcesSample
{
public IEnumerable<RetiredResource> ListRetiredResources(
string projectId = "my-project", string locationId = "us-east1")
{
// Create the client.
KeyManagementServiceClient client = KeyManagementServiceClient.Create();

// Build the location name.
LocationName locationName = new LocationName(projectId, locationId);

// Call the API.
PagedEnumerable<ListRetiredResourcesResponse, RetiredResource> response = client.ListRetiredResources(locationName);

// Return the result.
return response;
}
}
// [END kms_list_retired_resources]