Skip to content

Commit

Permalink
adds Client#delete_bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorfinnell committed Jan 5, 2018
1 parent 12e50c6 commit 9b6478c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions spec/awscr-s3/client_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ module Awscr::S3
end
end

describe "delete_bucket" do
it "returns true when buckest is deleted" do
WebMock.stub(:delete, "http://s3.amazonaws.com/bucket")
.to_return(body: "", status: 204)

client = Client.new("us-east-1", "key", "secret")
result = client.delete_bucket("bucket")

result.should be_true
end
end

describe "abort_multipart_upload" do
it "aborts an upload" do
WebMock.stub(:delete, "http://s3.amazonaws.com/bucket/object?uploadId=upload_id")
Expand Down
13 changes: 13 additions & 0 deletions src/awscr-s3/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ module Awscr::S3
resp.status_code == 200
end

# Delete a bucket, note: it must be empty
#
# ```
# client = Client.new("region", "key", "secret")
# resp = client.delete_bucket("test")
# p resp # => true
# ```
def delete_bucket(bucket)
resp = http.delete("/#{bucket}")

resp.status_code == 204
end

# Start a multipart upload
#
# ```
Expand Down

0 comments on commit 9b6478c

Please sign in to comment.