Skip to content

Commit 6d20fd3

Browse files
committed
feat: Support object retention
Closes googleapis#11227 Closes googleapis#11368
1 parent 02915a5 commit 6d20fd3

File tree

6 files changed

+41
-3
lines changed

6 files changed

+41
-3
lines changed

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/CreateBucketOptionsTest.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public void ModifyRequest_DefaultOptions()
2929
Assert.Null(request.PredefinedAcl);
3030
Assert.Null(request.PredefinedDefaultObjectAcl);
3131
Assert.Null(request.Projection);
32+
Assert.Null(request.EnableObjectRetention);
3233
}
3334

3435
[Fact]
@@ -39,12 +40,14 @@ public void ModifyRequest_AllOptions()
3940
{
4041
PredefinedAcl = PredefinedBucketAcl.AuthenticatedRead,
4142
PredefinedDefaultObjectAcl = PredefinedObjectAcl.BucketOwnerFullControl,
42-
Projection = Projection.Full
43+
Projection = Projection.Full,
44+
ObjectRetentionEnabled = true,
4345
};
4446
options.ModifyRequest(request);
4547
Assert.Equal(PredefinedAclEnum.AuthenticatedRead, request.PredefinedAcl);
4648
Assert.Equal(PredefinedDefaultObjectAclEnum.BucketOwnerFullControl, request.PredefinedDefaultObjectAcl);
4749
Assert.Equal(ProjectionEnum.Full, request.Projection);
50+
Assert.True(request.EnableObjectRetention);
4851
}
4952
}
5053
}

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/PatchObjectOptionsTest.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public void ModifyRequest_DefaultOptions()
3535
Assert.Null(request.PredefinedAcl);
3636
Assert.Null(request.Projection);
3737
Assert.Null(request.UserProject);
38+
Assert.Null(request.OverrideUnlockedRetention);
3839
}
3940

4041
[Fact]
@@ -48,7 +49,8 @@ public void ModifyRequest_PositiveMatchOptions()
4849
IfMetagenerationMatch = 3L,
4950
PredefinedAcl = PredefinedObjectAcl.AuthenticatedRead,
5051
Projection = Projection.Full,
51-
UserProject = "proj"
52+
UserProject = "proj",
53+
OverrideUnlockedRetention = true,
5254
};
5355
options.ModifyRequest(request);
5456
Assert.Equal(1L, request.Generation);
@@ -59,6 +61,7 @@ public void ModifyRequest_PositiveMatchOptions()
5961
Assert.Equal(PredefinedAclEnum.AuthenticatedRead, request.PredefinedAcl);
6062
Assert.Equal(ProjectionEnum.Full, request.Projection);
6163
Assert.Equal("proj", request.UserProject);
64+
Assert.True(request.OverrideUnlockedRetention);
6265
}
6366

6467
[Fact]

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/UpdateObjectOptionsTest.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public void ModifyRequest_DefaultOptions()
3737
Assert.Null(request.PredefinedAcl);
3838
Assert.Null(request.Projection);
3939
Assert.Null(request.UserProject);
40+
Assert.Null(request.OverrideUnlockedRetention);
4041
}
4142

4243
[Fact]
@@ -67,7 +68,8 @@ public void ModifyRequest_PositiveMatchOptions()
6768
IfMetagenerationMatch = 3L,
6869
PredefinedAcl = PredefinedObjectAcl.AuthenticatedRead,
6970
Projection = Projection.Full,
70-
UserProject = "proj"
71+
UserProject = "proj",
72+
OverrideUnlockedRetention = true,
7173
};
7274
options.ModifyRequest(request, obj);
7375
Assert.Equal(1L, request.Generation);
@@ -78,6 +80,7 @@ public void ModifyRequest_PositiveMatchOptions()
7880
Assert.Equal(PredefinedAclEnum.AuthenticatedRead, request.PredefinedAcl);
7981
Assert.Equal(ProjectionEnum.Full, request.Projection);
8082
Assert.Equal("proj", request.UserProject);
83+
Assert.True(request.OverrideUnlockedRetention);
8184
}
8285

8386
[Fact]

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/CreateBucketOptions.cs

+9
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public sealed class CreateBucketOptions
3838
/// </summary>
3939
public Projection? Projection { get; set; }
4040

41+
/// <summary>
42+
/// When set to true, permanently enable object retention for this bucket.
43+
/// </summary>
44+
public bool? ObjectRetentionEnabled { get; set; }
45+
4146
/// <summary>
4247
/// Options to pass custom retry configuration for each API request.
4348
/// </summary>
@@ -59,6 +64,10 @@ internal void ModifyRequest(BucketsResource.InsertRequest request)
5964
{
6065
request.Projection = GaxPreconditions.CheckEnumValue((ProjectionEnum) Projection, nameof(Projection));
6166
}
67+
if (ObjectRetentionEnabled.HasValue)
68+
{
69+
request.EnableObjectRetention = ObjectRetentionEnabled.Value;
70+
}
6271
}
6372
}
6473
}

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/PatchObjectOptions.cs

+10
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ public sealed class PatchObjectOptions
7575
/// </summary>
7676
public string UserProject { get; set; }
7777

78+
/// <summary>
79+
/// Must be true to remove the retention configuration, reduce its unlocked retention period, or change its
80+
/// mode from unlocked to locked.
81+
/// </summary>
82+
public bool? OverrideUnlockedRetention { get; set; }
83+
7884
/// <summary>
7985
/// Options to pass custom retry configuration for each API request.
8086
/// </summary>
@@ -126,6 +132,10 @@ internal void ModifyRequest(PatchRequest request)
126132
{
127133
request.UserProject = UserProject;
128134
}
135+
if (OverrideUnlockedRetention.HasValue)
136+
{
137+
request.OverrideUnlockedRetention = OverrideUnlockedRetention.Value;
138+
}
129139
}
130140
}
131141
}

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/UpdateObjectOptions.cs

+10
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ public sealed class UpdateObjectOptions
8383
/// </summary>
8484
public string UserProject { get; set; }
8585

86+
/// <summary>
87+
/// Must be true to remove the retention configuration, reduce its unlocked retention period, or change its
88+
/// mode from unlocked to locked.
89+
/// </summary>
90+
public bool? OverrideUnlockedRetention { get; set; }
91+
8692
/// <summary>
8793
/// Options to pass custom retry configuration for each API request.
8894
/// </summary>
@@ -149,6 +155,10 @@ internal void ModifyRequest(UpdateRequest request, Object obj)
149155
{
150156
request.UserProject = UserProject;
151157
}
158+
if (OverrideUnlockedRetention.HasValue)
159+
{
160+
request.OverrideUnlockedRetention = OverrideUnlockedRetention.Value;
161+
}
152162
}
153163
}
154164
}

0 commit comments

Comments
 (0)