Class: CFoundry::V1::Base

Inherits:
BaseClient show all
Defined in:
lib/cfoundry/v1/base.rb

Instance Attribute Summary collapse

Attributes inherited from BaseClient

#no_backtrace

Instance Method Summary collapse

Methods inherited from BaseClient

#request_path, #token_data

Constructor Details

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

Returns a new instance of Base.



12
13
14
15
16
17
# File 'lib/cfoundry/v1/base.rb', line 12

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

Instance Attribute Details

#proxyObject

Returns the value of attribute proxy.



10
11
12
# File 'lib/cfoundry/v1/base.rb', line 10

def proxy
  @proxy
end

#targetObject

Returns the value of attribute target.



10
11
12
# File 'lib/cfoundry/v1/base.rb', line 10

def target
  @target
end

#tokenObject

Returns the value of attribute token.



10
11
12
# File 'lib/cfoundry/v1/base.rb', line 10

def token
  @token
end

#traceObject

Returns the value of attribute trace.



10
11
12
# File 'lib/cfoundry/v1/base.rb', line 10

def trace
  @trace
end

Instance Method Details

#app(name) ⇒ Object



90
91
92
# File 'lib/cfoundry/v1/base.rb', line 90

def app(name)
  get("apps", name, nil => :json)
end

#appsObject

Applications



82
83
84
# File 'lib/cfoundry/v1/base.rb', line 82

def apps
  get("apps", nil => :json)
end

#check_resources(fingerprints) ⇒ Object



120
121
122
# File 'lib/cfoundry/v1/base.rb', line 120

def check_resources(fingerprints)
  post(fingerprints, "resources", :json => :json)
end

#crashes(name) ⇒ Object



98
99
100
# File 'lib/cfoundry/v1/base.rb', line 98

def crashes(name)
  get("apps", name, "crashes", nil => :json)[:crashes]
end

#create_app(payload) ⇒ Object



86
87
88
# File 'lib/cfoundry/v1/base.rb', line 86

def create_app(payload)
  post(payload, "apps", :json => :json)
end

#create_service(manifest) ⇒ Object



147
148
149
# File 'lib/cfoundry/v1/base.rb', line 147

def create_service(manifest)
  post(manifest, "services", :json => :json)
end

#create_token(payload, email) ⇒ Object



77
78
79
# File 'lib/cfoundry/v1/base.rb', line 77

def create_token(payload, email)
  post(payload, "users", email, "tokens", :json => :json)
end

#create_user(payload) ⇒ Object



60
61
62
# File 'lib/cfoundry/v1/base.rb', line 60

def create_user(payload)
  post(payload, "users", :json => nil)
end

#delete_app(name) ⇒ Object



111
112
113
114
# File 'lib/cfoundry/v1/base.rb', line 111

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

#delete_service(name) ⇒ Object



155
156
157
158
# File 'lib/cfoundry/v1/base.rb', line 155

def delete_service(name)
  delete("services", name, nil => :json)
  true
end

#delete_user(email) ⇒ Object



68
69
70
71
# File 'lib/cfoundry/v1/base.rb', line 68

def delete_user(email)
  delete("users", email, nil => :json)
  true
end

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



102
103
104
# File 'lib/cfoundry/v1/base.rb', line 102

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

#infoObject

Cloud metadata



43
44
45
# File 'lib/cfoundry/v1/base.rb', line 43

def info
  get("info", nil => :json)
end

#instances(name) ⇒ Object



94
95
96
# File 'lib/cfoundry/v1/base.rb', line 94

def instances(name)
  get("apps", name, "instances", nil => :json)[:instances]
end

#service(name) ⇒ Object



151
152
153
# File 'lib/cfoundry/v1/base.rb', line 151

def service(name)
  get("services", name, nil => :json)
end

#servicesObject

Services



143
144
145
# File 'lib/cfoundry/v1/base.rb', line 143

def services
  get("services", nil => :json)
end

#stats(name) ⇒ Object



116
117
118
# File 'lib/cfoundry/v1/base.rb', line 116

def stats(name)
  get("apps", name, "stats", nil => :json)
end

#system_runtimesObject



51
52
53
# File 'lib/cfoundry/v1/base.rb', line 51

def system_runtimes
  get("info", "runtimes", nil => :json)
end

#system_servicesObject



47
48
49
# File 'lib/cfoundry/v1/base.rb', line 47

def system_services
  get("info", "services", nil => :json)
end

#uaaObject

The UAA used for this client.

‘false` if no UAA (legacy)



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cfoundry/v1/base.rb', line 29

def uaa
  return @uaa unless @uaa.nil?

  endpoint = info[:authorization_endpoint]
  return @uaa = false unless endpoint

  @uaa = CFoundry::UAAClient.new(endpoint)
  @uaa.trace = @trace
  @uaa.token = @token
  @uaa
end

#update_app(name, payload) ⇒ Object



107
108
109
# File 'lib/cfoundry/v1/base.rb', line 107

def update_app(name, payload)
  put(payload, "apps", name, :json => nil)
end

#update_user(email, payload) ⇒ Object



73
74
75
# File 'lib/cfoundry/v1/base.rb', line 73

def update_user(email, payload)
  put(payload, "users", email, :json => nil)
end

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



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/cfoundry/v1/base.rb', line 124

def upload_app(name, zipfile, resources = [])
  payload = {
    :_method => "put",
    :resources => MultiJson.dump(resources),
    :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



64
65
66
# File 'lib/cfoundry/v1/base.rb', line 64

def user(email)
  get("users", email, nil => :json)
end

#usersObject

Users



56
57
58
# File 'lib/cfoundry/v1/base.rb', line 56

def users
  get("users", nil => :json)
end