tutum 0.1.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bc928e5a9fc5caa0c6153fb0077ec03f76c1748
4
- data.tar.gz: 2d5b94d6897b27b0c6091cf9495c17040fdc033d
3
+ metadata.gz: b2bfa295e6c208a54c15b5c1b13c22854bf2d5f9
4
+ data.tar.gz: 913fcefd8d41ce5a9d872b09416592c44f2904bb
5
5
  SHA512:
6
- metadata.gz: cd65782c63c1e44f2a973f2f970b2025ea9d51df1b35f097f2a754d858c220c162b0ae87892a71c20a46fd73c8ded8c96be7b539a8c4d09e07751352e8c92f39
7
- data.tar.gz: 29a903c1c471e77b8972467bd0fa2f65102da060cc2ec20d37d13fa6ec8d2bd269d51ff079b5ad0ea547ffd929218bf072162e36367a10d09f705b5e0ba099a9
6
+ metadata.gz: 9e26ea5e40d68159cb6579f01f20cf2b8b5525e3f69b16e9bbff1d504cce01272b9deb5639b181b4e09f9c954f50a729cbbfb3dfe70e73a09ef510e200dfe97f
7
+ data.tar.gz: 6395fa21a58394335cf37a2010281506b5369d674af5695321f84947f79ad052107fd86ccfc6e441613f73895692b471a0f5867c347e4539e22da75c1143ef9b
data/lib/tutum.rb CHANGED
@@ -1,7 +1,17 @@
1
1
  require_relative './tutum_api'
2
- require_relative './tutum_clusters'
2
+
3
+
4
+ require_relative './tutum_actions'
3
5
  require_relative './tutum_containers'
6
+ require_relative './tutum_node_clusters'
4
7
  require_relative './tutum_images'
8
+ require_relative './tutum_node_clusters'
9
+ require_relative './tutum_node_types'
10
+ require_relative './tutum_nodes'
11
+ require_relative './tutum_providers'
12
+ require_relative './tutum_regions'
13
+ require_relative './tutum_services'
14
+ require_relative './tutum_error'
5
15
 
6
16
  class Tutum
7
17
  attr_reader :username, :api_key
@@ -18,6 +28,10 @@ class Tutum
18
28
  }
19
29
  end
20
30
 
31
+ def actions
32
+ @actions ||= TutumContainers.new(headers)
33
+ end
34
+
21
35
  def containers
22
36
  @containers ||= TutumContainers.new(headers)
23
37
  end
@@ -26,7 +40,24 @@ class Tutum
26
40
  @images ||= TutumImages.new(headers)
27
41
  end
28
42
 
29
- def clusters
30
- @clusters ||= TutumClusters.new(headers)
43
+ def node_clusters
44
+ @node_clusters ||= TutumNodeClusters.new(headers)
31
45
  end
46
+
47
+ def node_types
48
+ @node_types ||= TutumNOdeTypes.new(headers)
49
+ end
50
+
51
+ def nodes
52
+ @nodes ||= TutumNodes.new(headers)
53
+ end
54
+
55
+ def providers
56
+ @providers ||= TutumProviders.new(headers)
57
+ end
58
+
59
+ def services
60
+ @services ||= TutumServices.new(headers)
61
+ end
62
+
32
63
  end
@@ -0,0 +1,17 @@
1
+ class TutumActions < TutumApi
2
+ def list_url
3
+ "/action/"
4
+ end
5
+
6
+ def list(params)
7
+ http_get(list_url, params)
8
+ end
9
+
10
+ def get_url(uuid)
11
+ "/action/#{uuid}/"
12
+ end
13
+
14
+ def get(uuid)
15
+ http_get(get_url(uuid))
16
+ end
17
+ end
data/lib/tutum_api.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'httparty'
2
2
  class TutumApi
3
3
  attr_reader :headers
4
- BASE_API_PATH = "https://app.tutum.co/api"
4
+ BASE_API_PATH = "https://dashboard.tutum.co/api"
5
5
  API_VERSION = "v1"
6
6
  def initialize(headers)
7
7
  @headers = headers
@@ -13,16 +13,33 @@ class TutumApi
13
13
  BASE_API_PATH+"/"+API_VERSION + path
14
14
  end
15
15
 
16
+
17
+ def expect_20x(path, &block)
18
+ response = block.call
19
+ if(response.code/10 != 20)
20
+ raise TutumError.new("#{response.code} received for API call to #{path}")
21
+ end
22
+ response
23
+ end
24
+
16
25
  def http_get(path, args={})
17
- HTTParty.get(api_path(path), http_headers.merge({ :query => args }))
26
+ expect_20x(path) do
27
+ HTTParty.get(api_path(path), http_headers.merge({ :query => args }))
28
+ end
18
29
  end
19
30
  def http_post(path, args={})
20
- HTTParty.post(api_path(path), http_headers.merge({ :body => args.to_json }))
31
+ expect_20x(path) do
32
+ HTTParty.post(api_path(path), http_headers.merge({ :body => args.to_json }))
33
+ end
21
34
  end
22
35
  def http_patch(path, args={})
23
- HTTParty.patch(api_path(path), http_headers.merge({ :body => args.to_json }))
36
+ expect_20x(path) do
37
+ HTTParty.patch(api_path(path), http_headers.merge({ :body => args.to_json }))
38
+ end
24
39
  end
25
40
  def http_delete(path, args={})
26
- HTTParty.delete(api_path(path), http_headers.merge({ :query => args }))
41
+ expect_20x(path) do
42
+ HTTParty.delete(api_path(path), http_headers.merge({ :query => args }))
43
+ end
27
44
  end
28
45
  end
@@ -7,14 +7,6 @@ class TutumContainers < TutumApi
7
7
  http_get(list_url, params)
8
8
  end
9
9
 
10
- def create_url
11
- "/container/"
12
- end
13
-
14
- def create(params)
15
- http_post(create_url, params)
16
- end
17
-
18
10
  def get_url(uuid)
19
11
  "/container/#{uuid}/"
20
12
  end
@@ -47,19 +39,11 @@ class TutumContainers < TutumApi
47
39
  http_get(logs_url(uuid))
48
40
  end
49
41
 
50
- def redeploy_url(uuid)
51
- "/container/#{uuid}/redeploy/"
52
- end
53
-
54
- def redeploy(uuid, params)
55
- http_post(redeploy_url(uuid), params)
56
- end
57
-
58
- def delete_url(uuid)
42
+ def terminate_url(uuid)
59
43
  "/container/#{uuid}/"
60
44
  end
61
45
 
62
- def delete(uuid)
63
- http_delete(delete_url(uuid))
46
+ def terminate(uuid)
47
+ http_terminate(terminate_url(uuid))
64
48
  end
65
49
  end
@@ -0,0 +1,2 @@
1
+ class TutumError < StandardError
2
+ end
@@ -0,0 +1,50 @@
1
+ class TutumNodeClusters < TutumApi
2
+ def list_url
3
+ "/application/"
4
+ end
5
+
6
+ def list(params)
7
+ http_get(list_url, params)
8
+ end
9
+
10
+ def create_url
11
+ "/application/"
12
+ end
13
+
14
+ def create(params)
15
+ http_post(create_url, params)
16
+ end
17
+
18
+ def get_url(uuid)
19
+ "/application/#{uuid}/"
20
+ end
21
+
22
+ def get(uuid)
23
+ http_get(get_url(uuid))
24
+ end
25
+
26
+ def update_url(uuid)
27
+ "/application/#{uuid}/"
28
+ end
29
+
30
+ def update(uuid, params)
31
+ http_patch(update_url(uuid), params)
32
+ end
33
+
34
+ def deploy_url(uuid)
35
+ "/application/#{uuid}/deploy/"
36
+ end
37
+
38
+ def deploy(uuid, params)
39
+ http_post(deploy_url(uuid), params)
40
+ end
41
+
42
+ def terminate_url(uuid)
43
+ "/application/#{uuid}/"
44
+ end
45
+
46
+ def terminate(uuid)
47
+ http_delete(terminate_url(uuid))
48
+ end
49
+
50
+ end
@@ -0,0 +1,18 @@
1
+ class TutumNodeTypes < TutumApi
2
+ def list_url
3
+ "/node_type/"
4
+ end
5
+
6
+ def list(params)
7
+ http_get(list_url, params)
8
+ end
9
+
10
+ def get_url(uuid)
11
+ "/node_type/#{uuid}/"
12
+ end
13
+
14
+ def get(uuid)
15
+ http_get(get_url(uuid))
16
+ end
17
+
18
+ end
@@ -0,0 +1,34 @@
1
+ class TutumNodes < TutumApi
2
+ def list_url
3
+ "/node/"
4
+ end
5
+
6
+ def list(params)
7
+ http_get(list_url, params)
8
+ end
9
+
10
+ def get_url(uuid)
11
+ "/node/#{uuid}/"
12
+ end
13
+
14
+ def get(uuid)
15
+ http_get(get_url(uuid))
16
+ end
17
+
18
+ def deploy_url(uuid)
19
+ "/node/#{uuid}/deploy/"
20
+ end
21
+
22
+ def deploy(uuid, params)
23
+ http_post(deploy_url(uuid), params)
24
+ end
25
+
26
+ def terminate_url(uuid)
27
+ "/node/#{uuid}/"
28
+ end
29
+
30
+ def terminate(uuid)
31
+ http_delete(terminate_url(uuid))
32
+ end
33
+
34
+ end
@@ -0,0 +1,18 @@
1
+ class TutumProviders < TutumApi
2
+ def list_url
3
+ "/provider/"
4
+ end
5
+
6
+ def list(params)
7
+ http_get(list_url, params)
8
+ end
9
+
10
+ def get_url(uuid)
11
+ "/provider/#{uuid}/"
12
+ end
13
+
14
+ def get(uuid)
15
+ http_get(get_url(uuid))
16
+ end
17
+
18
+ end
@@ -0,0 +1,18 @@
1
+ class TutumRegions < TutumApi
2
+ def list_url
3
+ "/region/"
4
+ end
5
+
6
+ def list(params)
7
+ http_get(list_url, params)
8
+ end
9
+
10
+ def get_url(uuid)
11
+ "/region/#{uuid}/"
12
+ end
13
+
14
+ def get(uuid)
15
+ http_get(get_url(uuid))
16
+ end
17
+
18
+ end
@@ -1,6 +1,6 @@
1
- class TutumClusters < TutumApi
1
+ class TutumServices < TutumApi
2
2
  def list_url
3
- "/application/"
3
+ "/service/"
4
4
  end
5
5
 
6
6
  def list(params)
@@ -8,7 +8,7 @@ class TutumClusters < TutumApi
8
8
  end
9
9
 
10
10
  def create_url
11
- "/application/"
11
+ "/service/"
12
12
  end
13
13
 
14
14
  def create(params)
@@ -16,51 +16,60 @@ class TutumClusters < TutumApi
16
16
  end
17
17
 
18
18
  def get_url(uuid)
19
- "/application/#{uuid}/"
19
+ "/service/#{uuid}/"
20
20
  end
21
21
 
22
22
  def get(uuid)
23
23
  http_get(get_url(uuid))
24
24
  end
25
25
 
26
- def start_url(uuid)
27
- "/application/#{uuid}/start/"
26
+ def logs_url(uuid)
27
+ "/service/#{uuid}/"
28
28
  end
29
29
 
30
- def start(uuid)
31
- http_post(start_url(uuid))
30
+ def logs(uuid)
31
+ http_get(get_url(uuid))
32
32
  end
33
33
 
34
- def stop_url(uuid)
35
- "/application/#{uuid}/stop/"
34
+ def update_url(uuid)
35
+ "/service/#{uuid}/"
36
+ end
37
+
38
+ def update(uuid, params)
39
+ http_patch(update_url(uuid), params)
36
40
  end
37
41
 
38
- def stop(uuid)
39
- http_post(stop_url(uuid))
42
+ def start_url(uuid)
43
+ "/service/#{uuid}/start/"
44
+ end
45
+
46
+ def start(uuid)
47
+ http_post(start_url(uuid))
40
48
  end
41
49
 
42
- def update_url(uuid)
43
- "/application/#{uuid}/"
50
+ def stop_url(uuid)
51
+ "/service/#{uuid}/stop/"
44
52
  end
45
53
 
46
- def update(uuid, params)
47
- http_patch(update_url(uuid), params)
54
+ def stop(uuid)
55
+ http_post(stop_url(uuid))
48
56
  end
49
57
 
58
+
50
59
  def redeploy_url(uuid)
51
- "/application/#{uuid}/redeploy/"
60
+ "/service/#{uuid}/redeploy/"
52
61
  end
53
62
 
54
63
  def redeploy(uuid, params)
55
64
  http_post(redeploy_url(uuid), params)
56
65
  end
57
66
 
58
- def delete_url(uuid)
59
- "/application/#{uuid}/"
67
+ def terminate_url(uuid)
68
+ "/service/#{uuid}/"
60
69
  end
61
70
 
62
- def delete(uuid)
63
- http_delete(delete_url(uuid))
71
+ def terminate(uuid)
72
+ http_delete(terminate_url(uuid))
64
73
  end
65
74
 
66
75
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tutum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martyn Garcia
@@ -32,10 +32,17 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - lib/tutum.rb
35
+ - lib/tutum_actions.rb
35
36
  - lib/tutum_api.rb
36
- - lib/tutum_clusters.rb
37
37
  - lib/tutum_containers.rb
38
+ - lib/tutum_error.rb
38
39
  - lib/tutum_images.rb
40
+ - lib/tutum_node_clusters.rb
41
+ - lib/tutum_node_types.rb
42
+ - lib/tutum_nodes.rb
43
+ - lib/tutum_providers.rb
44
+ - lib/tutum_regions.rb
45
+ - lib/tutum_services.rb
39
46
  homepage: https://github.com/255BITS/ruby-tutum
40
47
  licenses:
41
48
  - MIT