Class: Scalarium::API
- Inherits:
-
AbstractAPI
- Object
- AbstractAPI
- Scalarium::API
- Defined in:
- lib/scalarium-api-wrapper/api.rb
Instance Method Summary collapse
-
#deploy_application(app_id, options = {:comment => nil, :migrate => false}) ⇒ Hash
Method allows to deploy application in scalarium.
-
#fetch_all_deployments(app_id) ⇒ Array
Method allows to fetch all the deployments for the specified application.
-
#fetch_deployment_details(app_id, deployment_id) ⇒ Hash
Method pings scalarium to check the details of the deploy (i.e. progress).
-
#get_applications ⇒ Array
Method fetches all applications on the server.
-
#get_cloud(cloud_id) ⇒ Hash
Method gets single could details.
-
#get_cloud_instances(cloud_id) ⇒ Array
Method obtains instances of the cloud.
-
#get_cloud_roles(cloud_id) ⇒ Array
Method obtains roles per cloud.
-
#get_clouds(cloud_id = nil) ⇒ Array, Hash
Method fetches all clouds on the server .
-
#get_instance_of_cloud(cloud_id, instance_of_cloud_id) ⇒ Hash
Method obtains details of specified instance for a given cloud.
-
#send_instance_command(cloud_id, instance_id, command) ⇒ Object
Method allows to send command to the instance of specified cloud.
Instance Method Details
#deploy_application(app_id, options = {:comment => nil, :migrate => false}) ⇒ Hash
Method allows to deploy application in scalarium
105 106 107 108 109 110 |
# File 'lib/scalarium-api-wrapper/api.rb', line 105 def deploy_application(app_id, = {:comment => nil, :migrate => false}) json_command = JSON.dump(:command => 'deploy', :comment => [:comment], :migrate => [:migrate]) http_post_request(Scalarium.applications_url+"/#{app_id}/deploy", json_command) end |
#fetch_all_deployments(app_id) ⇒ Array
Method allows to fetch all the deployments for the specified application
91 92 93 94 |
# File 'lib/scalarium-api-wrapper/api.rb', line 91 def fetch_all_deployments(app_id) warn "[WARRNING!] This functionality might not be yet supported by Scalarium!" http_get_request(Scalarium.applications_url+"/#{app_id}/deployments/#{deployment_id}") end |
#fetch_deployment_details(app_id, deployment_id) ⇒ Hash
Method pings scalarium to check the details of the deploy (i.e. progress)
82 83 84 |
# File 'lib/scalarium-api-wrapper/api.rb', line 82 def fetch_deployment_details(app_id, deployment_id) http_get_request(Scalarium.applications_url+"/#{app_id}/deployments/#{deployment_id}") end |
#get_applications ⇒ Array
Method fetches all applications on the server
71 72 73 |
# File 'lib/scalarium-api-wrapper/api.rb', line 71 def get_applications http_get_request(Scalarium.applications_url) end |
#get_cloud(cloud_id) ⇒ Hash
Method gets single could details
22 23 24 |
# File 'lib/scalarium-api-wrapper/api.rb', line 22 def get_cloud(cloud_id) http_get_request(Scalarium.clouds_url+"/#{cloud_id}") end |
#get_cloud_instances(cloud_id) ⇒ Array
Method obtains instances of the cloud
40 41 42 |
# File 'lib/scalarium-api-wrapper/api.rb', line 40 def get_cloud_instances(cloud_id) http_get_request(Scalarium.clouds_url+"/#{cloud_id}/instances") end |
#get_cloud_roles(cloud_id) ⇒ Array
Method obtains roles per cloud
31 32 33 |
# File 'lib/scalarium-api-wrapper/api.rb', line 31 def get_cloud_roles(cloud_id) http_get_request(Scalarium.clouds_url+"/#{cloud_id}/roles") end |
#get_clouds(cloud_id = nil) ⇒ Array, Hash
Method fetches all clouds on the server
or when param is passed it gets the particular cloud and
12 13 14 15 |
# File 'lib/scalarium-api-wrapper/api.rb', line 12 def get_clouds(cloud_id=nil) return get_cloud(cloud_id) unless cloud_id.nil? http_get_request(Scalarium.clouds_url) end |
#get_instance_of_cloud(cloud_id, instance_of_cloud_id) ⇒ Hash
Method obtains details of specified instance for a given cloud
50 51 52 |
# File 'lib/scalarium-api-wrapper/api.rb', line 50 def get_instance_of_cloud(cloud_id, instance_of_cloud_id) http_get_request(Scalarium.clouds_url+"/#{cloud_id}/instances/#{instance_of_cloud_id}") end |
#send_instance_command(cloud_id, instance_id, command) ⇒ Object
Method allows to send command to the instance of specified cloud
60 61 62 63 64 65 |
# File 'lib/scalarium-api-wrapper/api.rb', line 60 def send_instance_command(cloud_id, instance_id, command) commands = [:start, :reboot, :stop] raise ArgumentError, "You have passed wrong command allowed ones are: #{commands}" if !commands.include?(command) http_post_request(Scalarium.clouds_url+"/#{cloud_id}/instances/#{instance_id}/#{command.to_s}") end |