hilarity-api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/README.md +127 -0
- data/Rakefile +10 -0
- data/changelog.txt +3 -0
- data/hilarity-api.gemspec +25 -0
- data/lib/hilarity-api.rb +1 -0
- data/lib/hilarity/api.rb +143 -0
- data/lib/hilarity/api/apps.rb +71 -0
- data/lib/hilarity/api/config_vars.rb +33 -0
- data/lib/hilarity/api/domains.rb +42 -0
- data/lib/hilarity/api/errors.rb +28 -0
- data/lib/hilarity/api/keys.rb +42 -0
- data/lib/hilarity/api/login.rb +14 -0
- data/lib/hilarity/api/user.rb +14 -0
- data/lib/hilarity/api/version.rb +5 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f1ae3a442253b1117e494d6fafaa509acef62f85
|
4
|
+
data.tar.gz: a3745ec63482719134e8f9219dadfc8021287497
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 67231c27b9211f98eac20622610f66f205b3544ef422fc167f28961a6d309e97ac4035ae5140e6bb18f843d1a3c06af9c1e325f72a1dcbab0c44df4420d69298
|
7
|
+
data.tar.gz: 1c4bdcf7b8043a7ce26656230a0c446e2ba25cc1422f3081ab6c019380a177a08dad84b06402b64197e425e7966f34f7781ed7746d2ada3ec9fdbc003ac4b245
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
Hilarity Ruby Client
|
2
|
+
==================
|
3
|
+
|
4
|
+
The Hilarity Ruby Client is used to interact with the [Hilarity API](https://hilarity.io/docs/) from Ruby.
|
5
|
+
|
6
|
+
|
7
|
+
Usage
|
8
|
+
-----
|
9
|
+
|
10
|
+
Start by creating a connection to Hilarity with your credentials:
|
11
|
+
|
12
|
+
require 'hilarity-api'
|
13
|
+
|
14
|
+
hilarity = Hilarity::API.new(:api_key => API_KEY) # use API Key
|
15
|
+
hilarity = Hilarity::API.new(:username => USERNAME, :password => PASSWORD) # use username and password
|
16
|
+
hilarity = Hilarity::API.new(:headers => {'User-Agent' => 'custom'}) # use custom header
|
17
|
+
|
18
|
+
NOTE: You can leave out the `:api_key` if `ENV['HILARITY_API_KEY']` is set instead.
|
19
|
+
|
20
|
+
Now you can make requests to the api.
|
21
|
+
|
22
|
+
Requests
|
23
|
+
--------
|
24
|
+
|
25
|
+
What follows is an overview of commands you can run for the client.
|
26
|
+
|
27
|
+
For additional details about any of the commands, see the [API docs](http://legacy-api-docs.hilarity.io).
|
28
|
+
|
29
|
+
### Add-ons
|
30
|
+
|
31
|
+
hilarity.delete_addon(APP, ADD_ON) # remove the ADD_ON add-on from the app named APP
|
32
|
+
hilarity.post_addon(APP, ADD_ON) # add ADD_ON add-on to an the app named APP
|
33
|
+
hilarity.put_addon(APP, ADD_ON) # update the ADD_ON add-on on the app named APP
|
34
|
+
hilarity.get_addons # see a listing of all available add-ons
|
35
|
+
hilarity.get_addons(APP) # see listing of installed add-ons for the app named APP
|
36
|
+
|
37
|
+
### Apps
|
38
|
+
|
39
|
+
hilarity.delete_app(APP) # delete the app named APP
|
40
|
+
hilarity.get_apps # get a list of your apps
|
41
|
+
hilarity.get_app(APP) # get info about the app named APP
|
42
|
+
hilarity.get_dyno_types(APP) # get dyno types for the app named APP
|
43
|
+
hilarity.post_app # create an app with a generated name and the default stack
|
44
|
+
hilarity.post_app_maintenance(APP, '1') # toggle maintenance mode for the app named APP
|
45
|
+
hilarity.post_app('name' => 'app') # create an app with a specified name, APP
|
46
|
+
hilarity.put_app('name' => 'myapp') # update an app to have a different name
|
47
|
+
|
48
|
+
### Collaborators
|
49
|
+
|
50
|
+
hilarity.delete_collaborator(APP, 'email@example.com') # remove 'email@example.com' collaborator from APP app
|
51
|
+
hilarity.get_collaborators(APP) # list collaborators for APP app
|
52
|
+
hilarity.post_collaborator(APP, 'email@example.com') # add 'email@example.com' collaborator to APP app
|
53
|
+
|
54
|
+
### Config Variables
|
55
|
+
|
56
|
+
hilarity.delete_config_var(APP, KEY) # remove KEY key from APP app
|
57
|
+
hilarity.get_config_vars(APP) # get list of config vars for APP app
|
58
|
+
hilarity.put_config_vars(APP, KEY => 'value') # set KEY key to 'value' for APP app
|
59
|
+
|
60
|
+
### Domains
|
61
|
+
|
62
|
+
hilarity.delete_domain(APP, 'example.com') # remove the 'example.com' domain from the APP app
|
63
|
+
hilarity.get_domains(APP) # list configured domains for the APP app
|
64
|
+
hilarity.post_domain(APP, 'example.com') # add 'example.com' domain to the APP app
|
65
|
+
|
66
|
+
### Keys
|
67
|
+
|
68
|
+
hilarity.delete_key('user@hostname.local') # remove the 'user@hostname.local' key
|
69
|
+
hilarity.delete_keys # remove all keys
|
70
|
+
hilarity.get_keys # list configured keys
|
71
|
+
hilarity.post_key('key data') # add key defined by 'key data'
|
72
|
+
|
73
|
+
### Logs
|
74
|
+
|
75
|
+
hilarity.get_logs(APP) # return logs information for APP app
|
76
|
+
|
77
|
+
### Processes
|
78
|
+
|
79
|
+
hilarity.get_ps(APP) # list current dynos for APP app
|
80
|
+
hilarity.post_ps(APP, 'command') # run 'command' command in context of APP app
|
81
|
+
hilarity.post_ps_restart(APP) # restart all dynos for APP app
|
82
|
+
hilarity.post_ps_scale(APP, TYPE, QTY) # scale TYPE type dynos to QTY for APP app
|
83
|
+
hilarity.post_ps_stop(APP, 'ps' => 'web.1') # stop 'web.1' dyno for APP app
|
84
|
+
hilarity.post_ps_stop(APP, 'type' => 'web') # stop all 'web' dynos for APP app
|
85
|
+
hilarity.post_ps_restart(APP, 'ps' => 'web.1') # restart 'web.1' dyno for APP app
|
86
|
+
hilarity.put_dynos(APP, DYNOS) # set number of dynos for bamboo app APP to DYNOS
|
87
|
+
hilarity.put_workers(APP, WORKERS) # set number of workers for bamboo app APP to WORKERS
|
88
|
+
hilarity.post_ps_scale(APP, 'worker', WORKERS) # set number of workers for cedar app APP to WORKERS
|
89
|
+
hilarity.put_formation(APP, 'web' => '2X') # set dyno size to '2X' for all 'web' dynos for APP app
|
90
|
+
|
91
|
+
### Releases
|
92
|
+
|
93
|
+
hilarity.get_releases(APP) # list of releases for the APP app
|
94
|
+
hilarity.get_release(APP, 'v#') # get details of 'v#' release for APP app
|
95
|
+
hilarity.post_release(APP, 'v#') # rollback APP app to 'v#' release
|
96
|
+
|
97
|
+
### Stacks
|
98
|
+
|
99
|
+
hilarity.get_stack(APP) # list available stacks
|
100
|
+
hilarity.put_stack(APP, STACK) # migrate APP app to STACK stack
|
101
|
+
|
102
|
+
### User
|
103
|
+
|
104
|
+
hilarity.get_user # list user info
|
105
|
+
|
106
|
+
Mock
|
107
|
+
----
|
108
|
+
|
109
|
+
For testing (or practice) you can also use a simulated Hilarity account:
|
110
|
+
|
111
|
+
require 'hilarity-api'
|
112
|
+
|
113
|
+
hilarity = Hilarity::API.new(:api_key => API_KEY, :mock => true)
|
114
|
+
|
115
|
+
Commands will now behave as normal, however, instead of interacting with your actual Hilarity account you'll be interacting with a **blank** test account. Note: test accounts will have NO apps to begin with. You'll need to create one:
|
116
|
+
|
117
|
+
hilarity.post_app(:name => 'my-test-app')
|
118
|
+
|
119
|
+
Tests
|
120
|
+
-----
|
121
|
+
|
122
|
+
To run tests, first set `ENV['HEROKU_API_KEY']` to your api key. Then use `bundle exec rake` to run mock tests or `MOCK=false bundle exec rake` to run integration tests.
|
123
|
+
|
124
|
+
Meta
|
125
|
+
----
|
126
|
+
|
127
|
+
Released under the [MIT license](http://www.opensource.org/licenses/mit-license.php).
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
task :cache, [:api_key] do |task, args|
|
4
|
+
unless args.api_key
|
5
|
+
puts('cache requires an api key, please call as `cache[api_key]`')
|
6
|
+
else
|
7
|
+
require "#{File.dirname(__FILE__)}/lib/hilarity/api"
|
8
|
+
hilarity = Hilarity::API.new(:api_key => args.api_key)
|
9
|
+
end
|
10
|
+
end
|
data/changelog.txt
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "hilarity/api/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "hilarity-api"
|
7
|
+
s.version = Hilarity::API::VERSION
|
8
|
+
s.authors = ["Zane Shannon"]
|
9
|
+
s.email = ["zcs@hilarity.io"]
|
10
|
+
s.homepage = "http://github.com/hilarity/hilarity.rb"
|
11
|
+
s.license = 'MIT'
|
12
|
+
s.summary = %q{Ruby Client for the Hilarity API}
|
13
|
+
s.description = %q{Ruby Client for the Hilarity API}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_runtime_dependency 'excon', '~>0.38'
|
21
|
+
s.add_runtime_dependency 'multi_json', '~>1.8'
|
22
|
+
|
23
|
+
s.add_development_dependency 'minitest'
|
24
|
+
s.add_development_dependency 'rake'
|
25
|
+
end
|
data/lib/hilarity-api.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require(File.join(File.dirname(__FILE__), "hilarity", "api"))
|
data/lib/hilarity/api.rb
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
require "base64"
|
2
|
+
require "cgi"
|
3
|
+
require "excon"
|
4
|
+
require "multi_json"
|
5
|
+
require "securerandom"
|
6
|
+
require "uri"
|
7
|
+
require "zlib"
|
8
|
+
|
9
|
+
__LIB_DIR__ = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
10
|
+
unless $LOAD_PATH.include?(__LIB_DIR__)
|
11
|
+
$LOAD_PATH.unshift(__LIB_DIR__)
|
12
|
+
end
|
13
|
+
|
14
|
+
require "hilarity/api/errors"
|
15
|
+
require "hilarity/api/version"
|
16
|
+
|
17
|
+
require "hilarity/api/apps"
|
18
|
+
require "hilarity/api/config_vars"
|
19
|
+
require "hilarity/api/domains"
|
20
|
+
require "hilarity/api/keys"
|
21
|
+
require "hilarity/api/login"
|
22
|
+
require "hilarity/api/user"
|
23
|
+
|
24
|
+
srand
|
25
|
+
|
26
|
+
module Hilarity
|
27
|
+
class API
|
28
|
+
|
29
|
+
HEADERS = {
|
30
|
+
'Accept' => 'application/json',
|
31
|
+
'Accept-Encoding' => 'gzip',
|
32
|
+
#'Accept-Language' => 'en-US, en;q=0.8',
|
33
|
+
'User-Agent' => "hilarity-rb/#{Hilarity::API::VERSION}",
|
34
|
+
'X-Ruby-Version' => RUBY_VERSION,
|
35
|
+
'X-Ruby-Platform' => RUBY_PLATFORM
|
36
|
+
}
|
37
|
+
|
38
|
+
OPTIONS = {
|
39
|
+
:headers => {},
|
40
|
+
:host => 'hilarity.io',
|
41
|
+
:nonblock => false,
|
42
|
+
:scheme => 'https'
|
43
|
+
}
|
44
|
+
|
45
|
+
def initialize(options={})
|
46
|
+
options = OPTIONS.merge(options)
|
47
|
+
|
48
|
+
@api_key = options.delete(:api_key) || ENV['HILARITY_API_KEY']
|
49
|
+
if !@api_key && options.has_key?(:username) && options.has_key?(:password)
|
50
|
+
username = options.delete(:username)
|
51
|
+
password = options.delete(:password)
|
52
|
+
@connection = Excon.new("#{options[:scheme]}://#{options[:host]}", options.merge(:headers => HEADERS))
|
53
|
+
@api_key = self.post_login(username, password).body["api_key"]
|
54
|
+
end
|
55
|
+
|
56
|
+
user_pass = ":#{@api_key}"
|
57
|
+
options[:headers] = HEADERS.merge({
|
58
|
+
'Authorization' => "Basic #{Base64.encode64(user_pass).gsub("\n", '')}",
|
59
|
+
}).merge(options[:headers])
|
60
|
+
|
61
|
+
@connection = Excon.new("#{options[:scheme]}://#{options[:host]}", options)
|
62
|
+
end
|
63
|
+
|
64
|
+
def request(params, &block)
|
65
|
+
begin
|
66
|
+
response = @connection.request(params, &block)
|
67
|
+
rescue Excon::Errors::HTTPStatusError => error
|
68
|
+
klass = case error.response.status
|
69
|
+
when 401 then Hilarity::API::Errors::Unauthorized
|
70
|
+
when 402 then Hilarity::API::Errors::VerificationRequired
|
71
|
+
when 403 then Hilarity::API::Errors::Forbidden
|
72
|
+
when 404
|
73
|
+
if error.request[:path].match /\/apps\/\/.*/
|
74
|
+
Hilarity::API::Errors::NilApp
|
75
|
+
else
|
76
|
+
Hilarity::API::Errors::NotFound
|
77
|
+
end
|
78
|
+
when 408 then Hilarity::API::Errors::Timeout
|
79
|
+
when 422 then Hilarity::API::Errors::RequestFailed
|
80
|
+
when 423 then Hilarity::API::Errors::Locked
|
81
|
+
when 429 then Hilarity::API::Errors::RateLimitExceeded
|
82
|
+
when /50./ then Hilarity::API::Errors::RequestFailed
|
83
|
+
else Hilarity::API::Errors::ErrorWithResponse
|
84
|
+
end
|
85
|
+
|
86
|
+
decompress_response!(error.response)
|
87
|
+
reerror = klass.new(error.message, error.response)
|
88
|
+
reerror.set_backtrace(error.backtrace)
|
89
|
+
raise(reerror)
|
90
|
+
end
|
91
|
+
|
92
|
+
if response.body && !response.body.empty?
|
93
|
+
decompress_response!(response)
|
94
|
+
begin
|
95
|
+
response.body = MultiJson.load(response.body)
|
96
|
+
rescue
|
97
|
+
# leave non-JSON body as is
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# reset (non-persistent) connection
|
102
|
+
@connection.reset
|
103
|
+
|
104
|
+
response
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
def decompress_response!(response)
|
110
|
+
return unless response.headers['Content-Encoding'] == 'gzip'
|
111
|
+
response.body = Zlib::GzipReader.new(StringIO.new(response.body)).read
|
112
|
+
end
|
113
|
+
|
114
|
+
def app_params(params)
|
115
|
+
app_params = {}
|
116
|
+
params.each do |key, value|
|
117
|
+
app_params["app[#{key}]"] = value
|
118
|
+
end
|
119
|
+
app_params
|
120
|
+
end
|
121
|
+
|
122
|
+
def addon_params(params)
|
123
|
+
params.inject({}) do |accum, (key, value)|
|
124
|
+
accum["config[#{key}]"] = value
|
125
|
+
accum
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def escape(string)
|
130
|
+
CGI.escape(string).gsub('.', '%2E')
|
131
|
+
end
|
132
|
+
|
133
|
+
def ps_options(params)
|
134
|
+
if ps_env = params.delete(:ps_env) || params.delete('ps_env')
|
135
|
+
ps_env.each do |key, value|
|
136
|
+
params["ps_env[#{key}]"] = value
|
137
|
+
end
|
138
|
+
end
|
139
|
+
params
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Hilarity
|
2
|
+
class API
|
3
|
+
|
4
|
+
# DELETE /apps/:app
|
5
|
+
def delete_app(app)
|
6
|
+
request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => :delete,
|
9
|
+
:path => "/api/v1/apps/#{app}"
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /apps
|
14
|
+
def get_apps
|
15
|
+
request(
|
16
|
+
:expects => 200,
|
17
|
+
:method => :get,
|
18
|
+
:path => "/api/v1/apps"
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
# GET /apps/:app
|
23
|
+
def get_app(app)
|
24
|
+
request(
|
25
|
+
:expects => 200,
|
26
|
+
:method => :get,
|
27
|
+
:path => "/api/v1/apps/#{app}"
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
# GET /apps/:app/server/maintenance
|
32
|
+
def get_app_maintenance(app)
|
33
|
+
request(
|
34
|
+
:expects => 200,
|
35
|
+
:method => :get,
|
36
|
+
:path => "/api/v1/apps/#{app}/server/maintenance"
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
# POST /apps
|
41
|
+
def post_app(params={})
|
42
|
+
request(
|
43
|
+
:expects => 202,
|
44
|
+
:method => :post,
|
45
|
+
:path => '/api/v1/apps',
|
46
|
+
:query => app_params(params)
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
# POST /apps/:app/server/maintenance
|
51
|
+
def post_app_maintenance(app, maintenance_mode)
|
52
|
+
request(
|
53
|
+
:expects => 200,
|
54
|
+
:method => :post,
|
55
|
+
:path => "/api/v1/apps/#{app}/server/maintenance",
|
56
|
+
:query => {'maintenance_mode' => maintenance_mode}
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
# PUT /apps/:app
|
61
|
+
def put_app(app, params)
|
62
|
+
request(
|
63
|
+
:expects => 200,
|
64
|
+
:method => :put,
|
65
|
+
:path => "/api/v1/apps/#{app}",
|
66
|
+
:query => app_params(params)
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Hilarity
|
2
|
+
class API
|
3
|
+
|
4
|
+
# DELETE /apps/:app/config/:key
|
5
|
+
def delete_config_var(app, key)
|
6
|
+
request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => :delete,
|
9
|
+
:path => "/api/v1/apps/#{app}/config/#{escape(key)}"
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /apps/:app/config
|
14
|
+
def get_config_vars(app)
|
15
|
+
request(
|
16
|
+
:expects => 200,
|
17
|
+
:method => :get,
|
18
|
+
:path => "/api/v1/apps/#{app}/config"
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
# PUT /apps/:app/config
|
23
|
+
def put_config_vars(app, vars)
|
24
|
+
request(
|
25
|
+
:body => MultiJson.dump(vars),
|
26
|
+
:expects => 200,
|
27
|
+
:method => :put,
|
28
|
+
:path => "/api/v1/apps/#{app}/config"
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Hilarity
|
2
|
+
class API
|
3
|
+
|
4
|
+
# DELETE /apps/:app/domains/:domain
|
5
|
+
def delete_domain(app, domain)
|
6
|
+
request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => :delete,
|
9
|
+
:path => "/api/v1/apps/#{app}/domains/#{escape(domain)}"
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
# DELETE /apps/:app/domains
|
14
|
+
def delete_domains(app)
|
15
|
+
request(
|
16
|
+
:expects => 200,
|
17
|
+
:method => :delete,
|
18
|
+
:path => "/api/v1/apps/#{app}/domains"
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
# GET /apps/:app/domains
|
23
|
+
def get_domains(app)
|
24
|
+
request(
|
25
|
+
:expects => 200,
|
26
|
+
:method => :get,
|
27
|
+
:path => "/api/v1/apps/#{app}/domains"
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
# POST /apps/:app/domains
|
32
|
+
def post_domain(app, domain)
|
33
|
+
request(
|
34
|
+
:expects => 201,
|
35
|
+
:method => :post,
|
36
|
+
:path => "/api/v1/apps/#{app}/domains",
|
37
|
+
:query => {'domain_name[url]' => domain}
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Hilarity
|
2
|
+
class API
|
3
|
+
module Errors
|
4
|
+
class Error < StandardError; end
|
5
|
+
|
6
|
+
class ErrorWithResponse < Error
|
7
|
+
attr_reader :response
|
8
|
+
|
9
|
+
def initialize(message, response)
|
10
|
+
message = message << "\nbody: #{response.body.inspect}"
|
11
|
+
super message
|
12
|
+
@response = response
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Unauthorized < ErrorWithResponse; end
|
17
|
+
class VerificationRequired < ErrorWithResponse; end
|
18
|
+
class Forbidden < ErrorWithResponse; end
|
19
|
+
class NotFound < ErrorWithResponse; end
|
20
|
+
class Timeout < ErrorWithResponse; end
|
21
|
+
class Locked < ErrorWithResponse; end
|
22
|
+
class RateLimitExceeded < ErrorWithResponse; end
|
23
|
+
class RequestFailed < ErrorWithResponse; end
|
24
|
+
class NilApp < ErrorWithResponse; end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Hilarity
|
2
|
+
class API
|
3
|
+
|
4
|
+
# DELETE /ssh_keys/:key
|
5
|
+
def delete_key(key)
|
6
|
+
request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => :delete,
|
9
|
+
:path => "/api/v1/ssh_keys/#{escape(key)}"
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
# DELETE /ssh_keys
|
14
|
+
def delete_keys
|
15
|
+
request(
|
16
|
+
:expects => 200,
|
17
|
+
:method => :delete,
|
18
|
+
:path => "/api/v1/ssh_keys"
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
# GET /ssh_keys
|
23
|
+
def get_keys
|
24
|
+
request(
|
25
|
+
:expects => 200,
|
26
|
+
:method => :get,
|
27
|
+
:path => "/api/v1/ssh_keys"
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
# POST /ssh_keys
|
32
|
+
def post_key(key)
|
33
|
+
request(
|
34
|
+
:body => key,
|
35
|
+
:expects => 200,
|
36
|
+
:method => :post,
|
37
|
+
:path => "/api/v1/ssh_keys"
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hilarity-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zane Shannon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: excon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.38'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.38'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: multi_json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Ruby Client for the Hilarity API
|
70
|
+
email:
|
71
|
+
- zcs@hilarity.io
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- changelog.txt
|
81
|
+
- hilarity-api.gemspec
|
82
|
+
- lib/hilarity-api.rb
|
83
|
+
- lib/hilarity/api.rb
|
84
|
+
- lib/hilarity/api/apps.rb
|
85
|
+
- lib/hilarity/api/config_vars.rb
|
86
|
+
- lib/hilarity/api/domains.rb
|
87
|
+
- lib/hilarity/api/errors.rb
|
88
|
+
- lib/hilarity/api/keys.rb
|
89
|
+
- lib/hilarity/api/login.rb
|
90
|
+
- lib/hilarity/api/user.rb
|
91
|
+
- lib/hilarity/api/version.rb
|
92
|
+
homepage: http://github.com/hilarity/hilarity.rb
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.2.2
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Ruby Client for the Hilarity API
|
116
|
+
test_files: []
|