tutum-api 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a9b65b7b52a50ff39acba7894da5c01f70da6e70
4
+ data.tar.gz: 7f056aa5d0e9a9f6f50529a581dc7a52c9f111f3
5
+ SHA512:
6
+ metadata.gz: 80a7454093fd64165d5f9336a471ef5b6dd7342c4c80bbf870ef081bc1f3b186fff474e5d46c47e57499019717aa8e021927ffd80820bceb953419148ba033b2
7
+ data.tar.gz: 59e4c2ee384b307d607a03bf6bbcf652086272e77d2a50cdf3bff9ca2e4cb974fee092a3f56732440ac8e5b08f5b46a7905a99254c56cd3106ec349f846a9b33
data/lib/tutum.rb ADDED
@@ -0,0 +1,60 @@
1
+ require_relative './tutum_api'
2
+
3
+ require_relative './tutum_actions'
4
+ require_relative './tutum_containers'
5
+ require_relative './tutum_node_clusters'
6
+ require_relative './tutum_node_types'
7
+ require_relative './tutum_nodes'
8
+ require_relative './tutum_providers'
9
+ require_relative './tutum_regions'
10
+ require_relative './tutum_services'
11
+
12
+
13
+ class Tutum
14
+ attr_reader :username, :api_key
15
+
16
+ def initialize(username, api_key)
17
+ @username = username
18
+ @api_key = api_key
19
+ end
20
+
21
+ def headers
22
+ {
23
+ 'Authorization' => "ApiKey #{@username}:#{@api_key}",
24
+ 'Accept' => 'application/json',
25
+ 'Content-Type' => 'application/json'
26
+ }
27
+ end
28
+
29
+ def actions
30
+ @actions ||= TutumContainers.new(headers)
31
+ end
32
+
33
+ def containers
34
+ @containers ||= TutumContainers.new(headers)
35
+ end
36
+
37
+ def images
38
+ @images ||= TutumImages.new(headers)
39
+ end
40
+
41
+ def node_clusters
42
+ @node_clusters ||= TutumNodeClusters.new(headers)
43
+ end
44
+
45
+ def node_types
46
+ @node_types ||= TutumNodeTypes.new(headers)
47
+ end
48
+
49
+ def nodes
50
+ @nodes ||= TutumNodes.new(headers)
51
+ end
52
+
53
+ def providers
54
+ @providers ||= TutumProviders.new(headers)
55
+ end
56
+
57
+ def services
58
+ @services ||= TutumServices.new(headers)
59
+ end
60
+ end
@@ -0,0 +1,17 @@
1
+ class TutumActions < TutumApi
2
+ def list_url
3
+ "/action/"
4
+ end
5
+
6
+ def list
7
+ http_get(list_url)
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 ADDED
@@ -0,0 +1,32 @@
1
+ require 'rest-client'
2
+
3
+ class TutumApi
4
+ attr_reader :headers
5
+
6
+ BASE_API_PATH = 'https://dashboard.tutum.co/api'
7
+ API_VERSION = 'v1'
8
+
9
+ def initialize(headers)
10
+ @headers = headers
11
+ end
12
+
13
+ def url(path)
14
+ BASE_API_PATH + '/' + API_VERSION + path
15
+ end
16
+
17
+ def http_get(path)
18
+ RestClient.get(url(path), headers)
19
+ end
20
+
21
+ def http_post(path, content={})
22
+ RestClient.post(url(path), content.to_json, headers)
23
+ end
24
+
25
+ def http_put(path, content={})
26
+ RestClient.put(url(path), content.to_json, headers)
27
+ end
28
+
29
+ def http_delete(path)
30
+ RestClient.delete(url(path), headers)
31
+ end
32
+ end
@@ -0,0 +1,49 @@
1
+ class TutumContainers < TutumApi
2
+ def list_url
3
+ "/container/"
4
+ end
5
+
6
+ def list
7
+ http_get(list_url)
8
+ end
9
+
10
+ def get_url(uuid)
11
+ "/container/#{uuid}/"
12
+ end
13
+
14
+ def get(uuid)
15
+ http_get(get_url(uuid))
16
+ end
17
+
18
+ def start_url(uuid)
19
+ "/container/#{uuid}/start/"
20
+ end
21
+
22
+ def start(uuid)
23
+ http_post(start_url(uuid))
24
+ end
25
+
26
+ def stop_url(uuid)
27
+ "/container/#{uuid}/stop/"
28
+ end
29
+
30
+ def stop(uuid)
31
+ http_post(stop_url(uuid))
32
+ end
33
+
34
+ def logs_url(uuid)
35
+ "/container/#{uuid}/logs/"
36
+ end
37
+
38
+ def logs(uuid)
39
+ http_get(logs_url(uuid))
40
+ end
41
+
42
+ def terminate_url(uuid)
43
+ "/container/#{uuid}/"
44
+ end
45
+
46
+ def terminate(uuid)
47
+ http_terminate(terminate_url(uuid))
48
+ end
49
+ end
@@ -0,0 +1,49 @@
1
+ class TutumNodeClusters < TutumApi
2
+ def list_url
3
+ "/nodecluster/"
4
+ end
5
+
6
+ def list
7
+ http_get(list_url)
8
+ end
9
+
10
+ def create_url
11
+ "/nodecluster/"
12
+ end
13
+
14
+ def create(params)
15
+ http_post(create_url, params)
16
+ end
17
+
18
+ def get_url(uuid)
19
+ "/nodecluster/#{uuid}/"
20
+ end
21
+
22
+ def get(uuid)
23
+ http_get(get_url(uuid))
24
+ end
25
+
26
+ def update_url(uuid)
27
+ "/nodecluster/#{uuid}/"
28
+ end
29
+
30
+ def update(uuid, params)
31
+ http_put(update_url(uuid), params)
32
+ end
33
+
34
+ def deploy_url(uuid)
35
+ "/nodecluster/#{uuid}/deploy/"
36
+ end
37
+
38
+ def deploy(uuid)
39
+ http_post(deploy_url(uuid))
40
+ end
41
+
42
+ def terminate_url(uuid)
43
+ "/nodecluster/#{uuid}/"
44
+ end
45
+
46
+ def terminate(uuid)
47
+ delete(terminate_url(uuid))
48
+ end
49
+ end
@@ -0,0 +1,17 @@
1
+ class TutumNodeTypes < TutumApi
2
+ def list_url
3
+ "/nodetype/"
4
+ end
5
+
6
+ def list
7
+ http_get(list_url)
8
+ end
9
+
10
+ def get_url(uuid)
11
+ "/nodetype/#{uuid}/"
12
+ end
13
+
14
+ def get(uuid)
15
+ http_get(get_url(uuid))
16
+ end
17
+ end
@@ -0,0 +1,33 @@
1
+ class TutumNodes < TutumApi
2
+ def list_url
3
+ "/node/"
4
+ end
5
+
6
+ def list
7
+ http_get(list_url)
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)
23
+ http_post(deploy_url(uuid))
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
+ end
@@ -0,0 +1,18 @@
1
+ class TutumProviders < TutumApi
2
+ def list_url
3
+ "/provider/"
4
+ end
5
+
6
+ def list
7
+ http_get(list_url)
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,17 @@
1
+ class TutumRegions < TutumApi
2
+ def list_url
3
+ "/region/"
4
+ end
5
+
6
+ def list
7
+ http_get(list_url)
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
+ end
@@ -0,0 +1,73 @@
1
+ class TutumServices < TutumApi
2
+ def list_url
3
+ "/service/"
4
+ end
5
+
6
+ def list
7
+ http_get(list_url)
8
+ end
9
+
10
+ def create_url
11
+ "/service/"
12
+ end
13
+
14
+ def create(params)
15
+ http_post(create_url, params)
16
+ end
17
+
18
+ def get_url(uuid)
19
+ "/service/#{uuid}/"
20
+ end
21
+
22
+ def get(uuid)
23
+ http_get(get_url(uuid))
24
+ end
25
+
26
+ def logs_url(uuid)
27
+ "/service/#{uuid}/"
28
+ end
29
+
30
+ def logs(uuid)
31
+ http_get(get_url(uuid))
32
+ end
33
+
34
+ def update_url(uuid)
35
+ "/service/#{uuid}/"
36
+ end
37
+
38
+ def update(uuid, params)
39
+ http_put(update_url(uuid), params)
40
+ end
41
+
42
+ def start_url(uuid)
43
+ "/service/#{uuid}/start/"
44
+ end
45
+
46
+ def start(uuid)
47
+ http_post(start_url(uuid))
48
+ end
49
+
50
+ def stop_url(uuid)
51
+ "/service/#{uuid}/stop/"
52
+ end
53
+
54
+ def stop(uuid)
55
+ http_post(stop_url(uuid))
56
+ end
57
+
58
+ def redeploy_url(uuid)
59
+ "/service/#{uuid}/redeploy/"
60
+ end
61
+
62
+ def redeploy(uuid)
63
+ http_post(redeploy_url(uuid))
64
+ end
65
+
66
+ def terminate_url(uuid)
67
+ "/service/#{uuid}/"
68
+ end
69
+
70
+ def terminate(uuid)
71
+ http_delete(terminate_url(uuid))
72
+ end
73
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tutum-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Josie Wright
8
+ - Martyn Garcia
9
+ - Mikkel Garcia
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2014-10-28 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rest-client
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: 1.7.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
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
+ description:
100
+ email:
101
+ - jozwright@gmail.com
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - lib/tutum.rb
107
+ - lib/tutum_actions.rb
108
+ - lib/tutum_api.rb
109
+ - lib/tutum_containers.rb
110
+ - lib/tutum_node_clusters.rb
111
+ - lib/tutum_node_types.rb
112
+ - lib/tutum_nodes.rb
113
+ - lib/tutum_providers.rb
114
+ - lib/tutum_regions.rb
115
+ - lib/tutum_services.rb
116
+ homepage: http://rubygems.org/gems/tutum-api
117
+ licenses: []
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.2.2
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: A Ruby wrapper around the Tutum API
139
+ test_files: []