Class: CFoundry::V1::Base

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

Instance Attribute Summary

Attributes inherited from BaseClient

#rest_client

Instance Method Summary collapse

Methods inherited from BaseClient

#delete, #get, #info, #initialize, #password_score, #post, #put, #refresh_token!, #request, #request_raw, #stream_url, #token=, #trace=, #uaa

Constructor Details

This class inherits a constructor from CFoundry::BaseClient

Instance Method Details

#crashes(name) ⇒ Object



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

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

#create_token(payload, email) ⇒ Object



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

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

#create_user(payload) ⇒ Object

Users



21
22
23
24
25
# File 'lib/cfoundry/v1/base.rb', line 21

def create_user(payload)
  p payload
  # no JSON response
  post("users", :content => :json, :payload => payload)
end

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



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

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

#instances(name) ⇒ Object

Applications



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

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

#resource_match(fingerprints) ⇒ Object



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

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

#stats(name) ⇒ Object



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

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

#system_runtimesObject



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

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

#system_servicesObject



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

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

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



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/cfoundry/v1/base.rb', line 53

def upload_app(name, zipfile = nil, 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("apps", name, "application", :payload => payload)
rescue EOFError
  retry
end