Class: CFoundry::V1::Base

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

Constant Summary

Constants inherited from BaseClient

BaseClient::LOG_LENGTH

Instance Attribute Summary collapse

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
# File 'lib/cfoundry/v1/base.rb', line 12

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

Instance Attribute Details

#backtraceObject

Returns the value of attribute backtrace.



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

def backtrace
  @backtrace
end

#logObject

Returns the value of attribute log.



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

def log
  @log
end

#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



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

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

#appsObject

Applications



75
76
77
# File 'lib/cfoundry/v1/base.rb', line 75

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

#check_resources(fingerprints) ⇒ Object



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

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

#crashes(name) ⇒ Object



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

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

#create_app(payload) ⇒ Object



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

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

#create_service(manifest) ⇒ Object



140
141
142
# File 'lib/cfoundry/v1/base.rb', line 140

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

#create_token(payload, email) ⇒ Object



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

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

#create_user(payload) ⇒ Object



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

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

#delete_app(name) ⇒ Object



104
105
106
107
# File 'lib/cfoundry/v1/base.rb', line 104

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

#delete_service(name) ⇒ Object



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

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

#delete_user(email) ⇒ Object



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

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

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



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

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

#infoObject

Cloud metadata



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

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

#instances(name) ⇒ Object



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

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

#service(name) ⇒ Object



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

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

#servicesObject

Services



136
137
138
# File 'lib/cfoundry/v1/base.rb', line 136

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

#stats(name) ⇒ Object



109
110
111
# File 'lib/cfoundry/v1/base.rb', line 109

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

#system_runtimesObject



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

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

#system_servicesObject



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

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

#uaaObject

The UAA used for this client.

‘false` if no UAA (legacy)



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cfoundry/v1/base.rb', line 22

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



100
101
102
# File 'lib/cfoundry/v1/base.rb', line 100

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

#update_user(email, payload) ⇒ Object



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

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

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



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/cfoundry/v1/base.rb', line 117

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



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

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

#usersObject

Users



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

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