scalingo 3.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/.rubocop.yml +16 -0
  4. data/.travis.yml +24 -0
  5. data/CHANGELOG.md +29 -0
  6. data/Gemfile +4 -0
  7. data/Gemfile.lock +110 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +147 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +12 -0
  12. data/bin/setup +8 -0
  13. data/lib/scalingo.rb +2 -0
  14. data/lib/scalingo/api/client.rb +79 -0
  15. data/lib/scalingo/api/endpoint.rb +23 -0
  16. data/lib/scalingo/api/response.rb +71 -0
  17. data/lib/scalingo/auth.rb +21 -0
  18. data/lib/scalingo/auth/keys.rb +56 -0
  19. data/lib/scalingo/auth/scm_integrations.rb +57 -0
  20. data/lib/scalingo/auth/tokens.rb +78 -0
  21. data/lib/scalingo/auth/two_factor_auth.rb +61 -0
  22. data/lib/scalingo/auth/user.rb +31 -0
  23. data/lib/scalingo/bearer_token.rb +20 -0
  24. data/lib/scalingo/client.rb +105 -0
  25. data/lib/scalingo/config.rb +38 -0
  26. data/lib/scalingo/error/expired_token.rb +6 -0
  27. data/lib/scalingo/error/unauthenticated.rb +6 -0
  28. data/lib/scalingo/errors.rb +2 -0
  29. data/lib/scalingo/regional.rb +35 -0
  30. data/lib/scalingo/regional/addons.rb +109 -0
  31. data/lib/scalingo/regional/apps.rb +109 -0
  32. data/lib/scalingo/regional/collaborators.rb +57 -0
  33. data/lib/scalingo/regional/containers.rb +57 -0
  34. data/lib/scalingo/regional/deployments.rb +44 -0
  35. data/lib/scalingo/regional/domains.rb +70 -0
  36. data/lib/scalingo/regional/environment.rb +83 -0
  37. data/lib/scalingo/regional/events.rb +55 -0
  38. data/lib/scalingo/regional/logs.rb +38 -0
  39. data/lib/scalingo/regional/metrics.rb +41 -0
  40. data/lib/scalingo/regional/notifiers.rb +96 -0
  41. data/lib/scalingo/regional/operations.rb +18 -0
  42. data/lib/scalingo/regional/scm_repo_links.rb +109 -0
  43. data/lib/scalingo/version.rb +3 -0
  44. data/samples/auth/keys/_meta.json +13 -0
  45. data/samples/auth/keys/all-200.json +62 -0
  46. data/samples/auth/keys/create-201.json +67 -0
  47. data/samples/auth/keys/create-422.json +34 -0
  48. data/samples/auth/keys/destroy-204.json +19 -0
  49. data/samples/auth/keys/destroy-404.json +19 -0
  50. data/samples/auth/keys/show-200.json +60 -0
  51. data/samples/auth/keys/show-404.json +19 -0
  52. data/samples/auth/scm_integrations/_meta.json +14 -0
  53. data/samples/auth/scm_integrations/all-200.json +41 -0
  54. data/samples/auth/scm_integrations/create-201.json +41 -0
  55. data/samples/auth/scm_integrations/create-422.json +36 -0
  56. data/samples/auth/scm_integrations/destroy-204.json +15 -0
  57. data/samples/auth/scm_integrations/destroy-404.json +23 -0
  58. data/samples/auth/scm_integrations/show-200.json +34 -0
  59. data/samples/auth/scm_integrations/show-404.json +23 -0
  60. data/samples/auth/tokens/_meta.json +13 -0
  61. data/samples/auth/tokens/all-200.json +32 -0
  62. data/samples/auth/tokens/create-201.json +37 -0
  63. data/samples/auth/tokens/destroy-204.json +19 -0
  64. data/samples/auth/tokens/destroy-404.json +19 -0
  65. data/samples/auth/tokens/exchange-200.json +25 -0
  66. data/samples/auth/tokens/exchange-401.json +24 -0
  67. data/samples/auth/tokens/renew-200.json +32 -0
  68. data/samples/auth/tokens/renew-404.json +20 -0
  69. data/samples/auth/two_factor_auth/_meta.json +10 -0
  70. data/samples/auth/two_factor_auth/disable-not-initiated.json +23 -0
  71. data/samples/auth/two_factor_auth/disable-success.json +29 -0
  72. data/samples/auth/two_factor_auth/initiate-already-enabled.json +29 -0
  73. data/samples/auth/two_factor_auth/initiate-success.json +36 -0
  74. data/samples/auth/two_factor_auth/initiate-wrong-provider.json +29 -0
  75. data/samples/auth/two_factor_auth/status.json +29 -0
  76. data/samples/auth/two_factor_auth/validate-not-initiated.json +29 -0
  77. data/samples/auth/two_factor_auth/validate-success.json +49 -0
  78. data/samples/auth/two_factor_auth/validate-wrong.json +29 -0
  79. data/samples/auth/user/_meta.json +10 -0
  80. data/samples/auth/user/self.json +54 -0
  81. data/samples/auth/user/update-200.json +59 -0
  82. data/samples/auth/user/update-422.json +33 -0
  83. data/samples/regional/addons/_meta.json +22 -0
  84. data/samples/regional/addons/categories-guest.json +36 -0
  85. data/samples/regional/addons/categories-logged.json +37 -0
  86. data/samples/regional/addons/destroy-204.json +19 -0
  87. data/samples/regional/addons/destroy-404.json +24 -0
  88. data/samples/regional/addons/find-200.json +48 -0
  89. data/samples/regional/addons/find-404.json +24 -0
  90. data/samples/regional/addons/for-200.json +50 -0
  91. data/samples/regional/addons/providers-guest.json +588 -0
  92. data/samples/regional/addons/providers-logged.json +705 -0
  93. data/samples/regional/addons/provision-201.json +58 -0
  94. data/samples/regional/addons/provision-400.json +29 -0
  95. data/samples/regional/addons/sso-200.json +49 -0
  96. data/samples/regional/addons/sso-404.json +24 -0
  97. data/samples/regional/addons/update-200.json +58 -0
  98. data/samples/regional/addons/update-404.json +30 -0
  99. data/samples/regional/apps/_meta.json +52 -0
  100. data/samples/regional/apps/all.json +99 -0
  101. data/samples/regional/apps/create-201.json +66 -0
  102. data/samples/regional/apps/create-422.json +34 -0
  103. data/samples/regional/apps/destroy-204.json +19 -0
  104. data/samples/regional/apps/destroy-404.json +24 -0
  105. data/samples/regional/apps/destroy-422.json +27 -0
  106. data/samples/regional/apps/find-200.json +60 -0
  107. data/samples/regional/apps/find-404.json +24 -0
  108. data/samples/regional/apps/logs_url.json +62 -0
  109. data/samples/regional/apps/rename-200.json +65 -0
  110. data/samples/regional/apps/rename-404.json +29 -0
  111. data/samples/regional/apps/rename-422.json +33 -0
  112. data/samples/regional/apps/transfer-200.json +65 -0
  113. data/samples/regional/apps/transfer-404.json +27 -0
  114. data/samples/regional/apps/transfer-422.json +34 -0
  115. data/samples/regional/apps/update-200.json +66 -0
  116. data/samples/regional/apps/update-stack-404.json +30 -0
  117. data/samples/regional/collaborators/_meta.json +17 -0
  118. data/samples/regional/collaborators/accept-200.json +60 -0
  119. data/samples/regional/collaborators/accept-400.json +24 -0
  120. data/samples/regional/collaborators/accept-404.json +24 -0
  121. data/samples/regional/collaborators/destroy-204.json +19 -0
  122. data/samples/regional/collaborators/destroy-404.json +24 -0
  123. data/samples/regional/collaborators/for-200.json +34 -0
  124. data/samples/regional/collaborators/invite-201.json +37 -0
  125. data/samples/regional/collaborators/invite-422.json +34 -0
  126. data/samples/regional/containers/_meta.json +25 -0
  127. data/samples/regional/containers/for-200.json +39 -0
  128. data/samples/regional/containers/restart-202.json +28 -0
  129. data/samples/regional/containers/restart-422.json +33 -0
  130. data/samples/regional/containers/scale-202.json +48 -0
  131. data/samples/regional/containers/scale-422.json +36 -0
  132. data/samples/regional/containers/sizes-guest.json +115 -0
  133. data/samples/regional/containers/sizes-logged.json +116 -0
  134. data/samples/regional/deployments/_meta.json +8 -0
  135. data/samples/regional/deployments/find-200.json +45 -0
  136. data/samples/regional/deployments/find-404.json +24 -0
  137. data/samples/regional/deployments/for-with-paging.json +35 -0
  138. data/samples/regional/deployments/for-without-pages.json +56 -0
  139. data/samples/regional/deployments/logs-200.json +22 -0
  140. data/samples/regional/deployments/logs-404.json +24 -0
  141. data/samples/regional/domains/_meta.json +21 -0
  142. data/samples/regional/domains/create-201.json +44 -0
  143. data/samples/regional/domains/create-422.json +33 -0
  144. data/samples/regional/domains/destroy-204.json +19 -0
  145. data/samples/regional/domains/destroy-404.json +24 -0
  146. data/samples/regional/domains/find-200.json +38 -0
  147. data/samples/regional/domains/find-404.json +24 -0
  148. data/samples/regional/domains/for-200.json +40 -0
  149. data/samples/regional/domains/update-200.json +44 -0
  150. data/samples/regional/domains/update-404.json +30 -0
  151. data/samples/regional/domains/update-422.json +33 -0
  152. data/samples/regional/environment/_meta.json +43 -0
  153. data/samples/regional/environment/bulk-destroy-204.json +19 -0
  154. data/samples/regional/environment/bulk-update-200.json +70 -0
  155. data/samples/regional/environment/create-201.json +36 -0
  156. data/samples/regional/environment/create-422.json +37 -0
  157. data/samples/regional/environment/destroy-204.json +19 -0
  158. data/samples/regional/environment/destroy-404.json +24 -0
  159. data/samples/regional/environment/for-200.json +31 -0
  160. data/samples/regional/environment/update-200.json +35 -0
  161. data/samples/regional/environment/update-404.json +30 -0
  162. data/samples/regional/events/_meta.json +3 -0
  163. data/samples/regional/events/all-200.json +619 -0
  164. data/samples/regional/events/categories-guest.json +66 -0
  165. data/samples/regional/events/categories-logged.json +67 -0
  166. data/samples/regional/events/for-200.json +404 -0
  167. data/samples/regional/events/types-guest.json +288 -0
  168. data/samples/regional/events/types-logged.json +289 -0
  169. data/samples/regional/logs/_meta.json +11 -0
  170. data/samples/regional/logs/archives-200.json +28 -0
  171. data/samples/regional/logs/get-guest-200.json +18 -0
  172. data/samples/regional/logs/get-logged-200.json +19 -0
  173. data/samples/regional/logs/get-with-limit-200.json +18 -0
  174. data/samples/regional/metrics/_meta.json +15 -0
  175. data/samples/regional/metrics/for-invalid-400.json +23 -0
  176. data/samples/regional/metrics/for-valid-cpu-200.json +747 -0
  177. data/samples/regional/metrics/for-valid-router-404.json +23 -0
  178. data/samples/regional/metrics/types-guest.json +66 -0
  179. data/samples/regional/metrics/types-logged.json +67 -0
  180. data/samples/regional/notifiers/_meta.json +23 -0
  181. data/samples/regional/notifiers/create-201.json +55 -0
  182. data/samples/regional/notifiers/create-404.json +30 -0
  183. data/samples/regional/notifiers/create-422.json +36 -0
  184. data/samples/regional/notifiers/destroy-204.json +19 -0
  185. data/samples/regional/notifiers/destroy-404.json +24 -0
  186. data/samples/regional/notifiers/find-200.json +47 -0
  187. data/samples/regional/notifiers/find-404.json +24 -0
  188. data/samples/regional/notifiers/for-200.json +49 -0
  189. data/samples/regional/notifiers/platforms-guest.json +184 -0
  190. data/samples/regional/notifiers/platforms-logged.json +185 -0
  191. data/samples/regional/notifiers/test-200.json +22 -0
  192. data/samples/regional/notifiers/test-404.json +25 -0
  193. data/samples/regional/notifiers/update-200.json +53 -0
  194. data/samples/regional/operations/_meta.json +5 -0
  195. data/samples/regional/operations/find-200.json +31 -0
  196. data/samples/regional/operations/find-404.json +24 -0
  197. data/samples/regional/scm_repo_links/_meta.json +22 -0
  198. data/samples/regional/scm_repo_links/create-201.json +54 -0
  199. data/samples/regional/scm_repo_links/destroy-204.json +15 -0
  200. data/samples/regional/scm_repo_links/manual-deploy-200.json +32 -0
  201. data/samples/regional/scm_repo_links/show-200.json +43 -0
  202. data/samples/regional/scm_repo_links/update-200.json +50 -0
  203. data/scalingo.gemspec +51 -0
  204. data/spec/scalingo/auth/keys_spec.rb +58 -0
  205. data/spec/scalingo/auth/scm_integrations_spec.rb +58 -0
  206. data/spec/scalingo/auth/tokens_spec.rb +74 -0
  207. data/spec/scalingo/auth/two_factor_auth_spec.rb +69 -0
  208. data/spec/scalingo/auth/user_spec.rb +25 -0
  209. data/spec/scalingo/regional/addons_spec.rb +133 -0
  210. data/spec/scalingo/regional/apps_spec.rb +137 -0
  211. data/spec/scalingo/regional/collaborators_spec.rb +69 -0
  212. data/spec/scalingo/regional/containers_spec.rb +67 -0
  213. data/spec/scalingo/regional/deployments_spec.rb +45 -0
  214. data/spec/scalingo/regional/domains_spec.rb +84 -0
  215. data/spec/scalingo/regional/environment_spec.rb +77 -0
  216. data/spec/scalingo/regional/events_spec.rb +65 -0
  217. data/spec/scalingo/regional/logs_spec.rb +39 -0
  218. data/spec/scalingo/regional/metrics_spec.rb +46 -0
  219. data/spec/scalingo/regional/notifiers_spec.rb +113 -0
  220. data/spec/scalingo/regional/operations_spec.rb +19 -0
  221. data/spec/scalingo/regional/scm_repo_links_spec.rb +48 -0
  222. metadata +488 -0
@@ -0,0 +1,38 @@
1
+ require "active_support/core_ext/numeric/time"
2
+ require "dry-configurable"
3
+ require "scalingo/version"
4
+
5
+ module Scalingo
6
+ extend Dry::Configurable
7
+
8
+ # Known regions. Each region should have a corresponding entry in the urls settings below
9
+ setting :regions, %i[osc_fr1 osc_secnum_fr1]
10
+
11
+ # Default region
12
+ setting :default_region, :osc_fr1
13
+
14
+ # Endpoints URLS
15
+ setting :urls do
16
+ setting :auth, "https://auth.scalingo.com/v1"
17
+ setting :osc_fr1, "https://api.osc-fr1.scalingo.com/v1"
18
+ setting :osc_secnum_fr1, "https://api.osc-secnum-fr1.scalingo.com/v1"
19
+ end
20
+
21
+ # Configure the User Agent header
22
+ setting :user_agent, "Scalingo Ruby Client v#{Scalingo::VERSION}"
23
+
24
+ # For how long is a bearer token considered valid (it will raise passed this delay).
25
+ # Set to nil to never raise.
26
+ setting :exchanged_token_validity, 1.hour
27
+
28
+ # Raise an exception when trying to use an authenticated connection without a bearer token set
29
+ # Having this setting to true prevents performing requests that would fail due to lack of authentication headers.
30
+ setting :raise_on_missing_authentication, true
31
+
32
+ # These headers will be added to every request. Individual methods may override them.
33
+ # This should be a hash or a callable object that returns a hash.
34
+ setting :additional_headers, {}
35
+
36
+ # Raise an exception when the bearer token in use is supposed to be invalid
37
+ setting :raise_on_expired_token, false
38
+ end
@@ -0,0 +1,6 @@
1
+ module Scalingo
2
+ module Error
3
+ class ExpiredToken < StandardError
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Scalingo
2
+ module Error
3
+ class Unauthenticated < StandardError
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,2 @@
1
+ require "scalingo/error/expired_token"
2
+ require "scalingo/error/unauthenticated"
@@ -0,0 +1,35 @@
1
+ require "scalingo/api/client"
2
+
3
+ module Scalingo
4
+ class Regional < API::Client
5
+ require "scalingo/regional/addons"
6
+ require "scalingo/regional/apps"
7
+ require "scalingo/regional/collaborators"
8
+ require "scalingo/regional/containers"
9
+ require "scalingo/regional/deployments"
10
+ require "scalingo/regional/domains"
11
+ require "scalingo/regional/environment"
12
+ require "scalingo/regional/events"
13
+ require "scalingo/regional/logs"
14
+ require "scalingo/regional/metrics"
15
+ require "scalingo/regional/notifiers"
16
+ require "scalingo/regional/operations"
17
+ require "scalingo/regional/scm_repo_links"
18
+
19
+ register_handlers!(
20
+ addons: Addons,
21
+ apps: Apps,
22
+ collaborators: Collaborators,
23
+ containers: Containers,
24
+ deployments: Deployments,
25
+ domains: Domains,
26
+ environment: Environment,
27
+ events: Events,
28
+ logs: Logs,
29
+ metrics: Metrics,
30
+ notifiers: Notifiers,
31
+ operations: Operations,
32
+ scm_repo_links: ScmRepoLinks,
33
+ )
34
+ end
35
+ end
@@ -0,0 +1,109 @@
1
+ require "scalingo/api/endpoint"
2
+
3
+ module Scalingo
4
+ class Regional::Addons < API::Endpoint
5
+ def for(app_id, headers = nil, &block)
6
+ data = nil
7
+
8
+ response = connection.get(
9
+ "apps/#{app_id}/addons",
10
+ data,
11
+ headers,
12
+ &block
13
+ )
14
+
15
+ unpack(response, key: :addons)
16
+ end
17
+
18
+ def find(app_id, addon_id, headers = nil, &block)
19
+ data = nil
20
+
21
+ response = connection.get(
22
+ "apps/#{app_id}/addons/#{addon_id}",
23
+ data,
24
+ headers,
25
+ &block
26
+ )
27
+
28
+ unpack(response, key: :addon)
29
+ end
30
+
31
+ def provision(app_id, payload = {}, headers = nil, &block)
32
+ data = {addon: payload}
33
+
34
+ response = connection.post(
35
+ "apps/#{app_id}/addons",
36
+ data,
37
+ headers,
38
+ &block
39
+ )
40
+
41
+ unpack(response, key: :addon)
42
+ end
43
+
44
+ def update(app_id, addon_id, payload = {}, headers = nil, &block)
45
+ data = {addon: payload}
46
+
47
+ response = connection.patch(
48
+ "apps/#{app_id}/addons/#{addon_id}",
49
+ data,
50
+ headers,
51
+ &block
52
+ )
53
+
54
+ unpack(response, key: :addon)
55
+ end
56
+
57
+ def destroy(app_id, addon_id, headers = nil, &block)
58
+ data = nil
59
+
60
+ response = connection.delete(
61
+ "apps/#{app_id}/addons/#{addon_id}",
62
+ data,
63
+ headers,
64
+ &block
65
+ )
66
+
67
+ unpack(response)
68
+ end
69
+
70
+ def sso(app_id, addon_id, headers = nil, &block)
71
+ data = nil
72
+
73
+ response = connection.get(
74
+ "apps/#{app_id}/addons/#{addon_id}/sso",
75
+ data,
76
+ headers,
77
+ &block
78
+ )
79
+
80
+ unpack(response, key: :addon)
81
+ end
82
+
83
+ def categories(headers = nil, &block)
84
+ data = nil
85
+
86
+ response = connection(allow_guest: true).get(
87
+ "addon_categories",
88
+ data,
89
+ headers,
90
+ &block
91
+ )
92
+
93
+ unpack(response, key: :addon_categories)
94
+ end
95
+
96
+ def providers(headers = nil, &block)
97
+ data = nil
98
+
99
+ response = connection(allow_guest: true).get(
100
+ "addon_providers",
101
+ data,
102
+ headers,
103
+ &block
104
+ )
105
+
106
+ unpack(response, key: :addon_providers)
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,109 @@
1
+ require "scalingo/api/endpoint"
2
+
3
+ module Scalingo
4
+ class Regional::Apps < API::Endpoint
5
+ def all(headers = nil, &block)
6
+ data = nil
7
+
8
+ response = connection.get(
9
+ "apps",
10
+ data,
11
+ headers,
12
+ &block
13
+ )
14
+
15
+ unpack(response, key: :apps)
16
+ end
17
+
18
+ def find(id, headers = nil, &block)
19
+ data = nil
20
+
21
+ response = connection.get(
22
+ "apps/#{id}",
23
+ data,
24
+ headers,
25
+ &block
26
+ )
27
+
28
+ unpack(response, key: :app)
29
+ end
30
+
31
+ def create(payload = {}, headers = nil, &block)
32
+ data = {app: payload}
33
+
34
+ dry_run = !!(payload[:dry_run] || payload["dry_run"])
35
+
36
+ request_headers = {}
37
+ request_headers["X-Dry-Run"] = "true" if dry_run
38
+ request_headers.update(headers) if headers
39
+
40
+ response = connection.post(
41
+ "apps",
42
+ data,
43
+ request_headers,
44
+ &block
45
+ )
46
+
47
+ unpack(response, key: :app)
48
+ end
49
+
50
+ def update(id, payload = {}, headers = nil, &block)
51
+ data = {app: payload}
52
+
53
+ response = connection.patch(
54
+ "apps/#{id}",
55
+ data,
56
+ headers,
57
+ &block
58
+ )
59
+
60
+ unpack(response, key: :app)
61
+ end
62
+
63
+ def logs_url(id, headers = nil, &block)
64
+ data = nil
65
+
66
+ response = connection.get(
67
+ "apps/#{id}/logs",
68
+ data,
69
+ headers,
70
+ &block
71
+ )
72
+
73
+ unpack(response, key: :logs_url)
74
+ end
75
+
76
+ def destroy(id, payload = {}, headers = nil, &block)
77
+ response = connection.delete(
78
+ "apps/#{id}",
79
+ payload,
80
+ headers,
81
+ &block
82
+ )
83
+
84
+ unpack(response)
85
+ end
86
+
87
+ def rename(id, payload = {}, headers = nil, &block)
88
+ response = connection.post(
89
+ "apps/#{id}/rename",
90
+ payload,
91
+ headers,
92
+ &block
93
+ )
94
+
95
+ unpack(response, key: :app)
96
+ end
97
+
98
+ def transfer(id, payload = {}, headers = nil, &block)
99
+ response = connection.patch(
100
+ "apps/#{id}",
101
+ payload,
102
+ headers,
103
+ &block
104
+ )
105
+
106
+ unpack(response, key: :app)
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,57 @@
1
+ require "scalingo/api/endpoint"
2
+
3
+ module Scalingo
4
+ class Regional::Collaborators < API::Endpoint
5
+ def for(app_id, headers = nil, &block)
6
+ data = nil
7
+
8
+ response = connection.get(
9
+ "apps/#{app_id}/collaborators",
10
+ data,
11
+ headers,
12
+ &block
13
+ )
14
+
15
+ unpack(response, key: :collaborators)
16
+ end
17
+
18
+ def destroy(app_id, collaborator_id, headers = nil, &block)
19
+ data = nil
20
+
21
+ response = connection.delete(
22
+ "apps/#{app_id}/collaborators/#{collaborator_id}",
23
+ data,
24
+ headers,
25
+ &block
26
+ )
27
+
28
+ unpack(response)
29
+ end
30
+
31
+ def invite(app_id, payload = {}, headers = nil, &block)
32
+ data = {collaborator: payload}
33
+
34
+ response = connection.post(
35
+ "apps/#{app_id}/collaborators",
36
+ data,
37
+ headers,
38
+ &block
39
+ )
40
+
41
+ unpack(response, key: :collaborator)
42
+ end
43
+
44
+ def accept(token, headers = nil, &block)
45
+ data = {token: token}
46
+
47
+ response = connection.get(
48
+ "apps/collaboration",
49
+ data,
50
+ headers,
51
+ &block
52
+ )
53
+
54
+ unpack(response)
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,57 @@
1
+ require "scalingo/api/endpoint"
2
+
3
+ module Scalingo
4
+ class Regional::Containers < API::Endpoint
5
+ def for(app_id, headers = nil, &block)
6
+ data = nil
7
+
8
+ response = connection.get(
9
+ "apps/#{app_id}/containers",
10
+ data,
11
+ headers,
12
+ &block
13
+ )
14
+
15
+ unpack(response, key: :containers)
16
+ end
17
+
18
+ def scale(app_id, formation, headers = nil, &block)
19
+ data = {containers: formation}
20
+
21
+ response = connection.post(
22
+ "apps/#{app_id}/scale",
23
+ data,
24
+ headers,
25
+ &block
26
+ )
27
+
28
+ unpack(response, key: :containers)
29
+ end
30
+
31
+ def restart(app_id, scope = [], headers = nil, &block)
32
+ data = {scope: scope}
33
+
34
+ response = connection.post(
35
+ "apps/#{app_id}/restart",
36
+ data,
37
+ headers,
38
+ &block
39
+ )
40
+
41
+ unpack(response)
42
+ end
43
+
44
+ def sizes(headers = nil, &block)
45
+ data = nil
46
+
47
+ response = connection(allow_guest: true).get(
48
+ "features/container_sizes",
49
+ data,
50
+ headers,
51
+ &block
52
+ )
53
+
54
+ unpack(response, key: :container_sizes)
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,44 @@
1
+ require "scalingo/api/endpoint"
2
+
3
+ module Scalingo
4
+ class Regional::Deployments < API::Endpoint
5
+ def for(app_id, payload = {}, headers = nil, &block)
6
+ data = payload.compact
7
+
8
+ response = connection.get(
9
+ "apps/#{app_id}/deployments",
10
+ data,
11
+ headers,
12
+ &block
13
+ )
14
+
15
+ unpack(response, key: :deployments)
16
+ end
17
+
18
+ def find(app_id, deployment_id, headers = nil, &block)
19
+ data = nil
20
+
21
+ response = connection.get(
22
+ "apps/#{app_id}/deployments/#{deployment_id}",
23
+ data,
24
+ headers,
25
+ &block
26
+ )
27
+
28
+ unpack(response, key: :deployment)
29
+ end
30
+
31
+ def logs(app_id, deployment_id, headers = nil, &block)
32
+ data = nil
33
+
34
+ response = connection.get(
35
+ "apps/#{app_id}/deployments/#{deployment_id}/output",
36
+ data,
37
+ headers,
38
+ &block
39
+ )
40
+
41
+ unpack(response, key: :deployment)
42
+ end
43
+ end
44
+ end