Sha256: 35222333e84446c01bc55267da7deaec5fc01d26186402bd236941e344315f37
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
require "cfoundry/restclient" require "cfoundry/app" require "cfoundry/service" require "cfoundry/user" module CFoundry class Client attr_reader :rest def initialize(*args) @rest = RESTClient.new(*args) end def target @rest.target end def proxy @rest.proxy end def proxy=(x) @rest.proxy = x end # Cloud metadata def info @rest.info end def system_services @rest.system_services end def system_runtimes @rest.system_runtimes end # Users def users @rest.users.collect do |json| CFoundry::User.new( json["email"], self, { "email" => json["email"], "admin" => json["admin"] }) end end def user(email) CFoundry::User.new(email, self) end def register(email, password) @rest.create_user(:email => email, :password => password) user(email) end def login(email, password) @rest.token = @rest.create_token({ :password => password }, email)["token"] end def logout @rest.token = nil end def logged_in? !!@rest.token end # Applications def apps @rest.apps.collect do |json| CFoundry::App.new(json["name"], self, json) end end def app(name) CFoundry::App.new(name, self) end # Services def services @rest.services.collect do |json| CFoundry::Service.new(json["name"], self, json) end end def service(name) CFoundry::Service.new(name, self) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cfoundry-0.1.1 | lib/cfoundry/client.rb |
cfoundry-0.1.0 | lib/cfoundry/client.rb |