diff --git a/kms/api/Kms.Samples/DeleteKey.cs b/kms/api/Kms.Samples/DeleteKey.cs new file mode 100644 index 00000000000..c45b325f7d8 --- /dev/null +++ b/kms/api/Kms.Samples/DeleteKey.cs @@ -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 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 result = client.DeleteCryptoKey(keyName); + + // Return the result. + return result; + } +} +// [END kms_delete_key] diff --git a/kms/api/Kms.Samples/DeleteKeyVersion.cs b/kms/api/Kms.Samples/DeleteKeyVersion.cs new file mode 100644 index 00000000000..77ce67936bc --- /dev/null +++ b/kms/api/Kms.Samples/DeleteKeyVersion.cs @@ -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 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 result = client.DeleteCryptoKeyVersion(versionName); + + // Return the result. + return result; + } +} +// [END kms_delete_key_version] diff --git a/kms/api/Kms.Samples/GetRetiredResource.cs b/kms/api/Kms.Samples/GetRetiredResource.cs new file mode 100644 index 00000000000..fe6ed087366 --- /dev/null +++ b/kms/api/Kms.Samples/GetRetiredResource.cs @@ -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] diff --git a/kms/api/Kms.Samples/Kms.Samples.csproj b/kms/api/Kms.Samples/Kms.Samples.csproj index 931baf4606d..76af1c86f4e 100644 --- a/kms/api/Kms.Samples/Kms.Samples.csproj +++ b/kms/api/Kms.Samples/Kms.Samples.csproj @@ -5,6 +5,6 @@ - + diff --git a/kms/api/Kms.Samples/ListRetiredResources.cs b/kms/api/Kms.Samples/ListRetiredResources.cs new file mode 100644 index 00000000000..a7b852fb706 --- /dev/null +++ b/kms/api/Kms.Samples/ListRetiredResources.cs @@ -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 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 response = client.ListRetiredResources(locationName); + + // Return the result. + return response; + } +} +// [END kms_list_retired_resources]