Class: Heroku::Client::Api

Inherits:
Object
  • Object
show all
Includes:
Http
Defined in:
lib/heroku-client/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Http

#delete, #get, #post, #put, #request

Constructor Details

#initialize(apikey) ⇒ Api



75
76
77
# File 'lib/heroku-client/api.rb', line 75

def initialize(apikey)
  @apikey = apikey
end

Instance Attribute Details

#apikeyObject (readonly)

Returns the value of attribute apikey.



6
7
8
# File 'lib/heroku-client/api.rb', line 6

def apikey
  @apikey
end

Instance Method Details

#apps(*args) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/heroku-client/api.rb', line 8

def apps(*args)
  return get("apps") if args.size == 0

  return get("apps/#{args[0]}") if args.size == 1

  raise "Invalid number of parameters"
end

#collaborators(app_name) ⇒ Object



47
48
49
# File 'lib/heroku-client/api.rb', line 47

def collaborators(app_name)
  return get("apps/#{app_name}/collaborators")
end

#config_vars(app_name) ⇒ Object



51
52
53
# File 'lib/heroku-client/api.rb', line 51

def config_vars(app_name)
  return get("apps/#{app_name}/config_vars")
end

#create_app(params = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/heroku-client/api.rb', line 16

def create_app(params = {})
  post_params = {}

  [:name, :stack].each do |k|
    post_params["app[#{k}]"] = params[k] if params.has_key? k
  end

  post "apps", post_params
end

#delete_app(app_name) ⇒ Object



43
44
45
# File 'lib/heroku-client/api.rb', line 43

def delete_app(app_name)
  delete "apps/#{app_name}"
end

#domains(app_name) ⇒ Object



55
56
57
# File 'lib/heroku-client/api.rb', line 55

def domains(app_name)
  return get("apps/#{app_name}/domains")
end

#keysObject



59
60
61
# File 'lib/heroku-client/api.rb', line 59

def keys
  return get("user/keys")
end

#processes(app_name) ⇒ Object



63
64
65
# File 'lib/heroku-client/api.rb', line 63

def processes(app_name)
  return get("apps/#{app_name}/ps")
end

#releases(app_name) ⇒ Object



67
68
69
# File 'lib/heroku-client/api.rb', line 67

def releases(app_name)
  return get("apps/#{app_name}/releases")
end

#rename_app(old_app_name, new_app_name) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/heroku-client/api.rb', line 26

def rename_app(old_app_name, new_app_name)
  put_params = {}

  put_params["name"] = old_app_name
  put_params["app[name]"] = new_app_name

  put "apps/#{old_app_name}", put_params
end

#stacks(app_name) ⇒ Object



71
72
73
# File 'lib/heroku-client/api.rb', line 71

def stacks(app_name)
  get "apps/#{app_name}/stack"
end

#transfer_app(app_name, new_owner) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/heroku-client/api.rb', line 35

def transfer_app(app_name, new_owner)
  put_params = {}

  put_params["app[transfer_owner]"] = new_owner

  put "apps/#{app_name}", put_params
end