|
30 | 30 | import static com.adobe.testing.s3mock.util.AwsHttpParameters.NOT_LOCATION;
|
31 | 31 | import static com.adobe.testing.s3mock.util.AwsHttpParameters.NOT_OBJECT_LOCK;
|
32 | 32 | import static com.adobe.testing.s3mock.util.AwsHttpParameters.NOT_UPLOADS;
|
| 33 | +import static com.adobe.testing.s3mock.util.AwsHttpParameters.NOT_VERSIONING; |
33 | 34 | import static com.adobe.testing.s3mock.util.AwsHttpParameters.NOT_VERSIONS;
|
34 | 35 | import static com.adobe.testing.s3mock.util.AwsHttpParameters.OBJECT_LOCK;
|
35 | 36 | import static com.adobe.testing.s3mock.util.AwsHttpParameters.START_AFTER;
|
| 37 | +import static com.adobe.testing.s3mock.util.AwsHttpParameters.VERSIONING; |
36 | 38 | import static com.adobe.testing.s3mock.util.AwsHttpParameters.VERSIONS;
|
37 | 39 | import static com.adobe.testing.s3mock.util.AwsHttpParameters.VERSION_ID_MARKER;
|
38 | 40 | import static org.springframework.http.MediaType.APPLICATION_XML_VALUE;
|
|
44 | 46 | import com.adobe.testing.s3mock.dto.ListVersionsResult;
|
45 | 47 | import com.adobe.testing.s3mock.dto.LocationConstraint;
|
46 | 48 | import com.adobe.testing.s3mock.dto.ObjectLockConfiguration;
|
| 49 | +import com.adobe.testing.s3mock.dto.VersioningConfiguration; |
47 | 50 | import com.adobe.testing.s3mock.service.BucketService;
|
48 | 51 | import org.springframework.http.ResponseEntity;
|
49 | 52 | import org.springframework.stereotype.Controller;
|
@@ -116,7 +119,8 @@ public ResponseEntity<ListAllMyBucketsResult> listBuckets() {
|
116 | 119 | },
|
117 | 120 | params = {
|
118 | 121 | NOT_OBJECT_LOCK,
|
119 |
| - NOT_LIFECYCLE |
| 122 | + NOT_LIFECYCLE, |
| 123 | + NOT_VERSIONING |
120 | 124 | }
|
121 | 125 | )
|
122 | 126 | public ResponseEntity<Void> createBucket(@PathVariable final String bucketName,
|
@@ -180,6 +184,62 @@ public ResponseEntity<Void> deleteBucket(@PathVariable String bucketName) {
|
180 | 184 | return ResponseEntity.noContent().build();
|
181 | 185 | }
|
182 | 186 |
|
| 187 | + /** |
| 188 | + * Get VersioningConfiguration of a bucket. |
| 189 | + * <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketVersioning.html">API Reference</a> |
| 190 | + * |
| 191 | + * @param bucketName name of the Bucket. |
| 192 | + * |
| 193 | + * @return 200, VersioningConfiguration |
| 194 | + */ |
| 195 | + @GetMapping( |
| 196 | + value = { |
| 197 | + //AWS SDK V2 pattern |
| 198 | + "/{bucketName:.+}", |
| 199 | + //AWS SDK V1 pattern |
| 200 | + "/{bucketName:.+}/" |
| 201 | + }, |
| 202 | + params = { |
| 203 | + VERSIONING, |
| 204 | + NOT_LIST_TYPE |
| 205 | + }, |
| 206 | + produces = APPLICATION_XML_VALUE |
| 207 | + ) |
| 208 | + public ResponseEntity<VersioningConfiguration> getVersioningConfiguration( |
| 209 | + @PathVariable String bucketName) { |
| 210 | + bucketService.verifyBucketExists(bucketName); |
| 211 | + var configuration = bucketService.getVersioningConfiguration(bucketName); |
| 212 | + return ResponseEntity.ok(configuration); |
| 213 | + } |
| 214 | + |
| 215 | + /** |
| 216 | + * Put VersioningConfiguration of a bucket. |
| 217 | + * <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketVersioning.html">API Reference</a> |
| 218 | + * |
| 219 | + * @param bucketName name of the Bucket. |
| 220 | + * |
| 221 | + * @return 200 |
| 222 | + */ |
| 223 | + @PutMapping( |
| 224 | + value = { |
| 225 | + //AWS SDK V2 pattern |
| 226 | + "/{bucketName:.+}", |
| 227 | + //AWS SDK V1 pattern |
| 228 | + "/{bucketName:.+}/" |
| 229 | + }, |
| 230 | + params = { |
| 231 | + VERSIONING |
| 232 | + }, |
| 233 | + consumes = APPLICATION_XML_VALUE |
| 234 | + ) |
| 235 | + public ResponseEntity<Void> putVersioningConfiguration( |
| 236 | + @PathVariable String bucketName, |
| 237 | + @RequestBody VersioningConfiguration configuration) { |
| 238 | + bucketService.verifyBucketExists(bucketName); |
| 239 | + bucketService.setVersioningConfiguration(bucketName, configuration); |
| 240 | + return ResponseEntity.ok().build(); |
| 241 | + } |
| 242 | + |
183 | 243 | /**
|
184 | 244 | * Get ObjectLockConfiguration of a bucket.
|
185 | 245 | * <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectLockConfiguration.html">API Reference</a>
|
@@ -362,7 +422,8 @@ public ResponseEntity<LocationConstraint> getBucketLocation(
|
362 | 422 | NOT_LIST_TYPE,
|
363 | 423 | NOT_LIFECYCLE,
|
364 | 424 | NOT_LOCATION,
|
365 |
| - NOT_VERSIONS |
| 425 | + NOT_VERSIONS, |
| 426 | + NOT_VERSIONING |
366 | 427 | },
|
367 | 428 | produces = APPLICATION_XML_VALUE
|
368 | 429 | )
|
|
0 commit comments