Class: CFoundry::V1::Base

Inherits:
BaseClient show all
Includes:
BaseClientMethods
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, #request_path, #request_uri, #token_data

Constructor Details

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

Returns a new instance of Base.



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

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

Instance Attribute Details

#backtraceObject

Returns the value of attribute backtrace.



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

def backtrace
  @backtrace
end

#logObject

Returns the value of attribute log.



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

def log
  @log
end

#proxyObject

Returns the value of attribute proxy.



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

def proxy
  @proxy
end

#targetObject

Returns the value of attribute target.



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

def target
  @target
end

#tokenObject

Returns the value of attribute token.



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

def token
  @token
end

#traceObject

Returns the value of attribute trace.



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

def trace
  @trace
end

Instance Method Details

#crashes(name) ⇒ Object



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

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

#create_token(payload, email) ⇒ Object

Users



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

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

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



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

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

#infoObject

Cloud metadata



38
39
40
# File 'lib/cfoundry/v1/base.rb', line 38

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

#instances(name) ⇒ Object

Applications



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

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

#resource_match(fingerprints) ⇒ Object



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

def resource_match(fingerprints)
  post(fingerprints, "resources", :content => :json, :accept => :json)
end

#stats(name) ⇒ Object



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

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

#system_runtimesObject



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

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

#system_servicesObject



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

def system_services
  get("services", "v1", "offerings", :content => :json, :accept => :json)
end

#uaaObject

The UAA used for this client.

‘false` if no UAA (legacy)



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

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

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



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/cfoundry/v1/base.rb', line 78

def upload_app(name, zipfile, resources = [])
  payload = {
    :_method => "put",
    :resources => MultiJson.dump(resources),
    :application =>
      UploadIO.new(
        if zipfile.is_a? File
          zipfile
        elsif zipfile.is_a? String
          File.new(zipfile, "rb")
        end,
        "application/zip")
  }

  post(payload, "apps", name, "application")
rescue EOFError
  retry
end