rainforest 1.0.7 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -6
- data/.travis.yml +13 -1
- data/Gemfile +6 -0
- data/README.md +72 -21
- data/Rakefile +6 -13
- data/VERSION +1 -1
- data/bin/rainforest-console +1 -1
- data/gemfiles/default-with-activesupport.gemfile +8 -1
- data/gemfiles/json.gemfile +10 -2
- data/gemfiles/yajl.gemfile +10 -2
- data/lib/rainforest.rb +61 -240
- data/lib/rainforest/apibits/api_client.rb +28 -0
- data/lib/rainforest/apibits/api_endpoint.rb +11 -0
- data/lib/rainforest/apibits/api_list.rb +88 -0
- data/lib/rainforest/apibits/api_method.rb +95 -0
- data/lib/rainforest/apibits/api_object.rb +52 -0
- data/lib/rainforest/apibits/api_resource.rb +153 -0
- data/lib/rainforest/apibits/headers_builder.rb +47 -0
- data/lib/rainforest/apibits/params_builder.rb +27 -0
- data/lib/rainforest/apibits/path_builder.rb +38 -0
- data/lib/rainforest/apibits/requester.rb +104 -0
- data/lib/rainforest/apibits/util.rb +51 -0
- data/lib/rainforest/clients/default_client.rb +59 -0
- data/lib/rainforest/endpoints/client_stats_endpoint.rb +11 -0
- data/lib/rainforest/endpoints/environment_runs_endpoint.rb +11 -0
- data/lib/rainforest/endpoints/environments_endpoint.rb +48 -0
- data/lib/rainforest/endpoints/generator_rows_endpoint.rb +17 -0
- data/lib/rainforest/endpoints/generators_endpoint.rb +48 -0
- data/lib/rainforest/endpoints/integrations_endpoint.rb +33 -0
- data/lib/rainforest/endpoints/run_tests_endpoint.rb +20 -0
- data/lib/rainforest/endpoints/runs_endpoint.rb +48 -0
- data/lib/rainforest/endpoints/schedules_endpoint.rb +48 -0
- data/lib/rainforest/endpoints/site_environments_endpoint.rb +24 -0
- data/lib/rainforest/endpoints/sites_endpoint.rb +39 -0
- data/lib/rainforest/endpoints/tests_endpoint.rb +57 -0
- data/lib/rainforest/endpoints/users_endpoint.rb +48 -0
- data/lib/rainforest/errors/api_connection_error.rb +1 -1
- data/lib/rainforest/errors/api_error.rb +32 -1
- data/lib/rainforest/errors/authentication_error.rb +1 -1
- data/lib/rainforest/errors/rainforest_error.rb +2 -9
- data/lib/rainforest/resources/client_stats.rb +31 -0
- data/lib/rainforest/resources/environment.rb +73 -0
- data/lib/rainforest/resources/generator.rb +73 -0
- data/lib/rainforest/resources/integration.rb +52 -0
- data/lib/rainforest/resources/run.rb +93 -0
- data/lib/rainforest/resources/schedule.rb +63 -0
- data/lib/rainforest/resources/site.rb +53 -0
- data/lib/rainforest/resources/site_environment.rb +40 -0
- data/lib/rainforest/resources/test.rb +98 -0
- data/lib/rainforest/resources/user.rb +75 -0
- data/rainforest.gemspec +8 -6
- data/test/rainforest/api_client_test.rb +51 -0
- data/test/rainforest/api_endpoint_test.rb +13 -0
- data/test/rainforest/api_list_test.rb +49 -0
- data/test/rainforest/api_method_test.rb +78 -0
- data/test/rainforest/headers_builder_test.rb +28 -0
- data/test/rainforest/params_builder_test.rb +57 -0
- data/test/rainforest/path_builder_test.rb +50 -0
- data/test/rainforest/requester_test.rb +86 -0
- data/test/rainforest/util_test.rb +41 -19
- data/test/test_data.rb +72 -0
- data/test/test_helper.rb +17 -134
- metadata +99 -59
- data/CONTRIBUTORS +0 -2
- data/History.txt +0 -4
- data/LICENSE +0 -21
- data/lib/data/ca-certificates.crt +0 -3918
- data/lib/rainforest/api_operations/create.rb +0 -16
- data/lib/rainforest/api_operations/delete.rb +0 -11
- data/lib/rainforest/api_operations/list.rb +0 -16
- data/lib/rainforest/api_operations/update.rb +0 -61
- data/lib/rainforest/api_resource.rb +0 -33
- data/lib/rainforest/errors/invalid_request_error.rb +0 -10
- data/lib/rainforest/json.rb +0 -21
- data/lib/rainforest/list_object.rb +0 -35
- data/lib/rainforest/rainforest_object.rb +0 -165
- data/lib/rainforest/run.rb +0 -8
- data/lib/rainforest/singleton_api_resource.rb +0 -20
- data/lib/rainforest/util.rb +0 -100
- data/test/rainforest/api_resource_test.rb +0 -11
- data/test/rainforest/auth_test.rb +0 -24
- data/test/rainforest/list_object_test.rb +0 -7
- data/test/rainforest/metadata_test.rb +0 -7
- data/test/rainforest/run_test.rb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82b786fc24d65611d96a516701e188e587011fac
|
4
|
+
data.tar.gz: 13d9d3e95a6ecc8fa6422f4e75169615bb43de73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cc5b56ef4426f7c9284b6290842715e95efa7a274eb82781055f0209ec95bce8a381db10a7e4286dc97218c9b4010b61364c292bbff4b7b093e009196d9a1bf
|
7
|
+
data.tar.gz: 8b01181dbf47463375447865db939c80218a37363c53d024daf25bcde64c410449f6530335e58ef4d6fcbedc0f9b64fd2ed88d11ed1eafab108d78f317204d12
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,47 +1,98 @@
|
|
1
|
-
|
1
|
+
# Rainforest Ruby Bindings
|
2
2
|
|
3
|
-
# Installation
|
4
3
|
|
5
|
-
Install the gem:
|
6
4
|
|
7
|
-
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
You don't need this source code unless you want to modify the gem. If
|
8
|
+
you just want to use the Rainforest Ruby bindings, you should run:
|
9
|
+
|
10
|
+
```bash
|
8
11
|
gem install rainforest
|
9
12
|
```
|
10
13
|
|
11
|
-
|
14
|
+
If you want to build & install the gem from source:
|
15
|
+
|
16
|
+
```bash
|
17
|
+
gem build rainforest.gemspec
|
18
|
+
gem install rainforest-2.0.0.gem
|
19
|
+
```
|
20
|
+
|
21
|
+
|
22
|
+
## Requirements
|
23
|
+
|
24
|
+
* Ruby 1.8.7 or above. (Ruby 1.8.6 may work if you load
|
25
|
+
ActiveSupport.) For Ruby versions before 1.9.2, you'll need to add this to your Gemfile:
|
12
26
|
|
13
27
|
```ruby
|
14
|
-
|
28
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.2')
|
29
|
+
gem 'rest-client', '~> 1.6.8'
|
30
|
+
end
|
15
31
|
```
|
16
32
|
|
17
|
-
|
33
|
+
* rest-client, json
|
18
34
|
|
19
|
-
* Ruby 1.9.3 or above.
|
20
|
-
* rest-client, multi_json
|
21
35
|
|
36
|
+
## Bundler
|
22
37
|
|
23
|
-
|
38
|
+
If you are installing via bundler, you should be sure to use the https
|
39
|
+
rubygems source in your Gemfile, as any gems fetched over http could potentially be compromised.
|
24
40
|
|
25
41
|
```ruby
|
26
|
-
|
27
|
-
|
42
|
+
source 'https://rubygems.org'
|
43
|
+
|
44
|
+
gem 'rails'
|
45
|
+
gem 'rainforest'
|
46
|
+
```
|
47
|
+
|
48
|
+
## Using the library
|
28
49
|
|
29
|
-
|
30
|
-
runs = Rainforest::Run.all
|
50
|
+
The following section covers some general info about this API library. If you are looking for documentation covering the entire API, check here: [https://docs.rainfroestqa.com](https://docs.rainfroestqa.com).
|
31
51
|
|
32
|
-
|
33
|
-
|
52
|
+
### Params and Headers
|
53
|
+
|
54
|
+
All API methods accept 2 optional arguments - the params and headers. For example, if you had `SomeResource` and wanted to call `#some_method(some_arg)`, all of the following would be valid:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
# With no custom params or headers
|
58
|
+
Rainforest::SomeResource.some_method(some_arg)
|
34
59
|
|
60
|
+
# With only custom params
|
61
|
+
Rainforest::SomeResource.some_method(some_arg, params)
|
35
62
|
|
36
|
-
#
|
37
|
-
|
63
|
+
# With only custom headers
|
64
|
+
Rainforest::SomeResource.some_method(some_arg, nil, headers)
|
65
|
+
|
66
|
+
# With both custom params and headers
|
67
|
+
Rainforest::SomeResource.some_method(some_arg, params, headers)
|
38
68
|
```
|
39
69
|
|
40
|
-
|
70
|
+
This is mostly useful when creating new resources, or when trying to use an API endpoint that supports pagination.
|
71
|
+
|
41
72
|
|
42
|
-
|
73
|
+
### Using Multiple API Keys
|
43
74
|
|
75
|
+
The API library was designed to support both developers who plan to only use one API key, as well as developers who may need to use multiple API keys in the same server.
|
44
76
|
|
45
|
-
|
77
|
+
By default most resource lookups use code like this:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
Rainforest.api_key = "your-api-key"
|
81
|
+
test = Rainforest::Test.retrieve(id)
|
82
|
+
```
|
83
|
+
|
84
|
+
but since the API key is set on the module, this could cause issues if you need to use multiple API keys. To get around this, simply use one of the API clients located in the `clients` folder. For example:
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
client = Rainforest::DefaultClient.new("your-api-key")
|
88
|
+
test = client.tests.retreive(id)
|
89
|
+
```
|
90
|
+
|
91
|
+
The results from each will be the same, so if you prefer the client version you are welcome to use it even if you aren't using multiple API keys in production.
|
92
|
+
|
93
|
+
|
94
|
+
## Development
|
46
95
|
|
47
96
|
Test cases can be run with: `bundle exec rake test`
|
97
|
+
|
98
|
+
We welcome suggestions and feedback from our users :D
|
data/Rakefile
CHANGED
@@ -1,15 +1,8 @@
|
|
1
|
-
|
1
|
+
require 'rake/testtask'
|
2
|
+
require 'yaml'
|
2
3
|
|
3
|
-
task :test
|
4
|
-
ret = true
|
5
|
-
Dir["test/**/*_test.rb"].each do |f|
|
6
|
-
ret = ret && ruby(f, '')
|
7
|
-
end
|
8
|
-
end
|
4
|
+
task :default => [:test]
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
Rake::Task["test"].reenable
|
14
|
-
Rake::Task["test"].invoke
|
15
|
-
end
|
6
|
+
Rake::TestTask.new do |t|
|
7
|
+
t.pattern = './test/**/[^_]*_test.rb'
|
8
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/bin/rainforest-console
CHANGED
@@ -1,3 +1,10 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
gemspec :path => File.join(File.dirname(__FILE__), "..")
|
3
|
-
|
3
|
+
|
4
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3')
|
5
|
+
gem 'i18n', '< 0.7'
|
6
|
+
gem 'rest-client', '~> 1.6.8'
|
7
|
+
gem 'activesupport', '~> 3.2'
|
8
|
+
else
|
9
|
+
gem 'activesupport'
|
10
|
+
end
|
data/gemfiles/json.gemfile
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
gemspec :path => File.join(File.dirname(__FILE__), "..")
|
3
|
-
|
4
|
-
|
3
|
+
|
4
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3')
|
5
|
+
gem 'i18n', '< 0.7'
|
6
|
+
gem 'rest-client', '~> 1.6.8'
|
7
|
+
gem 'activesupport', '~> 3.2'
|
8
|
+
else
|
9
|
+
gem 'activesupport'
|
10
|
+
end
|
11
|
+
|
12
|
+
gem 'json'
|
data/gemfiles/yajl.gemfile
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
gemspec :path => File.join(File.dirname(__FILE__), "..")
|
3
|
-
|
4
|
-
|
3
|
+
|
4
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3')
|
5
|
+
gem 'i18n', '< 0.7'
|
6
|
+
gem 'rest-client', '~> 1.6.8'
|
7
|
+
gem 'activesupport', '~> 3.2'
|
8
|
+
else
|
9
|
+
gem 'activesupport'
|
10
|
+
end
|
11
|
+
|
12
|
+
gem 'yajl-ruby'
|
data/lib/rainforest.rb
CHANGED
@@ -1,262 +1,83 @@
|
|
1
1
|
# Rainforest Ruby bindings
|
2
|
-
# API
|
2
|
+
# API Docs are located at https://docs.rainfroestqa.com
|
3
3
|
require 'cgi'
|
4
4
|
require 'set'
|
5
5
|
require 'openssl'
|
6
6
|
require 'rest_client'
|
7
|
-
require '
|
7
|
+
require 'json'
|
8
|
+
require 'base64'
|
8
9
|
|
9
10
|
# Version
|
10
11
|
require 'rainforest/version'
|
11
12
|
|
12
|
-
# API operations
|
13
|
-
require 'rainforest/api_operations/create'
|
14
|
-
require 'rainforest/api_operations/update'
|
15
|
-
require 'rainforest/api_operations/delete'
|
16
|
-
require 'rainforest/api_operations/list'
|
17
|
-
|
18
|
-
# Resources
|
19
|
-
require 'rainforest/util'
|
20
|
-
require 'rainforest/json'
|
21
|
-
require 'rainforest/rainforest_object'
|
22
|
-
require 'rainforest/api_resource'
|
23
|
-
require 'rainforest/singleton_api_resource'
|
24
|
-
require 'rainforest/list_object'
|
25
|
-
require 'rainforest/run'
|
26
|
-
|
27
13
|
# Errors
|
28
14
|
require 'rainforest/errors/rainforest_error'
|
29
15
|
require 'rainforest/errors/api_error'
|
30
16
|
require 'rainforest/errors/api_connection_error'
|
31
|
-
require 'rainforest/errors/invalid_request_error'
|
32
17
|
require 'rainforest/errors/authentication_error'
|
33
18
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
payload = nil
|
81
|
-
else
|
82
|
-
payload = uri_encode(params)
|
83
|
-
end
|
84
|
-
|
85
|
-
request_opts.update(:headers => request_headers(api_key).update(headers),
|
86
|
-
:method => method, :open_timeout => 30,
|
87
|
-
:payload => payload, :url => url, :timeout => 80)
|
88
|
-
|
89
|
-
begin
|
90
|
-
response = execute_request(request_opts)
|
91
|
-
rescue SocketError => e
|
92
|
-
handle_restclient_error(e)
|
93
|
-
rescue NoMethodError => e
|
94
|
-
# Work around RestClient bug
|
95
|
-
if e.message =~ /\WRequestFailed\W/
|
96
|
-
e = APIConnectionError.new('Unexpected HTTP response code')
|
97
|
-
handle_restclient_error(e)
|
98
|
-
else
|
99
|
-
raise
|
100
|
-
end
|
101
|
-
rescue RestClient::ExceptionWithResponse => e
|
102
|
-
if rcode = e.http_code and rbody = e.http_body
|
103
|
-
handle_api_error(rcode, rbody)
|
104
|
-
else
|
105
|
-
handle_restclient_error(e)
|
106
|
-
end
|
107
|
-
rescue RestClient::Exception, Errno::ECONNREFUSED => e
|
108
|
-
handle_restclient_error(e)
|
109
|
-
end
|
110
|
-
|
111
|
-
[parse(response), api_key]
|
112
|
-
end
|
113
|
-
|
114
|
-
private
|
115
|
-
|
116
|
-
def self.ssl_preflight_passed?
|
117
|
-
if !verify_ssl_certs && !@no_verify
|
118
|
-
$stderr.puts "WARNING: Running without SSL cert verification. " +
|
119
|
-
"Execute 'Rainforest.verify_ssl_certs = true' to enable verification."
|
120
|
-
|
121
|
-
@no_verify = true
|
122
|
-
|
123
|
-
elsif !Util.file_readable(@ssl_bundle_path) && !@no_bundle
|
124
|
-
$stderr.puts "WARNING: Running without SSL cert verification " +
|
125
|
-
"because #{@ssl_bundle_path} isn't readable"
|
126
|
-
|
127
|
-
@no_bundle = true
|
128
|
-
end
|
129
|
-
|
130
|
-
!(@no_verify || @no_bundle)
|
131
|
-
end
|
132
|
-
|
133
|
-
def self.user_agent
|
134
|
-
@uname ||= get_uname
|
135
|
-
lang_version = "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
|
136
|
-
|
137
|
-
{
|
138
|
-
:bindings_version => Rainforest::VERSION,
|
139
|
-
:lang => 'ruby',
|
140
|
-
:lang_version => lang_version,
|
141
|
-
:platform => RUBY_PLATFORM,
|
142
|
-
:publisher => 'rainforest',
|
143
|
-
:uname => @uname
|
144
|
-
}
|
145
|
-
|
146
|
-
end
|
147
|
-
|
148
|
-
def self.get_uname
|
149
|
-
`uname -a 2>/dev/null`.strip if RUBY_PLATFORM =~ /linux|darwin/i
|
150
|
-
rescue Errno::ENOMEM => ex # couldn't create subprocess
|
151
|
-
"uname lookup failed"
|
152
|
-
end
|
153
|
-
|
154
|
-
def self.uri_encode(params)
|
155
|
-
Util.flatten_params(params).
|
156
|
-
map { |k,v| "#{k}=#{Util.url_encode(v)}" }.join('&')
|
157
|
-
end
|
158
|
-
|
159
|
-
def self.request_headers(api_key)
|
160
|
-
headers = {
|
161
|
-
:user_agent => "Rainforest/#{api_version} RubyBindings/#{Rainforest::VERSION}",
|
162
|
-
|
163
|
-
# TODO(jon): Ask Rainforest guys about using http basic auth
|
164
|
-
# :authorization => "Bearer #{api_key}",
|
165
|
-
"Accept" => "application/json",
|
166
|
-
"CLIENT_TOKEN" => api_key,
|
167
|
-
:content_type => 'application/x-www-form-urlencoded'
|
168
|
-
}
|
169
|
-
|
170
|
-
headers[:rainforest_version] = api_version if api_version
|
171
|
-
|
172
|
-
begin
|
173
|
-
headers.update(:x_rainforest_client_user_agent => Rainforest::JSON.dump(user_agent))
|
174
|
-
rescue => e
|
175
|
-
headers.update(:x_rainforest_client_raw_user_agent => user_agent.inspect,
|
176
|
-
:error => "#{e} (#{e.class})")
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
def self.execute_request(opts)
|
181
|
-
RestClient::Request.execute(opts)
|
182
|
-
end
|
183
|
-
|
184
|
-
def self.parse(response)
|
185
|
-
begin
|
186
|
-
# Would use :symbolize_names => true, but apparently there is
|
187
|
-
# some library out there that makes symbolize_names not work.
|
188
|
-
response = Rainforest::JSON.load(response.body)
|
189
|
-
rescue MultiJson::DecodeError
|
190
|
-
raise general_api_error(response.code, response.body)
|
191
|
-
end
|
192
|
-
|
193
|
-
Util.symbolize_names(response)
|
194
|
-
end
|
195
|
-
|
196
|
-
def self.general_api_error(rcode, rbody)
|
197
|
-
APIError.new("Invalid response object from API: #{rbody.inspect} " +
|
198
|
-
"(HTTP response code was #{rcode})", rcode, rbody)
|
199
|
-
end
|
200
|
-
|
201
|
-
def self.handle_api_error(rcode, rbody)
|
202
|
-
begin
|
203
|
-
error_obj = Rainforest::JSON.load(rbody)
|
204
|
-
error_obj = Util.symbolize_names(error_obj)
|
205
|
-
error = error_obj[:error] or raise RainforestError.new # escape from parsing
|
206
|
-
|
207
|
-
rescue MultiJson::DecodeError, RainforestError
|
208
|
-
raise general_api_error(rcode, rbody)
|
209
|
-
end
|
210
|
-
|
211
|
-
case rcode
|
212
|
-
when 400, 404
|
213
|
-
raise invalid_request_error error, rcode, rbody, error_obj
|
214
|
-
when 401
|
215
|
-
raise authentication_error error, rcode, rbody, error_obj
|
216
|
-
else
|
217
|
-
raise api_error error, rcode, rbody, error_obj
|
218
|
-
end
|
19
|
+
# Wrapper around RestClient
|
20
|
+
require 'rainforest/apibits/requester'
|
21
|
+
|
22
|
+
# Builders for creating API methods.
|
23
|
+
require 'rainforest/apibits/path_builder'
|
24
|
+
require 'rainforest/apibits/headers_builder'
|
25
|
+
require 'rainforest/apibits/params_builder'
|
26
|
+
require 'rainforest/apibits/api_method'
|
27
|
+
|
28
|
+
# Generic resources
|
29
|
+
require 'rainforest/apibits/api_endpoint'
|
30
|
+
require 'rainforest/apibits/api_client'
|
31
|
+
require 'rainforest/apibits/api_object'
|
32
|
+
require 'rainforest/apibits/api_resource'
|
33
|
+
require 'rainforest/apibits/api_list'
|
34
|
+
require 'rainforest/apibits/util'
|
35
|
+
|
36
|
+
# API specific resources
|
37
|
+
require 'rainforest/resources/client_stats'
|
38
|
+
require 'rainforest/resources/environment'
|
39
|
+
require 'rainforest/resources/generator'
|
40
|
+
require 'rainforest/resources/integration'
|
41
|
+
require 'rainforest/resources/run'
|
42
|
+
require 'rainforest/resources/schedule'
|
43
|
+
require 'rainforest/resources/site_environment'
|
44
|
+
require 'rainforest/resources/site'
|
45
|
+
require 'rainforest/resources/test'
|
46
|
+
require 'rainforest/resources/user'
|
47
|
+
|
48
|
+
# API specific endpoints
|
49
|
+
require 'rainforest/endpoints/client_stats_endpoint'
|
50
|
+
require 'rainforest/endpoints/environment_runs_endpoint'
|
51
|
+
require 'rainforest/endpoints/environments_endpoint'
|
52
|
+
require 'rainforest/endpoints/generators_endpoint'
|
53
|
+
require 'rainforest/endpoints/generator_rows_endpoint'
|
54
|
+
require 'rainforest/endpoints/integrations_endpoint'
|
55
|
+
require 'rainforest/endpoints/run_tests_endpoint'
|
56
|
+
require 'rainforest/endpoints/runs_endpoint'
|
57
|
+
require 'rainforest/endpoints/schedules_endpoint'
|
58
|
+
require 'rainforest/endpoints/site_environments_endpoint'
|
59
|
+
require 'rainforest/endpoints/sites_endpoint'
|
60
|
+
require 'rainforest/endpoints/tests_endpoint'
|
61
|
+
require 'rainforest/endpoints/users_endpoint'
|
62
|
+
|
63
|
+
# API specific clients
|
64
|
+
require 'rainforest/clients/default_client'
|
219
65
|
|
220
|
-
end
|
221
|
-
|
222
|
-
def self.invalid_request_error(error, rcode, rbody, error_obj)
|
223
|
-
InvalidRequestError.new("Invalid Request Error", error[:param], rcode,
|
224
|
-
rbody, error_obj)
|
225
|
-
end
|
226
66
|
|
227
|
-
|
228
|
-
|
229
|
-
|
67
|
+
module Rainforest
|
68
|
+
@api_base = "https://app.rainforestqa.com/api/1"
|
69
|
+
@api_staging = "https://app.rnfrst.com/api/1/"
|
70
|
+
@api_version = "v1"
|
71
|
+
@support_email = "help@rainforestqa.com"
|
72
|
+
@docs_url = "https://docs.rainfroestqa.com"
|
230
73
|
|
231
|
-
|
232
|
-
|
74
|
+
class << self
|
75
|
+
attr_accessor :api_base, :api_version
|
76
|
+
attr_reader :api_staging, :support_email, :docs_url
|
77
|
+
attr_accessor :api_key
|
233
78
|
end
|
234
79
|
|
235
|
-
def self.
|
236
|
-
|
237
|
-
when RestClient::ServerBrokeConnection, RestClient::RequestTimeout
|
238
|
-
message = "Could not connect to Rainforest (#{@api_base}). " +
|
239
|
-
"Please check your internet connection and try again. " +
|
240
|
-
"If this problem persists, you should check Rainforest's service status at " +
|
241
|
-
"https://twitter.com/rainforeststatus, or let us know at support@rainforest.com."
|
242
|
-
|
243
|
-
when RestClient::SSLCertificateNotVerified
|
244
|
-
message = "Could not verify Rainforest's SSL certificate. " +
|
245
|
-
"Please make sure that your network is not intercepting certificates. " +
|
246
|
-
"(Try going to https://api.rainforest.com/v1 in your browser.) " +
|
247
|
-
"If this problem persists, let us know at support@rainforest.com."
|
248
|
-
|
249
|
-
when SocketError
|
250
|
-
message = "Unexpected error communicating when trying to connect to Rainforest. " +
|
251
|
-
"You may be seeing this message because your DNS is not working. " +
|
252
|
-
"To check, try running 'host rainforest.com' from the command line."
|
253
|
-
|
254
|
-
else
|
255
|
-
message = "Unexpected error communicating with Rainforest. " +
|
256
|
-
"If this problem persists, let us know at support@rainforest.com."
|
257
|
-
|
258
|
-
end
|
259
|
-
|
260
|
-
raise APIConnectionError.new(message + "\n\n(Network error: #{e.message})")
|
80
|
+
def self.default_client
|
81
|
+
DefaultClient.new(Rainforest.api_key)
|
261
82
|
end
|
262
83
|
end
|