Listing S3 user buckets via REST API
You can list all buckets in S3 with the ostor-buckets
service:
# s3_curl GET "http://s3.example.com/?ostor-buckets" { "Buckets": [ { "size": { "current": 12288, "h_integral": 7360512, "hmax": 12288, "last_ts": 424241 }, "epoch": 0, "owner_id": "ba7eba06129464c5", "name": "bucket1", "creation_date": "2018-05-25T17:12:00.000Z" }, { "size": { "current": 46700160, "h_integral": 28160196480, "hmax": 46700160, "last_ts": 424237 }, "epoch": 0, "owner_id": "ba7eba06129464c5", "name": "bucket2", "creation_date": "2018-05-25T13:51:55.000Z" }, { "size": { "current": 12288, "h_integral": 8036352, "hmax": 12288, "last_ts": 424186 }, "epoch": 0, "owner_id": "9d80d59edbe2862a", "name": "bucket3", "creation_date": "2018-05-23T10:30:49.000Z" } ]}
To list only the buckets that are owned by a particular S3 user, specify the user email address along with the request:
# s3_curl GET "http://s3.example.com/?ostor-buckets&emailAddress=user1@example.com" { "Buckets": [ { "size": { "current": 12288, "h_integral": 7360512, "hmax": 12288, "last_ts": 424241 }, "epoch": 0, "owner_id": "ba7eba06129464c5", "name": "bucket1", "creation_date": "2018-05-25T17:12:00.000Z" }, { "size": { "current": 46700160, "h_integral": 28160196480, "hmax": 46700160, "last_ts": 424237 }, "epoch": 0, "owner_id": "ba7eba06129464c5", "name": "bucket2", "creation_date": "2018-05-25T13:51:55.000Z" } ]}
To list only specific buckets, specify their names in the request body. To do this, create a JSON file with a list of bucket names, and then pass it to the ostor-buckets
service with the multi
parameter:
# cat > buckets.json <<\EOT ["bucket2", "bucket3"] EOT # s3_curl GET "http://s3.example.com/?ostor-buckets&multi" buckets.json { "Buckets": [ { "size": { "current": 46700160, "h_integral": 28160196480, "hmax": 46700160, "last_ts": 424237 }, "epoch": 0, "owner_id": "ba7eba06129464c5", "name": "bucket2", "creation_date": "2018-05-25T13:51:55.000Z" }, { "size": { "current": 12288, "h_integral": 8036352, "hmax": 12288, "last_ts": 424186 }, "epoch": 0, "owner_id": "9d80d59edbe2862a", "name": "bucket3", "creation_date": "2018-05-23T10:30:49.000Z" } ]}