Class BucketController

java.lang.Object
com.adobe.testing.s3mock.BucketController

@CrossOrigin(origins="*", exposedHeaders="*") @Controller @RequestMapping("${com.adobe.testing.s3mock.contextPath:}") public class BucketController extends Object
Handles requests related to buckets.
  • Constructor Details

    • BucketController

      public BucketController(BucketService bucketService, software.amazon.awssdk.regions.Region region)
  • Method Details

    • listBuckets

      @GetMapping(value="/", produces="application/xml") public org.springframework.http.ResponseEntity<ListAllMyBucketsResult> listBuckets()
      List all existing buckets. API Reference
      Returns:
      List of all Buckets
    • createBucket

      @PutMapping(value={"/{bucketName:.+}","/{bucketName:.+}/"}, params={"!object-lock","!lifecycle"}) public org.springframework.http.ResponseEntity<Void> createBucket(@PathVariable String bucketName, @RequestHeader(value="x-amz-bucket-object-lock-enabled",required=false,defaultValue="false") boolean objectLockEnabled)
      Create a bucket if the name matches a simplified version of the bucket naming rules. API Reference Bucket Naming API Reference
      Parameters:
      bucketName - name of the bucket that should be created.
      Returns:
      200 OK if creation was successful.
    • headBucket

      @RequestMapping(value={"/{bucketName:.+}","/{bucketName:.+}/"}, method=HEAD) public org.springframework.http.ResponseEntity<Void> headBucket(@PathVariable String bucketName)
      Check if a bucket exists. API Reference
      Parameters:
      bucketName - name of the Bucket.
      Returns:
      200 if it exists; 404 if not found.
    • deleteBucket

      @DeleteMapping(value={"/{bucketName:.+}","/{bucketName:.+}/"}, params="!lifecycle") public org.springframework.http.ResponseEntity<Void> deleteBucket(@PathVariable String bucketName)
      Delete a bucket. API Reference
      Parameters:
      bucketName - name of the Bucket.
      Returns:
      204 if Bucket was deleted; 404 if not found
    • getObjectLockConfiguration

      @GetMapping(value={"/{bucketName:.+}","/{bucketName:.+}/"}, params={"object-lock","!list-type"}, produces="application/xml") public org.springframework.http.ResponseEntity<ObjectLockConfiguration> getObjectLockConfiguration(@PathVariable String bucketName)
      Get ObjectLockConfiguration of a bucket. API Reference
      Parameters:
      bucketName - name of the Bucket.
      Returns:
      200, ObjectLockConfiguration
    • putObjectLockConfiguration

      @PutMapping(value={"/{bucketName:.+}","/{bucketName:.+}/"}, params="object-lock", consumes="application/xml") public org.springframework.http.ResponseEntity<Void> putObjectLockConfiguration(@PathVariable String bucketName, @RequestBody ObjectLockConfiguration configuration)
      Put ObjectLockConfiguration of a bucket. API Reference
      Parameters:
      bucketName - name of the Bucket.
      Returns:
      200, ObjectLockConfiguration
    • getBucketLifecycleConfiguration

      @GetMapping(value={"/{bucketName:.+}","/{bucketName:.+}/"}, params={"lifecycle","!list-type"}, produces="application/xml") public org.springframework.http.ResponseEntity<BucketLifecycleConfiguration> getBucketLifecycleConfiguration(@PathVariable String bucketName)
      Get BucketLifecycleConfiguration of a bucket. API Reference
      Parameters:
      bucketName - name of the Bucket.
      Returns:
      200, ObjectLockConfiguration
    • putBucketLifecycleConfiguration

      @PutMapping(value={"/{bucketName:.+}","/{bucketName:.+}/"}, params="lifecycle", consumes="application/xml") public org.springframework.http.ResponseEntity<Void> putBucketLifecycleConfiguration(@PathVariable String bucketName, @RequestBody BucketLifecycleConfiguration configuration)
      Put BucketLifecycleConfiguration of a bucket. API Reference
      Parameters:
      bucketName - name of the Bucket.
      Returns:
      200, ObjectLockConfiguration
    • deleteBucketLifecycleConfiguration

      @DeleteMapping(value={"/{bucketName:.+}","/{bucketName:.+}/"}, params="lifecycle") public org.springframework.http.ResponseEntity<Void> deleteBucketLifecycleConfiguration(@PathVariable String bucketName)
      Delete BucketLifecycleConfiguration of a bucket. API Reference
      Parameters:
      bucketName - name of the Bucket.
      Returns:
      200, ObjectLockConfiguration
    • getBucketLocation

      @GetMapping(value="/{bucketName:.+}", params="location") public org.springframework.http.ResponseEntity<LocationConstraint> getBucketLocation(@PathVariable String bucketName)
      Get location of a bucket. API Reference
      Parameters:
      bucketName - name of the Bucket.
      Returns:
      200, LocationConstraint
    • listObjects

      @GetMapping(value={"/{bucketName:.+}","/{bucketName:.+}/"}, params={"!uploads","!object-lock","!list-type","!lifecycle","!location","!versions"}, produces="application/xml") @Deprecated(since="2.12.2", forRemoval=true) public org.springframework.http.ResponseEntity<ListBucketResult> listObjects(@PathVariable String bucketName, @RequestParam(required=false) String prefix, @RequestParam(required=false) String delimiter, @RequestParam(required=false) String marker, @RequestParam(name="encoding-type",required=false) String encodingType, @RequestParam(name="max-keys",defaultValue="1000",required=false) Integer maxKeys)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Long since replaced by ListObjectsV2,
      Retrieve list of objects of a bucket. API Reference
      Parameters:
      bucketName - String set bucket name
      prefix - String find object names they start with prefix
      encodingType - whether to use URL encoding (encodingtype="url") or not
      Returns:
      ListBucketResult a list of objects in Bucket
    • listObjectsV2

      @GetMapping(value={"/{bucketName:.+}","/{bucketName:.+}/"}, params="list-type=2", produces="application/xml") public org.springframework.http.ResponseEntity<ListBucketResultV2> listObjectsV2(@PathVariable String bucketName, @RequestParam(required=false) String prefix, @RequestParam(required=false) String delimiter, @RequestParam(name="encoding-type",required=false) String encodingType, @RequestParam(name="start-after",required=false) String startAfter, @RequestParam(name="max-keys",defaultValue="1000",required=false) Integer maxKeys, @RequestParam(name="continuation-token",required=false) String continuationToken)
      Retrieve list of objects of a bucket. API Reference
      Parameters:
      bucketName - String set bucket name
      prefix - String find object names they start with prefix
      startAfter - String return key names after a specific object key in your key space
      maxKeys - Integer set maximum number of keys to be returned
      continuationToken - String pagination token returned by previous request
      Returns:
      ListBucketResultV2 a list of objects in Bucket
    • listObjectVersions

      @GetMapping(value={"/{bucketName:.+}","/{bucketName:.+}/"}, params="versions", produces="application/xml") public org.springframework.http.ResponseEntity<ListVersionsResult> listObjectVersions(@PathVariable String bucketName, @RequestParam(required=false) String prefix, @RequestParam(required=false) String delimiter, @RequestParam(name="key-marker",required=false) String keyMarker, @RequestParam(name="version-id-marker",required=false) String versionIdMarker, @RequestParam(name="encoding-type",required=false) String encodingType, @RequestParam(name="start-after",required=false) String startAfter, @RequestParam(name="max-keys",defaultValue="1000",required=false) Integer maxKeys, @RequestParam(name="continuation-token",required=false) String continuationToken)
      Retrieve list of versions of an object of a bucket. API Reference
      Parameters:
      bucketName - String set bucket name
      prefix - String find object names they start with prefix
      startAfter - String return key names after a specific object key in your key space
      maxKeys - Integer set maximum number of keys to be returned
      continuationToken - String pagination token returned by previous request
      Returns:
      ListVersionsResult a list of objects in Bucket