tutum 0.2.3 → 0.2.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a78bd77cac2157ce3d289b2b5e9ec2091675d4f
4
- data.tar.gz: fff8f4a56856405397b9a48ea35705443a370a45
3
+ metadata.gz: eb4f306b8b85406bc8c2357375a12287cfbfbfc1
4
+ data.tar.gz: f7c627785f0290b77e1610dca0b071c00679d6e1
5
5
  SHA512:
6
- metadata.gz: 88f4959d2bd96abe0c72a4a3caf9eb1bd66a12abfb4e632c147abb5190dccf14718aa2b01648cea9c458ea7d394e1165065a5e602793aace28b1409840cc1474
7
- data.tar.gz: 58041d025c910af93b030f96e0e53a55481809c1f74477731e78f74424bf3258a149a58e6f60189b048c1e5ee3316a2d1e23fd8afdccbc6c7e434bf1ef04c4c5
6
+ metadata.gz: c904fbc72d92c9f44d925bd63da23188fac0ce1c43bdbe590e185236eadb544287d101eac9b2f927fd5761bf5947b7bbaa17299a104e8d0649f77b742af22405
7
+ data.tar.gz: e88057f3342dc052c647b052da33a28046fe75f4945e4197b3644248e36dad2d4a173716dfacfc91824a150fd6ecc53d8ae491f7f519dc923ef3f0d2a4237f1c
@@ -1,20 +1,17 @@
1
1
  require_relative './tutum_api'
2
2
 
3
-
4
3
  require_relative './tutum_actions'
5
4
  require_relative './tutum_containers'
6
5
  require_relative './tutum_node_clusters'
7
- require_relative './tutum_images'
8
- require_relative './tutum_node_clusters'
9
6
  require_relative './tutum_node_types'
10
7
  require_relative './tutum_nodes'
11
8
  require_relative './tutum_providers'
12
9
  require_relative './tutum_regions'
13
10
  require_relative './tutum_services'
14
- require_relative './tutum_error'
15
11
 
16
12
  class Tutum
17
13
  attr_reader :username, :api_key
14
+
18
15
  def initialize(username, api_key)
19
16
  @username = username
20
17
  @api_key = api_key
@@ -22,9 +19,9 @@ class Tutum
22
19
 
23
20
  def headers
24
21
  {
25
- "Authorization" => "ApiKey #{@username}:#{@api_key}",
26
- "Accept" => "application/json",
27
- "Content-Type" => "application/json"
22
+ 'Authorization' => "ApiKey #{@username}:#{@api_key}",
23
+ 'Accept' => 'application/json',
24
+ 'Content-Type' => 'application/json'
28
25
  }
29
26
  end
30
27
 
@@ -59,5 +56,4 @@ class Tutum
59
56
  def services
60
57
  @services ||= TutumServices.new(headers)
61
58
  end
62
-
63
59
  end
@@ -1,49 +1,39 @@
1
- require 'httparty'
1
+ require 'rest-client'
2
+
2
3
  class TutumApi
3
4
  attr_reader :headers
4
- BASE_API_PATH = "https://dashboard.tutum.co/api"
5
- API_VERSION = "v1"
5
+
6
+ BASE_API_PATH = 'https://dashboard.tutum.co/api'
7
+ API_VERSION = 'v1'
8
+
6
9
  def initialize(headers)
7
10
  @headers = headers
8
11
  end
9
- def http_headers
10
- { headers: headers }
11
- end
12
- def api_path(path)
13
- BASE_API_PATH+"/"+API_VERSION + path
14
- end
15
12
 
16
-
17
- def expect_20x(path, &block)
18
- response = block.call
19
- if(response.code/10 != 20)
20
- msg = response.inspect
21
- if(response.parsed_response)
22
- msg = response.parsed_response.inspect
23
- end
24
- raise TutumError.new("#{response.code} received for API call to #{path}: #{msg}")
25
- end
26
- response
13
+ def url(path)
14
+ BASE_API_PATH + '/' + API_VERSION + path
27
15
  end
28
16
 
29
- def http_get(path, args={})
30
- expect_20x(path) do
31
- HTTParty.get(api_path(path), http_headers.merge({ :query => args }))
32
- end
17
+ def http_get(path, params={})
18
+ query = "?" + params.map { |k,v| "#{k}=#{v}"}.join("&")
19
+ full_path = path
20
+ full_path += query unless params.empty?
21
+ response = RestClient.get(url(path), headers)
22
+ JSON.parse(response)
33
23
  end
34
- def http_post(path, args={})
35
- expect_20x(path) do
36
- HTTParty.post(api_path(path), http_headers.merge({ :body => args.to_json }))
37
- end
24
+
25
+ def http_post(path, content={})
26
+ response = RestClient.post(url(path), content.to_json, headers)
27
+ JSON.parse(response)
38
28
  end
39
- def http_patch(path, args={})
40
- expect_20x(path) do
41
- HTTParty.patch(api_path(path), http_headers.merge({ :body => args.to_json }))
42
- end
29
+
30
+ def http_patch(path, content={})
31
+ response = RestClient.patch(url(path), content.to_json, headers)
32
+ JSON.parse(response)
43
33
  end
44
- def http_delete(path, args={})
45
- expect_20x(path) do
46
- HTTParty.delete(api_path(path), http_headers.merge({ :query => args }))
47
- end
34
+
35
+ def http_delete(path)
36
+ response = RestClient.delete(url(path), headers)
37
+ JSON.parse(response)
48
38
  end
49
39
  end
@@ -3,7 +3,7 @@ class TutumContainers < TutumApi
3
3
  "/container/"
4
4
  end
5
5
 
6
- def list(params)
6
+ def list(params={})
7
7
  http_get(list_url, params)
8
8
  end
9
9
 
@@ -3,7 +3,7 @@ class TutumNodeClusters < TutumApi
3
3
  "/nodecluster/"
4
4
  end
5
5
 
6
- def list(params)
6
+ def list(params={})
7
7
  http_get(list_url, params)
8
8
  end
9
9
 
@@ -26,7 +26,7 @@ class TutumNodeClusters < TutumApi
26
26
  def update_url(uuid)
27
27
  "/nodecluster/#{uuid}/"
28
28
  end
29
-
29
+
30
30
  def update(uuid, params)
31
31
  http_patch(update_url(uuid), params)
32
32
  end
@@ -34,7 +34,7 @@ class TutumNodeClusters < TutumApi
34
34
  def deploy_url(uuid)
35
35
  "/nodecluster/#{uuid}/deploy/"
36
36
  end
37
-
37
+
38
38
  def deploy(uuid)
39
39
  http_post(deploy_url(uuid))
40
40
  end
@@ -46,5 +46,5 @@ class TutumNodeClusters < TutumApi
46
46
  def terminate(uuid)
47
47
  http_delete(terminate_url(uuid))
48
48
  end
49
-
50
49
  end
50
+
@@ -3,8 +3,8 @@ class TutumNodeTypes < TutumApi
3
3
  "/nodetype/"
4
4
  end
5
5
 
6
- def list
7
- http_get(list_url)
6
+ def list(params={})
7
+ http_get(list_url, params)
8
8
  end
9
9
 
10
10
  def get_url(uuid)
@@ -14,5 +14,4 @@ class TutumNodeTypes < TutumApi
14
14
  def get(uuid)
15
15
  http_get(get_url(uuid))
16
16
  end
17
-
18
17
  end
@@ -3,7 +3,7 @@ class TutumNodes < TutumApi
3
3
  "/node/"
4
4
  end
5
5
 
6
- def list(params)
6
+ def list(params={})
7
7
  http_get(list_url, params)
8
8
  end
9
9
 
@@ -18,9 +18,9 @@ class TutumNodes < TutumApi
18
18
  def deploy_url(uuid)
19
19
  "/node/#{uuid}/deploy/"
20
20
  end
21
-
22
- def deploy(uuid, params)
23
- http_post(deploy_url(uuid), params)
21
+
22
+ def deploy(uuid)
23
+ http_post(deploy_url(uuid))
24
24
  end
25
25
 
26
26
  def terminate_url(uuid)
@@ -30,5 +30,4 @@ class TutumNodes < TutumApi
30
30
  def terminate(uuid)
31
31
  http_delete(terminate_url(uuid))
32
32
  end
33
-
34
33
  end
@@ -3,7 +3,7 @@ class TutumProviders < TutumApi
3
3
  "/provider/"
4
4
  end
5
5
 
6
- def list(params)
6
+ def list(params={})
7
7
  http_get(list_url, params)
8
8
  end
9
9
 
@@ -14,5 +14,4 @@ class TutumProviders < TutumApi
14
14
  def get(uuid)
15
15
  http_get(get_url(uuid))
16
16
  end
17
-
18
17
  end
@@ -3,7 +3,7 @@ class TutumRegions < TutumApi
3
3
  "/region/"
4
4
  end
5
5
 
6
- def list(params)
6
+ def list(params={})
7
7
  http_get(list_url, params)
8
8
  end
9
9
 
@@ -14,5 +14,4 @@ class TutumRegions < TutumApi
14
14
  def get(uuid)
15
15
  http_get(get_url(uuid))
16
16
  end
17
-
18
17
  end
@@ -3,7 +3,7 @@ class TutumServices < TutumApi
3
3
  "/service/"
4
4
  end
5
5
 
6
- def list(params)
6
+ def list(params={})
7
7
  http_get(list_url, params)
8
8
  end
9
9
 
@@ -34,7 +34,7 @@ class TutumServices < TutumApi
34
34
  def update_url(uuid)
35
35
  "/service/#{uuid}/"
36
36
  end
37
-
37
+
38
38
  def update(uuid, params)
39
39
  http_patch(update_url(uuid), params)
40
40
  end
@@ -42,7 +42,7 @@ class TutumServices < TutumApi
42
42
  def start_url(uuid)
43
43
  "/service/#{uuid}/start/"
44
44
  end
45
-
45
+
46
46
  def start(uuid)
47
47
  http_post(start_url(uuid))
48
48
  end
@@ -50,18 +50,17 @@ class TutumServices < TutumApi
50
50
  def stop_url(uuid)
51
51
  "/service/#{uuid}/stop/"
52
52
  end
53
-
53
+
54
54
  def stop(uuid)
55
55
  http_post(stop_url(uuid))
56
56
  end
57
57
 
58
-
59
58
  def redeploy_url(uuid)
60
59
  "/service/#{uuid}/redeploy/"
61
60
  end
62
-
63
- def redeploy(uuid, params)
64
- http_post(redeploy_url(uuid), params)
61
+
62
+ def redeploy(uuid)
63
+ http_post(redeploy_url(uuid))
65
64
  end
66
65
 
67
66
  def terminate_url(uuid)
@@ -71,5 +70,4 @@ class TutumServices < TutumApi
71
70
  def terminate(uuid)
72
71
  http_delete(terminate_url(uuid))
73
72
  end
74
-
75
73
  end
metadata CHANGED
@@ -1,32 +1,120 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tutum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
+ - Josie Wright
7
8
  - Martyn Garcia
8
9
  - Mikkel Garcia
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-08-06 00:00:00.000000000 Z
13
+ date: 2014-11-04 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
- name: httparty
16
+ name: rest-client
16
17
  requirement: !ruby/object:Gem::Requirement
17
18
  requirements:
18
19
  - - ~>
19
20
  - !ruby/object:Gem::Version
20
- version: 0.13.1
21
+ version: 1.7.2
21
22
  type: :runtime
22
23
  prerelease: false
23
24
  version_requirements: !ruby/object:Gem::Requirement
24
25
  requirements:
25
26
  - - ~>
26
27
  - !ruby/object:Gem::Version
27
- version: 0.13.1
28
+ version: 1.7.2
29
+ - !ruby/object:Gem::Dependency
30
+ name: json
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: 1.8.1
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ version: 1.8.1
43
+ - !ruby/object:Gem::Dependency
44
+ name: codeclimate-test-reporter
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ version: 0.4.1
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 0.4.1
57
+ - !ruby/object:Gem::Dependency
58
+ name: rspec
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: 3.1.0
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: 3.1.0
71
+ - !ruby/object:Gem::Dependency
72
+ name: rake
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 10.3.2
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ~>
83
+ - !ruby/object:Gem::Version
84
+ version: 10.3.2
85
+ - !ruby/object:Gem::Dependency
86
+ name: wrong
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ~>
90
+ - !ruby/object:Gem::Version
91
+ version: 0.7.1
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 0.7.1
99
+ - !ruby/object:Gem::Dependency
100
+ name: pry
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ version: 0.10.1
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ~>
111
+ - !ruby/object:Gem::Version
112
+ version: 0.10.1
28
113
  description: Provides HTTP functionality wrapped in a nice ruby interface.
29
- email: martyn@255bits.com
114
+ email:
115
+ - jozwright@gmail.com
116
+ - martyn@255bits.com
117
+ - mikkel@255bits.com
30
118
  executables: []
31
119
  extensions: []
32
120
  extra_rdoc_files: []
@@ -35,15 +123,13 @@ files:
35
123
  - lib/tutum_actions.rb
36
124
  - lib/tutum_api.rb
37
125
  - lib/tutum_containers.rb
38
- - lib/tutum_error.rb
39
- - lib/tutum_images.rb
40
126
  - lib/tutum_node_clusters.rb
41
127
  - lib/tutum_node_types.rb
42
128
  - lib/tutum_nodes.rb
43
129
  - lib/tutum_providers.rb
44
130
  - lib/tutum_regions.rb
45
131
  - lib/tutum_services.rb
46
- homepage: https://github.com/255BITS/ruby-tutum
132
+ homepage: https://github.com/tutumcloud/ruby-tutum
47
133
  licenses:
48
134
  - MIT
49
135
  metadata: {}
@@ -66,6 +152,6 @@ rubyforge_project:
66
152
  rubygems_version: 2.0.3
67
153
  signing_key:
68
154
  specification_version: 4
69
- summary: Ruby interface for the tutum PaaS API.
155
+ summary: A Ruby wrapper for the Tutum API
70
156
  test_files: []
71
157
  has_rdoc:
@@ -1,2 +0,0 @@
1
- class TutumError < StandardError
2
- end
@@ -1,43 +0,0 @@
1
- class TutumImages < TutumApi
2
- def list_url
3
- "/image/"
4
- end
5
-
6
- def list(params)
7
- http_get(list_url, params)
8
- end
9
-
10
- def add_url
11
- "/image/"
12
- end
13
-
14
- def add(name, params)
15
- http_post(add_url, params.merge({:name => name}))
16
- end
17
-
18
- def get_url(name)
19
- "/image/#{name}/"
20
- end
21
-
22
- def get(name)
23
- http_get(get_url(name))
24
- end
25
-
26
- def update_url(name)
27
- "/image/#{name}/"
28
- end
29
-
30
- def update(name, params)
31
- http_patch(update_url(name), params)
32
- end
33
-
34
- def delete_url(name)
35
- "/image/#{name}/"
36
- end
37
-
38
- def delete(name)
39
- http_delete(delete_url(name))
40
- end
41
-
42
-
43
- end