Class: CFoundry::RESTClient

Inherits:
Object
  • Object
show all
Defined in:
lib/cfoundry/restclient.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target = "http://api.cloudfoundry.com", token = nil) ⇒ RESTClient

Returns a new instance of RESTClient.



11
12
13
14
15
16
# File 'lib/cfoundry/restclient.rb', line 11

def initialize(
    target = "http://api.cloudfoundry.com",
    token = nil)
  @target = target
  @token = token
end

Instance Attribute Details

#proxyObject

Returns the value of attribute proxy.



9
10
11
# File 'lib/cfoundry/restclient.rb', line 9

def proxy
  @proxy
end

#targetObject

Returns the value of attribute target.



9
10
11
# File 'lib/cfoundry/restclient.rb', line 9

def target
  @target
end

#tokenObject

Returns the value of attribute token.



9
10
11
# File 'lib/cfoundry/restclient.rb', line 9

def token
  @token
end

#traceObject

Returns the value of attribute trace.



9
10
11
# File 'lib/cfoundry/restclient.rb', line 9

def trace
  @trace
end

Instance Method Details

#app(name) ⇒ Object



66
67
68
# File 'lib/cfoundry/restclient.rb', line 66

def app(name)
  json_get("apps", name)
end

#appsObject

Applications



58
59
60
# File 'lib/cfoundry/restclient.rb', line 58

def apps
  json_get("apps")
end

#check_resources(fingerprints) ⇒ Object



92
93
94
# File 'lib/cfoundry/restclient.rb', line 92

def check_resources(fingerprints)
  json_post(fingerprints.to_json, "resources")
end

#create_app(payload) ⇒ Object



62
63
64
# File 'lib/cfoundry/restclient.rb', line 62

def create_app(payload)
  json_post(payload.to_json, "apps")
end

#create_service(manifest) ⇒ Object



119
120
121
# File 'lib/cfoundry/restclient.rb', line 119

def create_service(manifest)
  json_post(manifest.to_json, "services")
end

#create_token(payload, email) ⇒ Object



53
54
55
# File 'lib/cfoundry/restclient.rb', line 53

def create_token(payload, email)
  json_post(payload.to_json, "users", email, "tokens")
end

#create_user(payload) ⇒ Object



36
37
38
# File 'lib/cfoundry/restclient.rb', line 36

def create_user(payload)
  post(payload.to_json, "users")
end

#delete_app(name) ⇒ Object



83
84
85
86
# File 'lib/cfoundry/restclient.rb', line 83

def delete_app(name)
  delete("apps", name)
  true
end

#delete_service(name) ⇒ Object



127
128
129
130
# File 'lib/cfoundry/restclient.rb', line 127

def delete_service(name)
  delete("services", name)
  true
end

#delete_user(email) ⇒ Object



44
45
46
47
# File 'lib/cfoundry/restclient.rb', line 44

def delete_user(email)
  delete("users", email)
  true
end

#files(name, instance, *path) ⇒ Object Also known as: file



74
75
76
# File 'lib/cfoundry/restclient.rb', line 74

def files(name, instance, *path)
  get("apps", name, "instances", instance, "files", *path)
end

#infoObject

Cloud metadata



19
20
21
# File 'lib/cfoundry/restclient.rb', line 19

def info
  json_get("info")
end

#instances(name) ⇒ Object



70
71
72
# File 'lib/cfoundry/restclient.rb', line 70

def instances(name)
  json_get("apps", name, "instances")["instances"]
end

#service(name) ⇒ Object



123
124
125
# File 'lib/cfoundry/restclient.rb', line 123

def service(name)
  json_get("services", name)
end

#servicesObject

Services



115
116
117
# File 'lib/cfoundry/restclient.rb', line 115

def services
  json_get("services")
end

#stats(name) ⇒ Object



88
89
90
# File 'lib/cfoundry/restclient.rb', line 88

def stats(name)
  json_get("apps", name, "stats")
end

#system_runtimesObject



27
28
29
# File 'lib/cfoundry/restclient.rb', line 27

def system_runtimes
  json_get("info", "runtimes")
end

#system_servicesObject



23
24
25
# File 'lib/cfoundry/restclient.rb', line 23

def system_services
  json_get("info", "services")
end

#update_app(name, payload) ⇒ Object



79
80
81
# File 'lib/cfoundry/restclient.rb', line 79

def update_app(name, payload)
  put(payload.to_json, "apps", name)
end

#update_user(email, payload) ⇒ Object



49
50
51
# File 'lib/cfoundry/restclient.rb', line 49

def update_user(email, payload)
  put(payload.to_json, "users", email)
end

#upload_app(name, zipfile, resources = []) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/cfoundry/restclient.rb', line 96

def upload_app(name, zipfile, resources = [])
  payload = {
    :_method => "put",
    :resources => resources.to_json,
    :multipart => true,
    :application =>
      if zipfile.is_a? File
        zipfile
      elsif zipfile.is_a? String
        File.new(zipfile, "rb")
      end
  }

  post(payload, "apps", name, "application")
rescue RestClient::ServerBrokeConnection
  retry
end

#user(email) ⇒ Object



40
41
42
# File 'lib/cfoundry/restclient.rb', line 40

def user(email)
  json_get("users", email)
end

#usersObject

Users



32
33
34
# File 'lib/cfoundry/restclient.rb', line 32

def users
  json_get("users")
end