swift_client 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -18,6 +18,39 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install swift_client
20
20
 
21
+ ## Usage
22
+
23
+ First, connect to a Swift cluster:
24
+
25
+ ```ruby
26
+ swift_client = SwiftClient.new(:auth_url => "https://example.com/auth/v1.0", :username => "account:username", :api_key => "secret api key", :temp_url_key => "optional temp url key")
27
+ ```
28
+
29
+ SwiftClient will automatically reconnect in case the endpoint responds with 401
30
+ Unauthorized to one of your requests using the provided credentials.
31
+ Otherwise, i.e. in case the endpoint does not respond with 2xx to any of
32
+ SwiftClient's requests, SwiftClient will raise a `SwiftClient::ResponseError`.
33
+
34
+ SwiftClient offers the following requests:
35
+
36
+ * head_account -> HTTParty::Response
37
+ * post_account(headers = {}) -> HTTParty::Response
38
+ * head_containers -> HTTParty::Response
39
+ * get_containers(query = {}) -> HTTParty::Response
40
+ * get_container(container, query = {}) -> HTTParty::Response
41
+ * head_container(container) -> HTTParty::Response
42
+ * put_container(container, headers = {}) -> HTTParty::Response
43
+ * post_container(container, headers = {}) -> HTTParty::Response
44
+ * delete_container(container) -> HTTParty::Response
45
+ * put_object(object, data_or_io, container, headers = {}) -> HTTParty::Response
46
+ * post_object(object, container, headers = {}) -> HTTParty::Response
47
+ * get_object(object, container) -> HTTParty::Response
48
+ * head_object(object, container) -> HTTParty::Response
49
+ * delete_object(object, container) -> HTTParty::Response
50
+ * get_objects(container, query = {}) -> HTTParty::Response
51
+ * public_url(object, container) -> HTTParty::Response
52
+ * temp_url(object, container) -> HTTParty::Response
53
+
21
54
  ## Contributing
22
55
 
23
56
  1. Fork it ( https://github.com/mrkamel/swift_client/fork )
data/lib/swift_client.rb CHANGED
@@ -36,10 +36,18 @@ class SwiftClient
36
36
  authenticate
37
37
  end
38
38
 
39
+ def head_account
40
+ request :head, "/"
41
+ end
42
+
39
43
  def post_account(headers = {})
40
44
  request :post, "/", :headers => headers
41
45
  end
42
46
 
47
+ def head_containers
48
+ request :head, "/"
49
+ end
50
+
43
51
  def get_containers(query = {})
44
52
  request :get, "/", :query => query
45
53
  end
@@ -1,5 +1,5 @@
1
1
 
2
2
  class SwiftClient
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
 
@@ -20,12 +20,24 @@ class SwiftClientTest < MiniTest::Test
20
20
  assert_equal "https://storage-url.com/path", @swift_client.storage_url
21
21
  end
22
22
 
23
+ def test_head_account
24
+ stub_request(:head, "https://example.com/v1/AUTH_account/").with(:headers => { "Accept" => "application/json", "X-Auth-Token" => "Token" }).to_return(:status => 204, :body => "", :headers => { "Content-Type" => "application/json" })
25
+
26
+ assert 204, @swift_client.head_account.code
27
+ end
28
+
23
29
  def test_post_account
24
30
  stub_request(:post, "https://example.com/v1/AUTH_account/").with(:headers => { "Accept" => "application/json", "X-Auth-Token" => "Token", "X-Account-Meta-Test" => "Test" }).to_return(:status => 204, :body => "", :headers => { "Content-Type" => "application/json" })
25
31
 
26
32
  assert_equal 204, @swift_client.post_account("X-Account-Meta-Test" => "Test").code
27
33
  end
28
34
 
35
+ def test_head_containers
36
+ stub_request(:head, "https://example.com/v1/AUTH_account/").with(:headers => { "Accept" => "application/json", "X-Auth-Token" => "Token" }).to_return(:status => 204, :body => "", :headers => { "Content-Type" => "application/json" })
37
+
38
+ assert 204, @swift_client.head_containers.code
39
+ end
40
+
29
41
  def test_get_containers
30
42
  containers = [
31
43
  { "count" => 1, "bytes" => 1, "name" => "container-1" },
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swift_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-19 00:00:00.000000000 Z
12
+ date: 2014-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty