scalr_api_v2 0.1.1 → 0.2.0
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 +4 -4
- data/.rubocop.yml +2 -2
- data/CHANGELOG +8 -0
- data/README.md +2 -2
- data/lib/scalr_api_v2/config.rb +14 -4
- data/lib/scalr_api_v2/farms.rb +1 -1
- data/lib/scalr_api_v2/scripts.rb +7 -7
- data/lib/scalr_api_v2/servers.rb +1 -1
- data/lib/scalr_api_v2/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88fb75c5f8f55a72130481651889c0ab9c56823d
|
4
|
+
data.tar.gz: 937534bc0d5823556136a50e7c41300b4c3d10e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 293b1980f69372cae7726c239909a8929e85d5bd9e576d5191b1c501e3c77a1f4356a78b96b4abbd3659f242fde4876ff33296958b80464cf68535f3b96037df
|
7
|
+
data.tar.gz: a413e910a14eb2b0aa9014267d10774742418a94636f8cfb65c13bbe8621d6293406bce661e2cbd2f5d3fe606a22cfa098c9dec09bc4d5a1c7857951a7e4e3de
|
data/.rubocop.yml
CHANGED
@@ -23,10 +23,10 @@ Metrics/LineLength:
|
|
23
23
|
# Offense count: 1
|
24
24
|
# Configuration parameters: CountComments.
|
25
25
|
Metrics/MethodLength:
|
26
|
-
Max:
|
26
|
+
Max: 100
|
27
27
|
|
28
28
|
Metrics/BlockLength:
|
29
|
-
Max:
|
29
|
+
Max: 100
|
30
30
|
|
31
31
|
# Offense count: 1
|
32
32
|
# Configuration parameters: MinBodyLength.
|
data/CHANGELOG
ADDED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[](https://travis-ci.org/autotraderuk/scalr_api_v2)
|
1
|
+
[](https://travis-ci.org/autotraderuk/scalr_api_v2) [](https://badge.fury.io/rb/scalr_api_v2)
|
2
2
|
# ScalrApiV2
|
3
3
|
|
4
4
|
Ruby gem to allow you to develop against V2 of the [SCALR API](https://api-explorer.scalr.com)
|
@@ -26,7 +26,7 @@ Set the below environment variables:
|
|
26
26
|
export SCALR_API_KEY=your-api-key
|
27
27
|
export SCALR_API_SECRET=your-api-secret
|
28
28
|
export SCALR_URL=scalr-api-url
|
29
|
-
export SCALR_ENV_ID=id-of-desired-environment
|
29
|
+
export SCALR_ENV_ID=id-of-desired-environment (optional determines if request is sent as user or account i.e 'GET /api/v1beta0/account/scripts/' or 'GET /api/v1beta0/user/envId/scripts/'. defaults to account mode.)
|
30
30
|
|
31
31
|
### in your code
|
32
32
|
|
data/lib/scalr_api_v2/config.rb
CHANGED
@@ -3,17 +3,27 @@ module ScalrApiV2
|
|
3
3
|
class Config
|
4
4
|
def initialize; end
|
5
5
|
|
6
|
+
def mode_path(env_id)
|
7
|
+
mode = if env_id.nil?
|
8
|
+
'account'
|
9
|
+
else
|
10
|
+
Integer(env_id) >= 0 ? 'user' : 'account'
|
11
|
+
end
|
12
|
+
return mode == 'account' ? 'account' : "user/#{env_id}"
|
13
|
+
end
|
14
|
+
|
6
15
|
def config
|
7
16
|
config = {}
|
8
17
|
|
9
|
-
if ENV['SCALR_URL'].nil? || ENV['SCALR_KEY_ID'].nil? || ENV['SCALR_KEY_SECRET'].nil?
|
10
|
-
config['error'] = 'Missing Environment variables, please configure SCALR_URL, SCALR_KEY_ID, SCALR_KEY_SECRET
|
11
|
-
raise 'Missing Environment variables, please configure SCALR_URL, SCALR_KEY_ID, SCALR_KEY_SECRET
|
18
|
+
if ENV['SCALR_URL'].nil? || ENV['SCALR_KEY_ID'].nil? || ENV['SCALR_KEY_SECRET'].nil?
|
19
|
+
config['error'] = 'Missing Environment variables, please configure SCALR_URL, SCALR_KEY_ID, SCALR_KEY_SECRET'
|
20
|
+
raise 'Missing Environment variables, please configure SCALR_URL, SCALR_KEY_ID, SCALR_KEY_SECRET'
|
12
21
|
else
|
13
22
|
config['url'] = ENV['SCALR_URL']
|
14
23
|
config['key_id'] = ENV['SCALR_KEY_ID']
|
15
24
|
config['key_secret'] = ENV['SCALR_KEY_SECRET']
|
16
|
-
config['env_id'] = ENV['SCALR_ENV_ID']
|
25
|
+
config['env_id'] = ENV['SCALR_ENV_ID'].nil? ? nil : ENV['SCALR_ENV_ID']
|
26
|
+
config['mode_path'] = mode_path(config['env_id'])
|
17
27
|
end
|
18
28
|
return config
|
19
29
|
end
|
data/lib/scalr_api_v2/farms.rb
CHANGED
data/lib/scalr_api_v2/scripts.rb
CHANGED
@@ -18,43 +18,43 @@ module ScalrApiV2
|
|
18
18
|
|
19
19
|
# List all scripts
|
20
20
|
def list
|
21
|
-
list = @scalr.list(format('/api/v1beta0
|
21
|
+
list = @scalr.list(format('/api/v1beta0/%s/scripts/', @config['mode_path']))
|
22
22
|
return list
|
23
23
|
end
|
24
24
|
|
25
25
|
# List all script versions
|
26
26
|
def versions(script_id = 1)
|
27
|
-
list = @scalr.list(format('/api/v1beta0
|
27
|
+
list = @scalr.list(format('/api/v1beta0/%s/scripts/%s/script-versions/', @config['mode_path'], script_id))
|
28
28
|
return list
|
29
29
|
end
|
30
30
|
|
31
31
|
# Create script accepts script_object as hash and generates JSON before making SCALR api call
|
32
32
|
def create(script_object)
|
33
|
-
item = @scalr.create(format('/api/v1beta0
|
33
|
+
item = @scalr.create(format('/api/v1beta0/%s/scripts/', @config['mode_path']), JSON.generate(script_object))
|
34
34
|
return item
|
35
35
|
end
|
36
36
|
|
37
37
|
# Create script version
|
38
38
|
def create_version(script_id, script_object)
|
39
|
-
item = @scalr.create(format('/api/v1beta0
|
39
|
+
item = @scalr.create(format('/api/v1beta0/%s/scripts/%s/script-versions/', @config['mode_path'], script_id), JSON.generate(script_object))
|
40
40
|
return item
|
41
41
|
end
|
42
42
|
|
43
43
|
# Update script version
|
44
44
|
def update_version(script_id, script_version, script_object)
|
45
|
-
item = @scalr.patch(format('/api/v1beta0
|
45
|
+
item = @scalr.patch(format('/api/v1beta0/%s/scripts/%s/script-versions/%s/', @config['mode_path'], script_id, script_version), JSON.generate(script_object))
|
46
46
|
return item
|
47
47
|
end
|
48
48
|
|
49
49
|
# execute version
|
50
50
|
def execute(script_id, script_execution_object)
|
51
|
-
item = @scalr.post(format('/api/v1beta0
|
51
|
+
item = @scalr.post(format('/api/v1beta0/%s/scripts/%s/actions/execute', @config['mode_path'], script_id), JSON.generate(script_execution_object))
|
52
52
|
return item
|
53
53
|
end
|
54
54
|
|
55
55
|
# execute script version
|
56
56
|
def execute_version(script_id, script_version, script_execution_object)
|
57
|
-
item = @scalr.post(format('/api/v1beta0
|
57
|
+
item = @scalr.post(format('/api/v1beta0/%s/scripts/%s/script-versions/%s/actions/execute', @config['mode_path'], script_id, script_version), JSON.generate(script_execution_object))
|
58
58
|
return item
|
59
59
|
end
|
60
60
|
end
|
data/lib/scalr_api_v2/servers.rb
CHANGED
data/lib/scalr_api_v2/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scalr_api_v2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- david.meekin
|
@@ -205,6 +205,7 @@ files:
|
|
205
205
|
- .rspec
|
206
206
|
- .rubocop.yml
|
207
207
|
- .travis.yml
|
208
|
+
- CHANGELOG
|
208
209
|
- CODE_OF_CONDUCT.md
|
209
210
|
- Gemfile
|
210
211
|
- LICENSE.txt
|