Sha256: 38de20124829fa73be0a9a832fe8a8c4ee5538ccfa85f0a015883a5fb9e3d591

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require "rest-client"
require "json"

module Arukas
    class API
        def initialize(token, secret)
            @url = "https://#{token}:#{secret}@app.arukas.io/api/"
        end

        def get_apps
            RestClient.get @url + "apps/"
        end

        def create_apps(params)
            RestClient.post @url + "apps/", payload=params, {:content_type => :json}
        end

        def get_app(id)
            RestClient.get @url + "apps/#{id}"
        end

        def delete_app(id)
            RestClient.delete @url + "apps/#{id}"
        end

        def get_services
            RestClient.get @url + "services/"
        end

        def get_service(id)
            RestClient.get @url + "services/#{id}"
        end

        def patch_service(id, params)
            RestClient.patch @url + "services/#{id}", payload=params.to_json, {:content_type => :json, :accept => :json}
        end

        def power_on_service(id)
            RestClient.post @url + "services/#{id}/power", payload="", {:content_type => :json}
        end

        def power_off_service(id)
            RestClient.delete @url + "services/#{id}/power"
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arukas-0.2.0 lib/arukas/api.rb