From 9f639c65a9b6917d221057357d926c5c1f251fbf Mon Sep 17 00:00:00 2001 From: Orlando Emiliano Garcia Diaz Date: Fri, 6 Dec 2024 18:53:30 +0000 Subject: [PATCH] chore(acl): delete sample storage_print_bucket_acl_for_user --- .../PrintBucketAclForUserTest.cs | 46 ------------------- .../Storage.Samples/PrintBucketAclForUser.cs | 41 ----------------- 2 files changed, 87 deletions(-) delete mode 100644 storage/api/Storage.Samples.Tests/PrintBucketAclForUserTest.cs delete mode 100644 storage/api/Storage.Samples/PrintBucketAclForUser.cs diff --git a/storage/api/Storage.Samples.Tests/PrintBucketAclForUserTest.cs b/storage/api/Storage.Samples.Tests/PrintBucketAclForUserTest.cs deleted file mode 100644 index 02d3eab26d6..00000000000 --- a/storage/api/Storage.Samples.Tests/PrintBucketAclForUserTest.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2020 Google Inc. -// -// 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 -// -// http://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. - -using Xunit; - -[Collection(nameof(StorageFixture))] -public class PrintBucketAclForUserTest -{ - private readonly StorageFixture _fixture; - - public PrintBucketAclForUserTest(StorageFixture fixture) - { - _fixture = fixture; - } - - [Fact] - public void TestPrintBucketAclForUser() - { - PrintBucketAclForUserSample printBucketAclForUserSample = new PrintBucketAclForUserSample(); - AddBucketOwnerSample addBucketOwnerSample = new AddBucketOwnerSample(); - RemoveBucketOwnerSample removeBucketOwnerSample = new RemoveBucketOwnerSample(); - string userEmail = _fixture.ServiceAccountEmail; - - // Add bucket owner - addBucketOwnerSample.AddBucketOwner(_fixture.BucketNameGeneric, userEmail); - _fixture.SleepAfterBucketCreateUpdateDelete(); - - var bucketAclForUser = printBucketAclForUserSample.PrintBucketAclForUser(_fixture.BucketNameGeneric, userEmail); - Assert.All(bucketAclForUser, c => Assert.Equal(c.Email, userEmail)); - - // Remove bucket owner - removeBucketOwnerSample.RemoveBucketOwner(_fixture.BucketNameGeneric, userEmail); - _fixture.SleepAfterBucketCreateUpdateDelete(); - } -} diff --git a/storage/api/Storage.Samples/PrintBucketAclForUser.cs b/storage/api/Storage.Samples/PrintBucketAclForUser.cs deleted file mode 100644 index 032c48aa79c..00000000000 --- a/storage/api/Storage.Samples/PrintBucketAclForUser.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2020 Google Inc. -// -// 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 -// -// http://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 storage_print_bucket_acl_for_user] - -using Google.Apis.Storage.v1.Data; -using Google.Cloud.Storage.V1; -using System; -using System.Collections.Generic; -using System.Linq; - -public class PrintBucketAclForUserSample -{ - public IEnumerable PrintBucketAclForUser( - string bucketName = "your-unique-bucket-name", - string userEmail = "dev@iam.gserviceaccount.com") - { - var storage = StorageClient.Create(); - var bucket = storage.GetBucket(bucketName, new GetBucketOptions { Projection = Projection.Full }); - - var bucketAclForUser = bucket.Acl.Where((acl) => acl.Entity == $"user-{userEmail}"); - foreach (var acl in bucketAclForUser) - { - Console.WriteLine($"{acl.Role}:{acl.Entity}"); - } - - return bucketAclForUser; - } -} -// [END storage_print_bucket_acl_for_user]