Class: ScalrApiV2::Scripts
- Inherits:
-
Object
- Object
- ScalrApiV2::Scripts
- Defined in:
- lib/scalr_api_v2/scripts.rb
Overview
connection and request methods for interacting with the Scalr API
Instance Method Summary collapse
-
#create(script_object) ⇒ Object
Create script accepts script_object as hash and generates JSON before making SCALR api call.
-
#create_version(script_id, script_object) ⇒ Object
Create script version.
-
#execute(script_id, script_execution_object) ⇒ Object
execute version.
-
#execute_version(script_id, script_version, script_execution_object) ⇒ Object
execute script version.
-
#initialize ⇒ Scripts
constructor
A new instance of Scripts.
-
#list ⇒ Object
List all scripts.
-
#update_version(script_id, script_version, script_object) ⇒ Object
Update script version.
-
#versions(script_id = 1) ⇒ Object
List all script versions.
Constructor Details
#initialize ⇒ Scripts
Returns a new instance of Scripts.
14 15 16 17 |
# File 'lib/scalr_api_v2/scripts.rb', line 14 def initialize @config = ScalrApiV2::Config.new.config @scalr = ScalrApiV2::Request.new end |
Instance Method Details
#create(script_object) ⇒ Object
Create script accepts script_object as hash and generates JSON before making SCALR api call
32 33 34 35 |
# File 'lib/scalr_api_v2/scripts.rb', line 32 def create(script_object) item = @scalr.create(format('/api/v1beta0/%s/scripts/', @config['mode_path']), JSON.generate(script_object)) return item end |
#create_version(script_id, script_object) ⇒ Object
Create script version
38 39 40 41 |
# File 'lib/scalr_api_v2/scripts.rb', line 38 def create_version(script_id, script_object) item = @scalr.create(format('/api/v1beta0/%s/scripts/%s/script-versions/', @config['mode_path'], script_id), JSON.generate(script_object)) return item end |
#execute(script_id, script_execution_object) ⇒ Object
execute version
50 51 52 53 |
# File 'lib/scalr_api_v2/scripts.rb', line 50 def execute(script_id, script_execution_object) item = @scalr.post(format('/api/v1beta0/%s/scripts/%s/actions/execute', @config['mode_path'], script_id), JSON.generate(script_execution_object)) return item end |
#execute_version(script_id, script_version, script_execution_object) ⇒ Object
execute script version
56 57 58 59 |
# File 'lib/scalr_api_v2/scripts.rb', line 56 def execute_version(script_id, script_version, script_execution_object) 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)) return item end |
#list ⇒ Object
List all scripts
20 21 22 23 |
# File 'lib/scalr_api_v2/scripts.rb', line 20 def list list = @scalr.list(format('/api/v1beta0/%s/scripts/', @config['mode_path'])) return list end |
#update_version(script_id, script_version, script_object) ⇒ Object
Update script version
44 45 46 47 |
# File 'lib/scalr_api_v2/scripts.rb', line 44 def update_version(script_id, script_version, script_object) item = @scalr.patch(format('/api/v1beta0/%s/scripts/%s/script-versions/%s/', @config['mode_path'], script_id, script_version), JSON.generate(script_object)) return item end |
#versions(script_id = 1) ⇒ Object
List all script versions
26 27 28 29 |
# File 'lib/scalr_api_v2/scripts.rb', line 26 def versions(script_id = 1) list = @scalr.list(format('/api/v1beta0/%s/scripts/%s/script-versions/', @config['mode_path'], script_id)) return list end |