upcloud_api 1.0.1 → 1.1.0.pre.rc1

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: 6a5b19e86dec19e3f79f16b91dbca03fa81aa3ec
4
- data.tar.gz: bdc60ee6c10ee85b83a1107c95af7a902be160b3
3
+ metadata.gz: 6abeddb4d6ad7ff0bb932e242f024e1d2fb5ca24
4
+ data.tar.gz: e6fc93ccaa63baf8d9e77a13b47850a47d835abe
5
5
  SHA512:
6
- metadata.gz: 2b5fdd28bdac18d5ffd937445d6e685b51686ab7ff225dc99dc99fb81ae388ee2af7717eed0305fcc52b8c8e37f340b684f635fb3a817e81f057fb4d8fe333d6
7
- data.tar.gz: dfe31cf397eb647af91020fb7a7476d33dc7e25c18a45cede36a5ad4a302c378183eddc71e331e473513055318a93bf980f5d04befe577aa5475b6b32dc157aa
6
+ metadata.gz: 9faec00c67982ea678dd873372cf79a06840ed0c01508838424a851e4d3eaa8defd009f5e02332e4f3b0f00ba09494b5752146e3f009f7c74e061df0448de4f7
7
+ data.tar.gz: 011a2f9302605fbb85417ee4fcc904bcdd35081c75f506a90763960e0c154096621f7c3dd26f92b068359d4ed8887e73955fa0ff90c2ad3fd8b04b30f912ce44
@@ -1,3 +1,3 @@
1
1
  class UpcloudApi
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0-rc1"
3
3
  end
data/lib/upcloud_api.rb CHANGED
@@ -75,26 +75,28 @@ class UpcloudApi
75
75
  #
76
76
  # Calls POST /1.2/server
77
77
  #
78
- # @param template_uuid Uuid from UpcloudApi#templates (a disk’s UUID)
78
+ # Storage devices should be array of hashes containing following data:
79
79
  #
80
- # Returns HTTParty response bodys
81
- def create_server template_uuid, disk_name
80
+ # {
81
+ # "action" => "clone" # Can be "create", "clone" or "attach"
82
+ # "storage" => template_uuid, # Should be passed only for "clone" or "attach"
83
+ # "title" => disk_name # Name of the storage
84
+ # }
85
+ #
86
+ # Returns HTTParty response
87
+ def create_server zone: "fi-hel1", title:, hostname:, core_number: 1, memory_amount: 1024, storage_devices:
82
88
  data = {
83
89
  "server" => {
84
- "zone" => "",
85
- "title" => "",
86
- "hostname" => "",
87
- "core_number" => "",
88
- "memory_amount" => "",
89
- "storage_devices" => [
90
- "action" => "clone",
91
- "storage" => template_uuid,
92
- "title" => disk_name
93
- ]
90
+ "zone" => zone,
91
+ "title" => title,
92
+ "hostname" => hostname,
93
+ "core_number" => core_number,
94
+ "memory_amount" => memory_amount,
95
+ "storage_devices" => storage_devices
94
96
  }
95
97
  }
96
98
 
97
- json = JSON.encode data
99
+ json = JSON.generate data
98
100
  response = post "server", json
99
101
 
100
102
  response
@@ -110,7 +112,7 @@ class UpcloudApi
110
112
  # @param params [Hash] Hash of params that will be passed to be changed.
111
113
  def modify_server server_uuid, params
112
114
  data = { "server" => params }
113
- json = JSON.encode data
115
+ json = JSON.generate data
114
116
  response = put "server/#{server_uuid}", json
115
117
 
116
118
  response
@@ -157,7 +159,7 @@ class UpcloudApi
157
159
  }
158
160
  data["stop_server"]["timeout"] = timeout unless timeout.nil?
159
161
 
160
- json = JSON.encode data
162
+ json = JSON.generate data
161
163
 
162
164
  response = post "server/#{server_uuid}/stop", json
163
165
 
@@ -185,7 +187,7 @@ class UpcloudApi
185
187
  }
186
188
  data["stop_server"]["timeout"] = timeout unless timeout.nil?
187
189
 
188
- json = JSON.encode data
190
+ json = JSON.generate data
189
191
 
190
192
  response = post "server/#{server_uuid}/restart", json
191
193
 
@@ -199,14 +201,14 @@ class UpcloudApi
199
201
  end
200
202
 
201
203
  def post action, body = ""
202
- HTTParty.post "https://api.upcloud.com/1.2/#{action}", basic_auth: @auth, body: body
204
+ HTTParty.post "https://api.upcloud.com/1.2/#{action}", basic_auth: @auth, body: body, headers: { "Content-Type" => "application/json" }
203
205
  end
204
206
 
205
207
  def put action, body = ""
206
- HTTParty.put "https://api.upcloud.com/1.2/#{action}", basic_auth: @auth, body: body
208
+ HTTParty.put "https://api.upcloud.com/1.2/#{action}", basic_auth: @auth, body: body, headers: { "Content-Type" => "application/json" }
207
209
  end
208
210
 
209
211
  def delete action, body = ""
210
- HTTParty.delete "https://api.upcloud.com/1.2/#{action}", basic_auth: @auth
212
+ HTTParty.delete "https://api.upcloud.com/1.2/#{action}", basic_auth: @auth, headers: { "Content-Type" => "application/json" }
211
213
  end
212
214
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upcloud_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0.pre.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samu Voutilainen
@@ -48,9 +48,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
48
  version: '0'
49
49
  required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - ">"
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: 1.3.1
54
54
  requirements: []
55
55
  rubyforge_project:
56
56
  rubygems_version: 2.4.6