From ee54180880376324f52df3f50aa0107762ca765e Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 29 Jan 2025 02:09:51 +0000 Subject: [PATCH 01/28] fix: add oauth scopes to Places proto PiperOrigin-RevId: 720741557 Source-Link: https://github.com/googleapis/googleapis/commit/280725e991516d4a0f136268faf5aa6d32d21b54 Source-Link: https://github.com/googleapis/googleapis-gen/commit/194c4c32941fe559dd1a9848f4891db595562af5 Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuTWFwcy5QbGFjZXMuVjEvLk93bEJvdC55YW1sIiwiaCI6IjE5NGM0YzMyOTQxZmU1NTlkZDFhOTg0OGY0ODkxZGI1OTU1NjJhZjUifQ== --- .../Google.Maps.Places.V1/PlacesClient.g.cs | 12 ++++++++++-- .../Google.Maps.Places.V1/PlacesService.g.cs | 13 +++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/apis/Google.Maps.Places.V1/Google.Maps.Places.V1/PlacesClient.g.cs b/apis/Google.Maps.Places.V1/Google.Maps.Places.V1/PlacesClient.g.cs index 408e364549ff..f26eaa962698 100644 --- a/apis/Google.Maps.Places.V1/Google.Maps.Places.V1/PlacesClient.g.cs +++ b/apis/Google.Maps.Places.V1/Google.Maps.Places.V1/PlacesClient.g.cs @@ -186,8 +186,16 @@ public abstract partial class PlacesClient public static string DefaultEndpoint { get; } = "places.googleapis.com:443"; /// The default Places scopes. - /// The default Places scopes are: - public static scg::IReadOnlyList DefaultScopes { get; } = new sco::ReadOnlyCollection(new string[] { }); + /// + /// The default Places scopes are: + /// + /// https://www.googleapis.com/auth/cloud-platform + /// + /// + public static scg::IReadOnlyList DefaultScopes { get; } = new sco::ReadOnlyCollection(new string[] + { + "https://www.googleapis.com/auth/cloud-platform", + }); /// The service metadata associated with this client type. public static gaxgrpc::ServiceMetadata ServiceMetadata { get; } = new gaxgrpc::ServiceMetadata(Places.Descriptor, DefaultEndpoint, DefaultScopes, true, gax::ApiTransports.Grpc | gax::ApiTransports.Rest, PackageApiMetadata.ApiMetadata); diff --git a/apis/Google.Maps.Places.V1/Google.Maps.Places.V1/PlacesService.g.cs b/apis/Google.Maps.Places.V1/Google.Maps.Places.V1/PlacesService.g.cs index f15a8a521755..1e7f646d277d 100644 --- a/apis/Google.Maps.Places.V1/Google.Maps.Places.V1/PlacesService.g.cs +++ b/apis/Google.Maps.Places.V1/Google.Maps.Places.V1/PlacesService.g.cs @@ -152,7 +152,7 @@ static PlacesServiceReflection() { "U3VnZ2VzdGlvbi5Gb3JtYXR0YWJsZVRleHQSaAoRc3RydWN0dXJlZF9mb3Jt", "YXQYAiABKAsyTS5nb29nbGUubWFwcy5wbGFjZXMudjEuQXV0b2NvbXBsZXRl", "UGxhY2VzUmVzcG9uc2UuU3VnZ2VzdGlvbi5TdHJ1Y3R1cmVkRm9ybWF0QgYK", - "BGtpbmQy4QUKBlBsYWNlcxKLAQoMU2VhcmNoTmVhcmJ5EiouZ29vZ2xlLm1h", + "BGtpbmQykgYKBlBsYWNlcxKLAQoMU2VhcmNoTmVhcmJ5EiouZ29vZ2xlLm1h", "cHMucGxhY2VzLnYxLlNlYXJjaE5lYXJieVJlcXVlc3QaKy5nb29nbGUubWFw", "cy5wbGFjZXMudjEuU2VhcmNoTmVhcmJ5UmVzcG9uc2UiIoLT5JMCHCIXL3Yx", "L3BsYWNlczpzZWFyY2hOZWFyYnk6ASoSgwEKClNlYXJjaFRleHQSKC5nb29n", @@ -168,11 +168,12 @@ static PlacesServiceReflection() { "Z29vZ2xlLm1hcHMucGxhY2VzLnYxLkF1dG9jb21wbGV0ZVBsYWNlc1JlcXVl", "c3QaMS5nb29nbGUubWFwcy5wbGFjZXMudjEuQXV0b2NvbXBsZXRlUGxhY2Vz", "UmVzcG9uc2UiIoLT5JMCHCIXL3YxL3BsYWNlczphdXRvY29tcGxldGU6ASoa", - "GMpBFXBsYWNlcy5nb29nbGVhcGlzLmNvbUKjAQoZY29tLmdvb2dsZS5tYXBz", - "LnBsYWNlcy52MUISUGxhY2VzU2VydmljZVByb3RvUAFaN2Nsb3VkLmdvb2ds", - "ZS5jb20vZ28vbWFwcy9wbGFjZXMvYXBpdjEvcGxhY2VzcGI7cGxhY2VzcGKi", - "AgZHTVBTVjGqAhVHb29nbGUuTWFwcy5QbGFjZXMuVjHKAhVHb29nbGVcTWFw", - "c1xQbGFjZXNcVjFiBnByb3RvMw==")); + "ScpBFXBsYWNlcy5nb29nbGVhcGlzLmNvbdJBLmh0dHBzOi8vd3d3Lmdvb2ds", + "ZWFwaXMuY29tL2F1dGgvY2xvdWQtcGxhdGZvcm1CowEKGWNvbS5nb29nbGUu", + "bWFwcy5wbGFjZXMudjFCElBsYWNlc1NlcnZpY2VQcm90b1ABWjdjbG91ZC5n", + "b29nbGUuY29tL2dvL21hcHMvcGxhY2VzL2FwaXYxL3BsYWNlc3BiO3BsYWNl", + "c3BiogIGR01QU1YxqgIVR29vZ2xlLk1hcHMuUGxhY2VzLlYxygIVR29vZ2xl", + "XE1hcHNcUGxhY2VzXFYxYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Api.AnnotationsReflection.Descriptor, global::Google.Api.ClientReflection.Descriptor, global::Google.Api.FieldBehaviorReflection.Descriptor, global::Google.Api.ResourceReflection.Descriptor, global::Google.Geo.Type.ViewportReflection.Descriptor, global::Google.Maps.Places.V1.ContextualContentReflection.Descriptor, global::Google.Maps.Places.V1.EvChargingReflection.Descriptor, global::Google.Maps.Places.V1.GeometryReflection.Descriptor, global::Google.Maps.Places.V1.PlaceReflection.Descriptor, global::Google.Maps.Places.V1.PolylineReflection.Descriptor, global::Google.Maps.Places.V1.RouteModifiersReflection.Descriptor, global::Google.Maps.Places.V1.RoutingPreferenceReflection.Descriptor, global::Google.Maps.Places.V1.RoutingSummaryReflection.Descriptor, global::Google.Maps.Places.V1.TravelModeReflection.Descriptor, global::Google.Type.LatlngReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { From 12c0d70dd80fa58c606ca745e4798c1c8beab292 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Tue, 26 Nov 2024 04:50:10 -0800 Subject: [PATCH 02/28] Co-authored-by: Amanda Tarafa Mas <14878252+amanda-tarafa@users.noreply.github.com> Co-authored-by: Amanda Tarafa Mas <14878252+amanda-tarafa@users.noreply.github.com> modified: generator-input/apis.json --- .../GetBucketTest.cs | 58 +++++++++++++++++++ .../ListBucketsTest.cs | 21 +++++++ .../RestoreBucketTest.cs | 43 ++++++++++++++ .../GetBucketOptionsTest.cs | 10 +++- .../ListBucketsOptionsTest.cs | 5 +- .../RestoreBucketOptionsTest.cs | 45 ++++++++++++++ .../GetBucketOptions.cs | 20 +++++++ .../ListBucketsOptions.cs | 9 +++ .../RestoreBucketOptions.cs | 58 +++++++++++++++++++ .../StorageClient.RestoreBucket.cs | 49 ++++++++++++++++ .../StorageClientImpl.RestoreBucket.cs | 45 ++++++++++++++ generator-input/apis.json | 2 +- 12 files changed, 362 insertions(+), 3 deletions(-) create mode 100644 apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs create mode 100644 apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs create mode 100644 apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs create mode 100644 apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs create mode 100644 apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs create mode 100644 apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs new file mode 100644 index 000000000000..17945192b327 --- /dev/null +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs @@ -0,0 +1,58 @@ +// Copyright 2024 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. + +using System; +using System.Threading.Tasks; +using Xunit; + +namespace Google.Cloud.Storage.V1.IntegrationTests; +[Collection(nameof(StorageFixture))] +public class GetBucketTest +{ + private readonly StorageFixture _fixture; + + public GetBucketTest(StorageFixture fixture) + { + _fixture = fixture; + } + + [Fact] + public async Task SoftDeleted() + { + var softDeleteBucket = _fixture.CreateBucket(Guid.NewGuid().ToString() + "-soft-delete", false, true); + var bucket = await _fixture.Client.GetBucketAsync(softDeleteBucket.Name, new GetBucketOptions { SoftDeleted = false }); + + await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); + var softDeleted = await _fixture.Client.GetBucketAsync(softDeleteBucket.Name, new GetBucketOptions { SoftDeleted = true, Generation = bucket.Generation }); + Assert.NotNull(bucket.Generation); + Assert.NotNull(softDeleted.Generation); + Assert.Equal(bucket.Generation, softDeleted.Generation); + } + + [Fact] + public async Task GetSoftDeletedBucket() + { + var softDeleteBucket = _fixture.CreateBucket(Guid.NewGuid().ToString() + "-soft-delete", false, true); + var bucket = await _fixture.Client.GetBucketAsync(softDeleteBucket.Name, new GetBucketOptions { SoftDeleted = false }); + await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); + + var softDeleted = await _fixture.Client.GetBucketAsync(softDeleteBucket.Name, new GetBucketOptions { SoftDeleted = true, Generation = bucket.Generation }); + + Assert.NotNull(bucket.Name); + Assert.NotNull(softDeleted.Name); + Assert.Equal(bucket.Name, softDeleted.Name); + Assert.NotNull(softDeleted.SoftDeleteTimeDateTimeOffset); + Assert.NotNull(softDeleted.HardDeleteTimeDateTimeOffset); + } +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs index c4f6f04799a1..46c9956ade9b 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs @@ -75,6 +75,25 @@ public void PartialResponses() } } + [Fact] + public async Task SoftDeletedOnly() + { + var actualBuckets = await _fixture.Client.ListBucketsAsync(_fixture.ProjectId, new ListBucketsOptions { SoftDeletedOnly = true }).ToListAsync(); + + foreach (var bucket in actualBuckets) + { + // Check if list contains only soft deleted buckets created in storage fixture + if (bucket.Name.EndsWith("soft-delete")) + { + Assert.NotNull(bucket.Name); + Assert.NotNull(bucket.Generation); + Assert.NotNull(bucket.SoftDeleteTimeDateTimeOffset); + Assert.NotNull(bucket.HardDeleteTimeDateTimeOffset); + } + + } + } + // Fetches buckets using the given options in each possible way, validating that the expected bucket names are returned. private async Task AssertBuckets(ListBucketsOptions options, params string[] expectedBucketNames) { @@ -90,5 +109,7 @@ private void AssertBucketNames(IEnumerable actualBuckets, string[] expec var actualNames = actualBuckets.Select(b => b.Name).Where(name => name.StartsWith(_fixture.BucketPrefix)).OrderBy(x => x).ToList(); Assert.Equal(expectedNames.OrderBy(x => x), actualNames); } + + } } diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs new file mode 100644 index 000000000000..08ae55dd0e1d --- /dev/null +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs @@ -0,0 +1,43 @@ +// Copyright 2024 Google Inc. All Rights Reserved. +// +// 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 System; +using System.Threading.Tasks; +using Xunit; + +namespace Google.Cloud.Storage.V1.IntegrationTests +{ + [Collection(nameof(StorageFixture))] + public class RestoreBucketTest + { + private readonly StorageFixture _fixture; + + public RestoreBucketTest(StorageFixture fixture) + { + _fixture = fixture; + } + + [Fact] + public async Task RestoreSoftDeletedBucket() + { + var softDeleteBucket = _fixture.CreateBucket(Guid.NewGuid().ToString() + "-soft-delete", false, true); + var bucket = await _fixture.Client.GetBucketAsync(softDeleteBucket.Name, new GetBucketOptions { SoftDeleted = false }); + await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); + + var restored = await _fixture.Client.RestoreBucketAsync(softDeleteBucket.Name, bucket.Generation.Value); + Assert.Equal(bucket.Name, restored.Name); + Assert.Equal(bucket.Generation, restored.Generation); + } + } +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs index abdb68f17624..73df3f10fda2 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs @@ -31,6 +31,8 @@ public void ModifyRequest_DefaultOptions() Assert.Null(request.IfMetagenerationNotMatch); Assert.Null(request.Projection); Assert.Null(request.UserProject); + Assert.Null(request.SoftDeleted); + Assert.Null(request.Generation); } [Fact] @@ -41,13 +43,17 @@ public void ModifyRequest_PositiveMatchOptions() { IfMetagenerationMatch = 1L, Projection = Projection.Full, - UserProject = "proj" + UserProject = "proj", + SoftDeleted = true, + Generation = long.MaxValue }; options.ModifyRequest(request); Assert.Equal(1L, request.IfMetagenerationMatch); Assert.Null(request.IfMetagenerationNotMatch); Assert.Equal(ProjectionEnum.Full, request.Projection); Assert.Equal("proj", request.UserProject); + Assert.Equal(true, request.SoftDeleted); + Assert.Equal(long.MaxValue,request.Generation); } [Fact] @@ -61,6 +67,8 @@ public void ModifyRequest_NegativeMatchOptions() }; options.ModifyRequest(request); Assert.Null(request.IfMetagenerationMatch); + Assert.Null(request.SoftDeleted); + Assert.Null(request.Generation); Assert.Equal(1L, request.IfMetagenerationNotMatch); Assert.Equal(ProjectionEnum.Full, request.Projection); } diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs index f4868acd6c0a..2d21162d4248 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs @@ -30,6 +30,7 @@ public void ModifyRequest_DefaultOptions() Assert.Null(request.Prefix); Assert.Null(request.MaxResults); Assert.Null(request.PageToken); + Assert.Null(request.SoftDeleted); } [Fact] @@ -42,7 +43,8 @@ public void ModifyRequest_AllOptions() Prefix = "prefix", Projection = Projection.Full, PageToken = "nextpage", - Fields = "items(name),nextPageToken" + Fields = "items(name),nextPageToken", + SoftDeletedOnly = true, }; options.ModifyRequest(request); Assert.Equal(10, request.MaxResults); @@ -50,6 +52,7 @@ public void ModifyRequest_AllOptions() Assert.Equal(ProjectionEnum.Full, request.Projection); Assert.Equal("nextpage", request.PageToken); Assert.Equal("items(name),nextPageToken", request.Fields); + Assert.Equal(true, request.SoftDeleted); } } } diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs new file mode 100644 index 000000000000..8a5fe2503c69 --- /dev/null +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs @@ -0,0 +1,45 @@ +// Copyright 2024 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. + +using Xunit; +using static Google.Apis.Storage.v1.BucketsResource; +using static Google.Apis.Storage.v1.BucketsResource.RestoreRequest; + +namespace Google.Cloud.Storage.V1.Tests; +public class RestoreBucketOptionsTest +{ + [Fact] + public void ModifyRequest_DefaultOptions() + { + var request = new RestoreRequest(null, "bucket", 2L); + var options = new RestoreBucketOptions(); + options.ModifyRequest(request); + Assert.Null(request.Projection); + Assert.Null(request.UserProject); + } + + [Fact] + public void ModifyRequest_AllOptions() + { + var request = new RestoreRequest(null, "bucket", 2L); + var options = new RestoreBucketOptions + { + Projection = Projection.Full, + UserProject = "proj" + }; + options.ModifyRequest(request); + Assert.Equal(ProjectionEnum.Full, request.Projection); + Assert.Equal("proj", request.UserProject); + } +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs index 266dab4389f6..c79ce8762512 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs @@ -52,6 +52,17 @@ public sealed class GetBucketOptions /// public RetryOptions RetryOptions { get; set; } + /// + /// The bucket generation to be retrieved. It must be set if is true. + /// + public long? Generation { get; set; } + + /// + /// If true, the soft-deleted version of the bucket will be retrieved. + /// If true, must be set. + /// + public bool? SoftDeleted { get; set; } + internal void ModifyRequest(GetRequest request) { if (IfMetagenerationMatch != null && IfMetagenerationNotMatch != null) @@ -75,6 +86,15 @@ internal void ModifyRequest(GetRequest request) { request.UserProject = UserProject; } + if (Generation != null) + { + request.Generation = Generation; + } + if (SoftDeleted != null) + { + request.SoftDeleted = SoftDeleted; + } + } } } diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/ListBucketsOptions.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/ListBucketsOptions.cs index 3fe2fccd2110..13881e8bce8f 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/ListBucketsOptions.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/ListBucketsOptions.cs @@ -62,6 +62,11 @@ public sealed class ListBucketsOptions /// public RetryOptions RetryOptions { get; set; } + /// + /// If true, only soft-deleted buckets will be listed. The default is false. + /// + public bool? SoftDeletedOnly { get; set; } + /// /// Modifies the specified request for all non-null properties of this options object. /// @@ -88,6 +93,10 @@ internal void ModifyRequest(ListRequest request) { request.Fields = Fields; } + if (SoftDeletedOnly != null) + { + request.SoftDeleted = SoftDeletedOnly; + } } } } diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs new file mode 100644 index 000000000000..a52f168b7f66 --- /dev/null +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs @@ -0,0 +1,58 @@ +// Copyright 2024 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. + +using Google.Api.Gax; +using static Google.Apis.Storage.v1.BucketsResource; +using static Google.Apis.Storage.v1.BucketsResource.RestoreRequest; + +namespace Google.Cloud.Storage.V1; + +/// +/// Options for RestoreBucket operations. +/// +public sealed class RestoreBucketOptions +{ + /// + /// The projection of the restored bucket to return. Note the whole bucket will be restored, + /// except for the bucket's access controls. This only affects + /// what information is returned when restoration is successful. + /// + public Projection? Projection { get; set; } + /// + /// The encryption key to use for this operation. If this property is null, the + /// will be used instead. Use to remove encryption headers from this request. + /// + public EncryptionKey EncryptionKey { get; set; } + /// + /// If set, this is the ID of the project which will be billed for the request. + /// The caller must have suitable permissions for the project being billed. + /// + public string UserProject { get; set; } + /// + /// Options to pass custom retry configuration for each API request. + /// + public RetryOptions RetryOptions { get; set; } + + internal void ModifyRequest(RestoreRequest request) + { + if (Projection != null) + { + request.Projection = GaxPreconditions.CheckEnumValue((ProjectionEnum) Projection, nameof(Projection)); + } + if (UserProject != null) + { + request.UserProject = UserProject; + } + } +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs new file mode 100644 index 000000000000..37f7b707120f --- /dev/null +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs @@ -0,0 +1,49 @@ +// Copyright 2024 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. + +using System; +using System.Threading; +using System.Threading.Tasks; +using Bucket = Google.Apis.Storage.v1.Data.Bucket; + +namespace Google.Cloud.Storage.V1; +public abstract partial class StorageClient +{ + /// + /// Restores a soft-deleted bucket. + /// + /// The name of the bucket. Must not be null. + /// The specific revision of the bucket to restore. + /// Additional options for the restore operation. May be null, in which case appropriate + /// defaults will be used. + /// The representation of the restored Storage bucket. + public virtual Bucket RestoreBucket(string bucket, long generation, RestoreBucketOptions options = null) => + throw new NotImplementedException(); + + /// + /// Restores a soft-deleted bucket. + /// + /// The name of the bucket. Must not be null. + /// The specific revision of the bucket to restore. + /// Additional options for the restore operation. May be null, in which case appropriate + /// defaults will be used. + /// The token to monitor for cancellation requests. + /// A task representing the asynchronous operation, with a result returning the + /// representation of the restored Storage bucket. + public virtual Task RestoreBucketAsync( + string bucket, + long generation, + RestoreBucketOptions options = null, + CancellationToken cancellationToken = default) => throw new NotImplementedException(); +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs new file mode 100644 index 000000000000..cf1601e15416 --- /dev/null +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs @@ -0,0 +1,45 @@ +// Copyright 2024 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. + +using System.Threading.Tasks; +using System.Threading; +using Google.Apis.Storage.v1; +using Bucket = Google.Apis.Storage.v1.Data.Bucket; + +namespace Google.Cloud.Storage.V1; +public sealed partial class StorageClientImpl : StorageClient +{ + /// + public override Bucket RestoreBucket(string bucket, long generation, RestoreBucketOptions options = null) => + CreateRestoreBucketRequest(bucket, generation, options).Execute(); + + /// + public override Task RestoreBucketAsync( + string bucket, + long generation, + RestoreBucketOptions options = null, + CancellationToken cancellationToken = default) => + CreateRestoreBucketRequest(bucket, generation, options).ExecuteAsync(cancellationToken); + + private BucketsResource.RestoreRequest CreateRestoreBucketRequest(string bucket, long generation, RestoreBucketOptions options) + { + ValidateBucketName(bucket); + var request = Service.Buckets.Restore(bucket, generation); + ApplyEncryptionKey(options?.EncryptionKey, kmsNameFromOptions: null, request); + options?.ModifyRequest(request); + RetryOptions retryOptions = options?.RetryOptions ?? RetryOptions.IdempotentRetryOptions; + MarkAsRetriable(request, retryOptions); + return request; + } +} diff --git a/generator-input/apis.json b/generator-input/apis.json index 364541b497fb..ab03c7130f91 100644 --- a/generator-input/apis.json +++ b/generator-input/apis.json @@ -5152,7 +5152,7 @@ "description": "Recommended Google client library to access the Google Cloud Storage API. It wraps the Google.Apis.Storage.v1 client library, making common operations simpler in client code. Google Cloud Storage stores and retrieves potentially large, immutable data objects.", "dependencies": { "Google.Api.Gax.Rest": "default", - "Google.Apis.Storage.v1": "1.68.0.3431" + "Google.Apis.Storage.v1": "1.68.0.3604" }, "testDependencies": { "Google.Api.Gax.Testing": "default", From 39a1f2108f22b4b98a02640fc25e32d34caf30dc Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Thu, 23 Jan 2025 23:06:24 -0800 Subject: [PATCH 03/28] file-scoped namespace and generate bucket name method added --- .../RestoreBucketTest.cs | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs index 08ae55dd0e1d..c092e0cdeca8 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs @@ -16,28 +16,27 @@ using System.Threading.Tasks; using Xunit; -namespace Google.Cloud.Storage.V1.IntegrationTests +namespace Google.Cloud.Storage.V1.IntegrationTests; + +[Collection(nameof(StorageFixture))] +public class RestoreBucketTest { - [Collection(nameof(StorageFixture))] - public class RestoreBucketTest - { - private readonly StorageFixture _fixture; + private readonly StorageFixture _fixture; - public RestoreBucketTest(StorageFixture fixture) - { - _fixture = fixture; - } + public RestoreBucketTest(StorageFixture fixture) + { + _fixture = fixture; + } - [Fact] - public async Task RestoreSoftDeletedBucket() - { - var softDeleteBucket = _fixture.CreateBucket(Guid.NewGuid().ToString() + "-soft-delete", false, true); - var bucket = await _fixture.Client.GetBucketAsync(softDeleteBucket.Name, new GetBucketOptions { SoftDeleted = false }); - await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); + [Fact] + public async Task RestoreSoftDeletedBucket() + { + var bucketName = _fixture.GenerateBucketName(); + var softDeleteBucket = _fixture.CreateBucket(bucketName, false, true); + await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); - var restored = await _fixture.Client.RestoreBucketAsync(softDeleteBucket.Name, bucket.Generation.Value); - Assert.Equal(bucket.Name, restored.Name); - Assert.Equal(bucket.Generation, restored.Generation); - } + var restored = await _fixture.Client.RestoreBucketAsync(softDeleteBucket.Name, softDeleteBucket.Generation.Value); + Assert.Equal(softDeleteBucket.Name, restored.Name); + Assert.Equal(softDeleteBucket.Generation, restored.Generation); } } From 38fd06f2818e795db76d9a1f7683be9f6c8e6f96 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Fri, 24 Jan 2025 01:57:41 -0800 Subject: [PATCH 04/28] Adding all tests in single test , addition of generatebucket name method --- .../GetBucketTest.cs | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs index 17945192b327..f97b21c0b207 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs @@ -30,28 +30,13 @@ public GetBucketTest(StorageFixture fixture) [Fact] public async Task SoftDeleted() { - var softDeleteBucket = _fixture.CreateBucket(Guid.NewGuid().ToString() + "-soft-delete", false, true); - var bucket = await _fixture.Client.GetBucketAsync(softDeleteBucket.Name, new GetBucketOptions { SoftDeleted = false }); - - await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); - var softDeleted = await _fixture.Client.GetBucketAsync(softDeleteBucket.Name, new GetBucketOptions { SoftDeleted = true, Generation = bucket.Generation }); - Assert.NotNull(bucket.Generation); - Assert.NotNull(softDeleted.Generation); - Assert.Equal(bucket.Generation, softDeleted.Generation); - } - - [Fact] - public async Task GetSoftDeletedBucket() - { - var softDeleteBucket = _fixture.CreateBucket(Guid.NewGuid().ToString() + "-soft-delete", false, true); - var bucket = await _fixture.Client.GetBucketAsync(softDeleteBucket.Name, new GetBucketOptions { SoftDeleted = false }); + var bucketName = _fixture.GenerateBucketName(); + var softDeleteBucket = _fixture.CreateBucket(bucketName, false, true); await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); - var softDeleted = await _fixture.Client.GetBucketAsync(softDeleteBucket.Name, new GetBucketOptions { SoftDeleted = true, Generation = bucket.Generation }); - - Assert.NotNull(bucket.Name); - Assert.NotNull(softDeleted.Name); - Assert.Equal(bucket.Name, softDeleted.Name); + var softDeleted = await _fixture.Client.GetBucketAsync(softDeleteBucket.Name, new GetBucketOptions { SoftDeleted = true, Generation = softDeleteBucket.Generation }); + Assert.Equal(softDeleteBucket.Name, softDeleted.Name); + Assert.Equal(softDeleteBucket.Generation, softDeleted.Generation); Assert.NotNull(softDeleted.SoftDeleteTimeDateTimeOffset); Assert.NotNull(softDeleted.HardDeleteTimeDateTimeOffset); } From dd02b375f4af5fa095ac0ffb08221fb040ed93c2 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Fri, 24 Jan 2025 02:03:00 -0800 Subject: [PATCH 05/28] adding a blank line between one property and the next --- .../Google.Cloud.Storage.V1/RestoreBucketOptions.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs index a52f168b7f66..200dc17dc759 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs @@ -29,16 +29,19 @@ public sealed class RestoreBucketOptions /// what information is returned when restoration is successful. /// public Projection? Projection { get; set; } + /// /// The encryption key to use for this operation. If this property is null, the /// will be used instead. Use to remove encryption headers from this request. /// public EncryptionKey EncryptionKey { get; set; } + /// /// If set, this is the ID of the project which will be billed for the request. /// The caller must have suitable permissions for the project being billed. /// public string UserProject { get; set; } + /// /// Options to pass custom retry configuration for each API request. /// From 0258eb20b3dd8d3c89cbd6aff7f163f566b8f190 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Fri, 24 Jan 2025 02:45:49 -0800 Subject: [PATCH 06/28] List Soft Deleted Bucket test case changes --- .../ListBucketsTest.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs index 46c9956ade9b..863d36c79e6a 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs @@ -78,19 +78,19 @@ public void PartialResponses() [Fact] public async Task SoftDeletedOnly() { + var bucketName = _fixture.GenerateBucketName(); + var softDeleteBucket = _fixture.CreateBucket(bucketName, false, true); + await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); var actualBuckets = await _fixture.Client.ListBucketsAsync(_fixture.ProjectId, new ListBucketsOptions { SoftDeletedOnly = true }).ToListAsync(); foreach (var bucket in actualBuckets) { - // Check if list contains only soft deleted buckets created in storage fixture - if (bucket.Name.EndsWith("soft-delete")) + if (bucket.Name == softDeleteBucket.Name) { - Assert.NotNull(bucket.Name); Assert.NotNull(bucket.Generation); Assert.NotNull(bucket.SoftDeleteTimeDateTimeOffset); Assert.NotNull(bucket.HardDeleteTimeDateTimeOffset); } - } } @@ -109,7 +109,5 @@ private void AssertBucketNames(IEnumerable actualBuckets, string[] expec var actualNames = actualBuckets.Select(b => b.Name).Where(name => name.StartsWith(_fixture.BucketPrefix)).OrderBy(x => x).ToList(); Assert.Equal(expectedNames.OrderBy(x => x), actualNames); } - - } } From 9a5bfe7bca93a50f1f18bc8e1b3cae83a82c12e2 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Sun, 26 Jan 2025 22:02:24 -0800 Subject: [PATCH 07/28] Removal of encryption key support for restore bucket request and removal of package version override --- .../Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.csproj | 4 ++-- .../StorageClientImpl.RestoreBucket.cs | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.csproj b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.csproj index 9cfae17c9fd9..d0fb5ece91fe 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.csproj +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs index cf1601e15416..ad3be96a5c46 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs @@ -36,7 +36,6 @@ private BucketsResource.RestoreRequest CreateRestoreBucketRequest(string bucket, { ValidateBucketName(bucket); var request = Service.Buckets.Restore(bucket, generation); - ApplyEncryptionKey(options?.EncryptionKey, kmsNameFromOptions: null, request); options?.ModifyRequest(request); RetryOptions retryOptions = options?.RetryOptions ?? RetryOptions.IdempotentRetryOptions; MarkAsRetriable(request, retryOptions); From 7efe4724e557d3b6b713e16d5e929232912773c3 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Tue, 28 Jan 2025 02:51:21 -0800 Subject: [PATCH 08/28] Recommended changes as per internal PR review --- .../ListBucketsTest.cs | 12 +++++++----- .../RestoreBucketTest.cs | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs index 863d36c79e6a..563b3cabcdca 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs @@ -84,12 +84,14 @@ public async Task SoftDeletedOnly() var actualBuckets = await _fixture.Client.ListBucketsAsync(_fixture.ProjectId, new ListBucketsOptions { SoftDeletedOnly = true }).ToListAsync(); foreach (var bucket in actualBuckets) - { + { // Verify if the bucket is soft-deleted only + Assert.NotNull(bucket.Generation); + Assert.NotNull(bucket.SoftDeleteTimeDateTimeOffset); + Assert.NotNull(bucket.HardDeleteTimeDateTimeOffset); + if (bucket.Name == softDeleteBucket.Name) - { - Assert.NotNull(bucket.Generation); - Assert.NotNull(bucket.SoftDeleteTimeDateTimeOffset); - Assert.NotNull(bucket.HardDeleteTimeDateTimeOffset); + { // Compare the generation number + Assert.Equal(bucket.Generation, softDeleteBucket.Generation); } } } diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs index c092e0cdeca8..888f2afd29bf 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs @@ -35,8 +35,8 @@ public async Task RestoreSoftDeletedBucket() var softDeleteBucket = _fixture.CreateBucket(bucketName, false, true); await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); - var restored = await _fixture.Client.RestoreBucketAsync(softDeleteBucket.Name, softDeleteBucket.Generation.Value); - Assert.Equal(softDeleteBucket.Name, restored.Name); - Assert.Equal(softDeleteBucket.Generation, restored.Generation); + var restoredBucket = await _fixture.Client.RestoreBucketAsync(softDeleteBucket.Name, softDeleteBucket.Generation.Value); + Assert.Equal(softDeleteBucket.Name, restoredBucket.Name); + Assert.Equal(softDeleteBucket.Generation, restoredBucket.Generation); } } From 595e6ffed5cc73bb5ec5a5818c27314397d0ee2b Mon Sep 17 00:00:00 2001 From: Mahendra Date: Wed, 12 Feb 2025 09:14:23 +0530 Subject: [PATCH 09/28] named arguments added while calling create bucket method Co-authored-by: Amanda Tarafa Mas <14878252+amanda-tarafa@users.noreply.github.com> --- .../RestoreBucketTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs index 888f2afd29bf..b1652f54db26 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs @@ -32,7 +32,7 @@ public RestoreBucketTest(StorageFixture fixture) public async Task RestoreSoftDeletedBucket() { var bucketName = _fixture.GenerateBucketName(); - var softDeleteBucket = _fixture.CreateBucket(bucketName, false, true); + var softDeleteBucket = _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: true); await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); var restoredBucket = await _fixture.Client.RestoreBucketAsync(softDeleteBucket.Name, softDeleteBucket.Generation.Value); From ddd62d1148ae31a0a5e9638c340514be80dc8522 Mon Sep 17 00:00:00 2001 From: Mahendra Date: Wed, 12 Feb 2025 09:15:31 +0530 Subject: [PATCH 10/28] Update apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs Co-authored-by: Amanda Tarafa Mas <14878252+amanda-tarafa@users.noreply.github.com> --- .../Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs index 73df3f10fda2..50d82df90b30 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs @@ -52,7 +52,7 @@ public void ModifyRequest_PositiveMatchOptions() Assert.Null(request.IfMetagenerationNotMatch); Assert.Equal(ProjectionEnum.Full, request.Projection); Assert.Equal("proj", request.UserProject); - Assert.Equal(true, request.SoftDeleted); + Assert.True(request.SoftDeleted); Assert.Equal(long.MaxValue,request.Generation); } From 229e343a66e54e751970a5681d96c5d5081c3694 Mon Sep 17 00:00:00 2001 From: Mahendra Date: Wed, 12 Feb 2025 09:15:58 +0530 Subject: [PATCH 11/28] Update apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs Co-authored-by: Amanda Tarafa Mas <14878252+amanda-tarafa@users.noreply.github.com> --- .../Google.Cloud.Storage.V1/GetBucketOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs index c79ce8762512..ab7741a39601 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs @@ -59,7 +59,7 @@ public sealed class GetBucketOptions /// /// If true, the soft-deleted version of the bucket will be retrieved. - /// If true, must be set. + /// If true, must be set. /// public bool? SoftDeleted { get; set; } From beb036cb1eda425daa876aa6498233f0e73cca21 Mon Sep 17 00:00:00 2001 From: Mahendra Date: Wed, 12 Feb 2025 09:16:37 +0530 Subject: [PATCH 12/28] Update apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs Co-authored-by: Amanda Tarafa Mas <14878252+amanda-tarafa@users.noreply.github.com> --- .../Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs index 2d21162d4248..2a9172fb5666 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs @@ -52,7 +52,7 @@ public void ModifyRequest_AllOptions() Assert.Equal(ProjectionEnum.Full, request.Projection); Assert.Equal("nextpage", request.PageToken); Assert.Equal("items(name),nextPageToken", request.Fields); - Assert.Equal(true, request.SoftDeleted); + Assert.True(request.SoftDeleted); } } } From 517b8278fb4c4361e92f50c39b1f3172a6584d8d Mon Sep 17 00:00:00 2001 From: Mahendra Date: Wed, 12 Feb 2025 09:20:36 +0530 Subject: [PATCH 13/28] restore white space in Google.Cloud.Storage.V1.csproj --- .../Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.csproj b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.csproj index d0fb5ece91fe..a76376d4c6eb 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.csproj +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.csproj @@ -9,7 +9,7 @@ - + @@ -23,4 +23,4 @@ UrlSigner.cs - \ No newline at end of file + From 8b89da6c9e048ce78dd7ace01339801bb4a608ce Mon Sep 17 00:00:00 2001 From: Mahendra Date: Wed, 12 Feb 2025 09:29:17 +0530 Subject: [PATCH 14/28] Update GetBucketOptionsTest.cs --- .../Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs index 50d82df90b30..ac55c4a9a461 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs @@ -67,8 +67,6 @@ public void ModifyRequest_NegativeMatchOptions() }; options.ModifyRequest(request); Assert.Null(request.IfMetagenerationMatch); - Assert.Null(request.SoftDeleted); - Assert.Null(request.Generation); Assert.Equal(1L, request.IfMetagenerationNotMatch); Assert.Equal(ProjectionEnum.Full, request.Projection); } From 56639b46582f7fdc7c6d85e8181e1c62211aa3c5 Mon Sep 17 00:00:00 2001 From: Mahendra Date: Wed, 12 Feb 2025 09:40:06 +0530 Subject: [PATCH 15/28] Update ListBucketsTest.cs --- .../Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs index 563b3cabcdca..195ce0eda219 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs @@ -79,7 +79,7 @@ public void PartialResponses() public async Task SoftDeletedOnly() { var bucketName = _fixture.GenerateBucketName(); - var softDeleteBucket = _fixture.CreateBucket(bucketName, false, true); + var softDeleteBucket = _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: true); await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); var actualBuckets = await _fixture.Client.ListBucketsAsync(_fixture.ProjectId, new ListBucketsOptions { SoftDeletedOnly = true }).ToListAsync(); From ec7aab9d988c4cd3d2481e1ac14c9ec8433d0ca5 Mon Sep 17 00:00:00 2001 From: Mahendra Date: Wed, 12 Feb 2025 09:43:44 +0530 Subject: [PATCH 16/28] Update GetBucketTest.cs --- .../Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs index f97b21c0b207..dd5cee56b694 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs @@ -31,7 +31,7 @@ public GetBucketTest(StorageFixture fixture) public async Task SoftDeleted() { var bucketName = _fixture.GenerateBucketName(); - var softDeleteBucket = _fixture.CreateBucket(bucketName, false, true); + var softDeleteBucket = _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: true); await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); var softDeleted = await _fixture.Client.GetBucketAsync(softDeleteBucket.Name, new GetBucketOptions { SoftDeleted = true, Generation = softDeleteBucket.Generation }); From 25d3356c364ca25ca26ab6f7ad14c6da23282e2f Mon Sep 17 00:00:00 2001 From: Mahendra Date: Wed, 12 Feb 2025 18:36:44 +0530 Subject: [PATCH 17/28] encryption key removed from RestoreBucketOptions --- .../Google.Cloud.Storage.V1/RestoreBucketOptions.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs index 200dc17dc759..d89bd396f4ff 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs @@ -30,12 +30,6 @@ public sealed class RestoreBucketOptions /// public Projection? Projection { get; set; } - /// - /// The encryption key to use for this operation. If this property is null, the - /// will be used instead. Use to remove encryption headers from this request. - /// - public EncryptionKey EncryptionKey { get; set; } - /// /// If set, this is the ID of the project which will be billed for the request. /// The caller must have suitable permissions for the project being billed. From 1e026b1668fcf3c2e874c0f7b1bf8d6fa7ae1c61 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Mon, 17 Feb 2025 19:18:04 -0800 Subject: [PATCH 18/28] Initial commit for Assert.Contains and Assert.All in list bucket test --- .../ListBucketsTest.cs | 55 +++++++++++++++---- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs index 195ce0eda219..8bdf8b9b1e90 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs @@ -79,23 +79,54 @@ public void PartialResponses() public async Task SoftDeletedOnly() { var bucketName = _fixture.GenerateBucketName(); - var softDeleteBucket = _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: true); - await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); - var actualBuckets = await _fixture.Client.ListBucketsAsync(_fixture.ProjectId, new ListBucketsOptions { SoftDeletedOnly = true }).ToListAsync(); + var softDeleteBucket = _fixture.CreateBucket( + bucketName, + multiVersion: false, + softDelete: true + ); + await _fixture.Client.DeleteBucketAsync( + softDeleteBucket.Name, + new DeleteBucketOptions { DeleteObjects = true } + ); + var actualBuckets = await _fixture + .Client.ListBucketsAsync( + _fixture.ProjectId, + new ListBucketsOptions { SoftDeletedOnly = true } + ) + .ToListAsync(); - foreach (var bucket in actualBuckets) - { // Verify if the bucket is soft-deleted only - Assert.NotNull(bucket.Generation); - Assert.NotNull(bucket.SoftDeleteTimeDateTimeOffset); - Assert.NotNull(bucket.HardDeleteTimeDateTimeOffset); + var recentlyCreatedSoftDeleteBucket = actualBuckets + .Where(b => b.Name == softDeleteBucket.Name) + .ToList(); + Assert.Contains( + recentlyCreatedSoftDeleteBucket.First().Name.ToString(), + softDeleteBucket.Name.ToString() + ); + Assert.Contains( + recentlyCreatedSoftDeleteBucket.First().Generation.ToString(), + softDeleteBucket.Generation.ToString() + ); + Assert.NotNull(recentlyCreatedSoftDeleteBucket.First().SoftDeleteTimeDateTimeOffset); + Assert.NotNull(recentlyCreatedSoftDeleteBucket.First().HardDeleteTimeDateTimeOffset); - if (bucket.Name == softDeleteBucket.Name) - { // Compare the generation number - Assert.Equal(bucket.Generation, softDeleteBucket.Generation); - } + if (actualBuckets.Count == 0) + { + Assert.Fail("Soft deleted bucket list is empty"); + } + else + { + Assert.All(actualBuckets, AssertSoftDeletedBucket); } } + // Validating whether all buckets are soft-deleted only. + private void AssertSoftDeletedBucket(Bucket b) + { + Assert.NotNull(b.Generation); + Assert.NotNull(b.HardDeleteTimeDateTimeOffset); + Assert.NotNull(b.SoftDeleteTimeDateTimeOffset); + } + // Fetches buckets using the given options in each possible way, validating that the expected bucket names are returned. private async Task AssertBuckets(ListBucketsOptions options, params string[] expectedBucketNames) { From 678d101235033c8869e09c8d1424fc7e6753dfd8 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Tue, 18 Feb 2025 02:18:10 -0800 Subject: [PATCH 19/28] listbucket linters changes --- .../Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs | 2 +- .../Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs | 2 +- .../Google.Cloud.Storage.V1/ListBucketsOptions.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs index 8bdf8b9b1e90..2ef4ec0cd197 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs @@ -143,4 +143,4 @@ private void AssertBucketNames(IEnumerable actualBuckets, string[] expec Assert.Equal(expectedNames.OrderBy(x => x), actualNames); } } -} +} \ No newline at end of file diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs index 2a9172fb5666..4597736de890 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs @@ -55,4 +55,4 @@ public void ModifyRequest_AllOptions() Assert.True(request.SoftDeleted); } } -} +} \ No newline at end of file diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/ListBucketsOptions.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/ListBucketsOptions.cs index 13881e8bce8f..b06646352614 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/ListBucketsOptions.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/ListBucketsOptions.cs @@ -99,4 +99,4 @@ internal void ModifyRequest(ListRequest request) } } } -} +} \ No newline at end of file From f7853af87722caf39887b1eb3d6ab0213ae9255a Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Tue, 18 Feb 2025 02:28:12 -0800 Subject: [PATCH 20/28] restore bucket linter changes --- .../RestoreBucketTest.cs | 2 +- .../Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs | 4 ++-- .../Google.Cloud.Storage.V1/RestoreBucketOptions.cs | 2 +- .../Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs | 2 +- .../StorageClientImpl.RestoreBucket.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs index b1652f54db26..a95df0030bae 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs @@ -39,4 +39,4 @@ public async Task RestoreSoftDeletedBucket() Assert.Equal(softDeleteBucket.Name, restoredBucket.Name); Assert.Equal(softDeleteBucket.Generation, restoredBucket.Generation); } -} +} \ No newline at end of file diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs index 8a5fe2503c69..02879fffb8b8 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs @@ -18,7 +18,7 @@ namespace Google.Cloud.Storage.V1.Tests; public class RestoreBucketOptionsTest -{ +{ [Fact] public void ModifyRequest_DefaultOptions() { @@ -42,4 +42,4 @@ public void ModifyRequest_AllOptions() Assert.Equal(ProjectionEnum.Full, request.Projection); Assert.Equal("proj", request.UserProject); } -} +} \ No newline at end of file diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs index d89bd396f4ff..d30a7aef225a 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs @@ -52,4 +52,4 @@ internal void ModifyRequest(RestoreRequest request) request.UserProject = UserProject; } } -} +} \ No newline at end of file diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs index 37f7b707120f..f49014081016 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs @@ -46,4 +46,4 @@ public virtual Task RestoreBucketAsync( long generation, RestoreBucketOptions options = null, CancellationToken cancellationToken = default) => throw new NotImplementedException(); -} +} \ No newline at end of file diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs index ad3be96a5c46..fa5f4ae95872 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs @@ -41,4 +41,4 @@ private BucketsResource.RestoreRequest CreateRestoreBucketRequest(string bucket, MarkAsRetriable(request, retryOptions); return request; } -} +} \ No newline at end of file From 620c980fd6f812c3848b449b84ca167269ac3df0 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Tue, 18 Feb 2025 02:35:05 -0800 Subject: [PATCH 21/28] getbucket linter changes --- .../Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs | 2 +- .../Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs | 4 ++-- .../Google.Cloud.Storage.V1/GetBucketOptions.cs | 2 +- .../Google.Cloud.Storage.V1/StorageClient.GetBucket.cs | 2 +- .../Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs index dd5cee56b694..b2091e2779fe 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs @@ -40,4 +40,4 @@ public async Task SoftDeleted() Assert.NotNull(softDeleted.SoftDeleteTimeDateTimeOffset); Assert.NotNull(softDeleted.HardDeleteTimeDateTimeOffset); } -} +} \ No newline at end of file diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs index ac55c4a9a461..45e04ea26c03 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs @@ -53,7 +53,7 @@ public void ModifyRequest_PositiveMatchOptions() Assert.Equal(ProjectionEnum.Full, request.Projection); Assert.Equal("proj", request.UserProject); Assert.True(request.SoftDeleted); - Assert.Equal(long.MaxValue,request.Generation); + Assert.Equal(long.MaxValue, request.Generation); } [Fact] @@ -83,4 +83,4 @@ public void ModifyRequest_MatchNotMatchConflicts() } } -} +} \ No newline at end of file diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs index ab7741a39601..e3e170dcb25e 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs @@ -97,4 +97,4 @@ internal void ModifyRequest(GetRequest request) } } -} +} \ No newline at end of file diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.GetBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.GetBucket.cs index afe632c38583..b719baa87ec5 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.GetBucket.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.GetBucket.cs @@ -50,4 +50,4 @@ public virtual Task GetBucketAsync( throw new NotImplementedException(); } } -} +} \ No newline at end of file diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs index e29679e82b21..785af4342145 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs @@ -40,4 +40,4 @@ private BucketsResource.GetRequest CreateGetBucketRequest(string bucket, GetBuck return request; } } -} +} \ No newline at end of file From 9120a0fbe671fe2e0d840aad0649c258b38260c0 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Mon, 24 Feb 2025 02:24:12 -0800 Subject: [PATCH 22/28] getbucket linter changes --- .../GetBucketTest.cs | 2 +- .../Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs | 2 +- .../Google.Cloud.Storage.V1/GetBucketOptions.cs | 4 ++-- .../Google.Cloud.Storage.V1/StorageClient.GetBucket.cs | 4 ++-- .../Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs index b2091e2779fe..dd5cee56b694 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs @@ -40,4 +40,4 @@ public async Task SoftDeleted() Assert.NotNull(softDeleted.SoftDeleteTimeDateTimeOffset); Assert.NotNull(softDeleted.HardDeleteTimeDateTimeOffset); } -} \ No newline at end of file +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs index 45e04ea26c03..99127c183440 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/GetBucketOptionsTest.cs @@ -83,4 +83,4 @@ public void ModifyRequest_MatchNotMatchConflicts() } } -} \ No newline at end of file +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs index e3e170dcb25e..77b525d48b5d 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Google.Api.Gax; using System; +using Google.Api.Gax; using static Google.Apis.Storage.v1.BucketsResource; using static Google.Apis.Storage.v1.BucketsResource.GetRequest; @@ -97,4 +97,4 @@ internal void ModifyRequest(GetRequest request) } } -} \ No newline at end of file +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.GetBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.GetBucket.cs index b719baa87ec5..d67ad2db9018 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.GetBucket.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.GetBucket.cs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Google.Apis.Storage.v1.Data; using System; using System.Threading; using System.Threading.Tasks; +using Google.Apis.Storage.v1.Data; namespace Google.Cloud.Storage.V1 { @@ -50,4 +50,4 @@ public virtual Task GetBucketAsync( throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs index 785af4342145..0291009bec05 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Google.Apis.Storage.v1; -using Google.Apis.Storage.v1.Data; using System.Threading; using System.Threading.Tasks; +using Google.Apis.Storage.v1; +using Google.Apis.Storage.v1.Data; namespace Google.Cloud.Storage.V1 { @@ -40,4 +40,4 @@ private BucketsResource.GetRequest CreateGetBucketRequest(string bucket, GetBuck return request; } } -} \ No newline at end of file +} From 51d54873664fc663b3270f26765a5b7b0114b972 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Mon, 24 Feb 2025 02:36:50 -0800 Subject: [PATCH 23/28] restore bucket linter changes --- .../RestoreBucketTest.cs | 2 +- .../Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs | 2 +- .../Google.Cloud.Storage.V1/RestoreBucketOptions.cs | 2 +- .../Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs | 2 +- .../StorageClientImpl.RestoreBucket.cs | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs index a95df0030bae..b1652f54db26 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/RestoreBucketTest.cs @@ -39,4 +39,4 @@ public async Task RestoreSoftDeletedBucket() Assert.Equal(softDeleteBucket.Name, restoredBucket.Name); Assert.Equal(softDeleteBucket.Generation, restoredBucket.Generation); } -} \ No newline at end of file +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs index 02879fffb8b8..c83b90a8d528 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/RestoreBucketOptionsTest.cs @@ -42,4 +42,4 @@ public void ModifyRequest_AllOptions() Assert.Equal(ProjectionEnum.Full, request.Projection); Assert.Equal("proj", request.UserProject); } -} \ No newline at end of file +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs index d30a7aef225a..d89bd396f4ff 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/RestoreBucketOptions.cs @@ -52,4 +52,4 @@ internal void ModifyRequest(RestoreRequest request) request.UserProject = UserProject; } } -} \ No newline at end of file +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs index f49014081016..37f7b707120f 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.RestoreBucket.cs @@ -46,4 +46,4 @@ public virtual Task RestoreBucketAsync( long generation, RestoreBucketOptions options = null, CancellationToken cancellationToken = default) => throw new NotImplementedException(); -} \ No newline at end of file +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs index fa5f4ae95872..1993a5e08cdb 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System.Threading.Tasks; using System.Threading; +using System.Threading.Tasks; using Google.Apis.Storage.v1; using Bucket = Google.Apis.Storage.v1.Data.Bucket; @@ -41,4 +41,4 @@ private BucketsResource.RestoreRequest CreateRestoreBucketRequest(string bucket, MarkAsRetriable(request, retryOptions); return request; } -} \ No newline at end of file +} From e9accfdb94041c90f2c53569620487aff5036901 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Mon, 24 Feb 2025 02:42:48 -0800 Subject: [PATCH 24/28] listbucket linter changes --- .../ListBucketsTest.cs | 4 ++-- .../Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs | 2 +- .../Google.Cloud.Storage.V1/ListBucketsOptions.cs | 2 +- .../Google.Cloud.Storage.V1/StorageClient.ListBuckets.cs | 2 +- .../Google.Cloud.Storage.V1/StorageClientImpl.ListBuckets.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs index 2ef4ec0cd197..1669cdc7f451 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Google.Apis.Storage.v1.Data; using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Google.Apis.Storage.v1.Data; using Xunit; namespace Google.Cloud.Storage.V1.IntegrationTests @@ -143,4 +143,4 @@ private void AssertBucketNames(IEnumerable actualBuckets, string[] expec Assert.Equal(expectedNames.OrderBy(x => x), actualNames); } } -} \ No newline at end of file +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs index 4597736de890..2a9172fb5666 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/ListBucketsOptionsTest.cs @@ -55,4 +55,4 @@ public void ModifyRequest_AllOptions() Assert.True(request.SoftDeleted); } } -} \ No newline at end of file +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/ListBucketsOptions.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/ListBucketsOptions.cs index b06646352614..13881e8bce8f 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/ListBucketsOptions.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/ListBucketsOptions.cs @@ -99,4 +99,4 @@ internal void ModifyRequest(ListRequest request) } } } -} \ No newline at end of file +} diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.ListBuckets.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.ListBuckets.cs index b5c2a1205b89..782e8851d071 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.ListBuckets.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.ListBuckets.cs @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; using Google.Api.Gax; using Google.Apis.Storage.v1.Data; -using System; namespace Google.Cloud.Storage.V1 { diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.ListBuckets.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.ListBuckets.cs index c0730e3b805a..6cc04c20c250 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.ListBuckets.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.ListBuckets.cs @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System.Collections.Generic; using Google.Api.Gax; using Google.Api.Gax.Rest; using Google.Apis.Storage.v1; using Google.Apis.Storage.v1.Data; -using System.Collections.Generic; namespace Google.Cloud.Storage.V1 { From acc88c503ef8e08e3cece59d3519fea8e3a55943 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Mon, 24 Feb 2025 03:01:32 -0800 Subject: [PATCH 25/28] blank line added in getbucketest --- .../Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs index dd5cee56b694..7b8245c90f42 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs @@ -17,6 +17,7 @@ using Xunit; namespace Google.Cloud.Storage.V1.IntegrationTests; + [Collection(nameof(StorageFixture))] public class GetBucketTest { From 806ae11ca9674cb6a1f5b40cb46dcfed5ce08f20 Mon Sep 17 00:00:00 2001 From: mahendra-google Date: Tue, 25 Feb 2025 03:12:24 -0800 Subject: [PATCH 26/28] linter changes as per editorconfig file rules --- .../ListBucketsTest.cs | 2 +- .../Google.Cloud.Storage.V1/GetBucketOptions.cs | 2 +- .../Google.Cloud.Storage.V1/StorageClient.GetBucket.cs | 2 +- .../Google.Cloud.Storage.V1/StorageClient.ListBuckets.cs | 2 +- .../Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs | 4 ++-- .../Google.Cloud.Storage.V1/StorageClientImpl.ListBuckets.cs | 2 +- .../StorageClientImpl.RestoreBucket.cs | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs index 1669cdc7f451..8bdf8b9b1e90 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Google.Apis.Storage.v1.Data; using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; -using Google.Apis.Storage.v1.Data; using Xunit; namespace Google.Cloud.Storage.V1.IntegrationTests diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs index 77b525d48b5d..ab7741a39601 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/GetBucketOptions.cs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System; using Google.Api.Gax; +using System; using static Google.Apis.Storage.v1.BucketsResource; using static Google.Apis.Storage.v1.BucketsResource.GetRequest; diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.GetBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.GetBucket.cs index d67ad2db9018..afe632c38583 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.GetBucket.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.GetBucket.cs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Google.Apis.Storage.v1.Data; using System; using System.Threading; using System.Threading.Tasks; -using Google.Apis.Storage.v1.Data; namespace Google.Cloud.Storage.V1 { diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.ListBuckets.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.ListBuckets.cs index 782e8851d071..b5c2a1205b89 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.ListBuckets.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClient.ListBuckets.cs @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System; using Google.Api.Gax; using Google.Apis.Storage.v1.Data; +using System; namespace Google.Cloud.Storage.V1 { diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs index 0291009bec05..e29679e82b21 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.GetBucket.cs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System.Threading; -using System.Threading.Tasks; using Google.Apis.Storage.v1; using Google.Apis.Storage.v1.Data; +using System.Threading; +using System.Threading.Tasks; namespace Google.Cloud.Storage.V1 { diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.ListBuckets.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.ListBuckets.cs index 6cc04c20c250..c0730e3b805a 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.ListBuckets.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.ListBuckets.cs @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System.Collections.Generic; using Google.Api.Gax; using Google.Api.Gax.Rest; using Google.Apis.Storage.v1; using Google.Apis.Storage.v1.Data; +using System.Collections.Generic; namespace Google.Cloud.Storage.V1 { diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs index 1993a5e08cdb..a236082f58ff 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.RestoreBucket.cs @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Google.Apis.Storage.v1; using System.Threading; using System.Threading.Tasks; -using Google.Apis.Storage.v1; using Bucket = Google.Apis.Storage.v1.Data.Bucket; namespace Google.Cloud.Storage.V1; From 748e762ac27b3e271aaedd7f8912d2b926bf587d Mon Sep 17 00:00:00 2001 From: Amanda Tarafa Mas <14878252+amanda-tarafa@users.noreply.github.com> Date: Tue, 4 Mar 2025 22:59:08 -0800 Subject: [PATCH 27/28] Apply suggestions from code review --- .../ListBucketsTest.cs | 46 ++++--------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs index 8bdf8b9b1e90..356c74e85297 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs @@ -79,44 +79,18 @@ public void PartialResponses() public async Task SoftDeletedOnly() { var bucketName = _fixture.GenerateBucketName(); - var softDeleteBucket = _fixture.CreateBucket( - bucketName, - multiVersion: false, - softDelete: true - ); - await _fixture.Client.DeleteBucketAsync( - softDeleteBucket.Name, - new DeleteBucketOptions { DeleteObjects = true } - ); - var actualBuckets = await _fixture - .Client.ListBucketsAsync( - _fixture.ProjectId, - new ListBucketsOptions { SoftDeletedOnly = true } - ) + var softDeleteBucket = _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: true); + + await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true }); + + var actualBuckets = await _fixture.Client + .ListBucketsAsync(_fixture.ProjectId, new ListBucketsOptions { SoftDeletedOnly = true }) .ToListAsync(); - var recentlyCreatedSoftDeleteBucket = actualBuckets - .Where(b => b.Name == softDeleteBucket.Name) - .ToList(); - Assert.Contains( - recentlyCreatedSoftDeleteBucket.First().Name.ToString(), - softDeleteBucket.Name.ToString() - ); - Assert.Contains( - recentlyCreatedSoftDeleteBucket.First().Generation.ToString(), - softDeleteBucket.Generation.ToString() - ); - Assert.NotNull(recentlyCreatedSoftDeleteBucket.First().SoftDeleteTimeDateTimeOffset); - Assert.NotNull(recentlyCreatedSoftDeleteBucket.First().HardDeleteTimeDateTimeOffset); - - if (actualBuckets.Count == 0) - { - Assert.Fail("Soft deleted bucket list is empty"); - } - else - { - Assert.All(actualBuckets, AssertSoftDeletedBucket); - } + // Check the list cotains the bucket we just soft-deleted. + Assert.Contains(actualBuckets, bucket => bucket.Name == softDeleteBucket.Name && bucket.Generation == softDeleteBucket.Generation); + // Check all the buckets in the list are soft-deleted buckets. + Assert.All(actualBuckets, AssertSoftDeletedBucket); } // Validating whether all buckets are soft-deleted only. From a955e02fdddbcf4cc8afd84b1758a2a6b920f19b Mon Sep 17 00:00:00 2001 From: Amanda Tarafa Mas <14878252+amanda-tarafa@users.noreply.github.com> Date: Tue, 4 Mar 2025 22:59:45 -0800 Subject: [PATCH 28/28] Update apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs --- .../Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs index 356c74e85297..db43f91829cb 100644 --- a/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs +++ b/apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs @@ -93,7 +93,7 @@ public async Task SoftDeletedOnly() Assert.All(actualBuckets, AssertSoftDeletedBucket); } - // Validating whether all buckets are soft-deleted only. + // Validates that the given bucket is soft-deleted. private void AssertSoftDeletedBucket(Bucket b) { Assert.NotNull(b.Generation);