rubyshift 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/CHANGELOG.md +4 -0
- data/LICENSE +23 -0
- data/README.md +54 -0
- data/Rakefile +9 -0
- data/lib/rubyshift/api.rb +16 -0
- data/lib/rubyshift/client/applications.rb +78 -0
- data/lib/rubyshift/client/cartridges.rb +4 -0
- data/lib/rubyshift/client/domains.rb +32 -0
- data/lib/rubyshift/client.rb +9 -0
- data/lib/rubyshift/configuration.rb +61 -0
- data/lib/rubyshift/error.rb +43 -0
- data/lib/rubyshift/request.rb +138 -0
- data/lib/rubyshift/version.rb +3 -0
- data/lib/rubyshift.rb +35 -0
- data/rubyshift.gemspec +25 -0
- data/spec/fixtures/application.json +1 -0
- data/spec/fixtures/applications.json +1 -0
- data/spec/rubyshift/client/applications_spec.rb +40 -0
- data/spec/rubyshift/request_spec.rb +92 -0
- data/spec/rubyshift_spec.rb +92 -0
- data/spec/spec_helper.rb +38 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: df4b8a4d2f92b613847fe9c73ab70647bfa91058
|
4
|
+
data.tar.gz: 17504bb2f8647fdcd8360e30dd89d9d233e6c5ca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9697f930583eaac30ff54dfa29533a404f6d59b69814f9bbfb75941e206617232fb5612b450cf69f91b700e2abcf7e175d41ef013ab3b517a0efc48b72e900e6
|
7
|
+
data.tar.gz: 57b79a9bbe3bd19a9742b6373ff5609b1aa0103cdffbcf14cab3ad722c3e10f765c782c895e523e38c1568777317d92955f81f04e5d03076443d31aeb916d035
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2016 Anurag Patel <gnurag@gmail.com> All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
1. Redistributions of source code must retain the above copyright notice,
|
7
|
+
this list of conditions and the following disclaimer.
|
8
|
+
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
14
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
15
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
16
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
17
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
18
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
19
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
20
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
21
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
22
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
23
|
+
POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# RubyShift
|
2
|
+
|
3
|
+
RubyShift is a Ruby client for [OpenShift's REST API](https://access.redhat.com/documentation/en-US/OpenShift_Online/2.0/html/REST_API_Guide/index.html)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Installing from rubygems:
|
8
|
+
|
9
|
+
```sh
|
10
|
+
gem install rubyshift
|
11
|
+
```
|
12
|
+
|
13
|
+
Via Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'rubyshift', github: 'gnurag/rubyshift'
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Configuration example:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'rubyshift'
|
25
|
+
RubyShift.configure do |config|
|
26
|
+
config.endpoint = 'https://openshift.redhat.com/broker/rest'
|
27
|
+
config.access_token = '<secret-access-token>'
|
28
|
+
# Optional config options
|
29
|
+
config.httparty = { timeout: 90 }
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
Usage example:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
RubyShift.applications
|
37
|
+
# => []
|
38
|
+
|
39
|
+
RubyShift.application_create('myapp', domain_name: 'rubyshift', cartridges: 'ruby-2.0', scale: true, gear_size: 'small')
|
40
|
+
# => #<OpenStruct aliases=[], app_url="http://myapp-rubyshift.rhcloud.com/", auto_deploy=true, build_job_url=nil, building_app=nil, building_with=nil, creation_time="2016-04-13T21:00:01Z", deployment_branch="master", deployment_type="git", domain_id="rubyshift", embedded={"haproxy-1.4"=>{}}, framework="ruby-2.0", gear_count=1, gear_profile="small", git_url="ssh://500000000000000000000001@myapp-rubyshift.rhcloud.com/~/git/myapp.git/", ha=false, health_check_path="health", id="500000000000000000000001", initial_git_url=nil, keep_deployments=1, name="myapp", scalable=true, ssh_url="ssh://500000000000000000000001@myapp-rubyshift.rhcloud.com">
|
41
|
+
|
42
|
+
RubyShift.application('500000000000000000000001')
|
43
|
+
# => #<OpenStruct aliases=[], app_url="http://myapp-rubyshift.rhcloud.com/", auto_deploy=true, build_job_url=nil, building_app=nil, building_with=nil, creation_time="2016-04-13T21:00:01Z", deployment_branch="master", deployment_type="git", domain_id="rubyshift", embedded={"haproxy-1.4"=>{}}, framework="ruby-2.0", gear_count=1, gear_profile="small", git_url="ssh://500000000000000000000001@myapp-rubyshift.rhcloud.com/~/git/myapp.git/", ha=false, health_check_path="health", id="500000000000000000000001", initial_git_url=nil, keep_deployments=1, name="myapp", scalable=true, ssh_url="ssh://500000000000000000000001@myapp-rubyshift.rhcloud.com">
|
44
|
+
|
45
|
+
RubyShift.application_restart('500000000000000000000001')
|
46
|
+
# => #<OpenStruct aliases=[], app_url="http://myapp-rubyshift.rhcloud.com/", auto_deploy=true, build_job_url=nil, building_app=nil, building_with=nil, creation_time="2016-04-13T21:00:01Z", deployment_branch="master", deployment_type="git", domain_id="rubyshift", embedded={"haproxy-1.4"=>{}}, framework="ruby-2.0", gear_count=1, gear_profile="small", git_url="ssh://500000000000000000000001@myapp-rubyshift.rhcloud.com/~/git/myapp.git/", ha=false, health_check_path="health", id="500000000000000000000001", initial_git_url=nil, keep_deployments=1, name="myapp", scalable=true, ssh_url="ssh://500000000000000000000001@myapp-rubyshift.rhcloud.com">
|
47
|
+
|
48
|
+
RubyShift.application_delete('500000000000000000000001')
|
49
|
+
# => true
|
50
|
+
```
|
51
|
+
|
52
|
+
## Acknowledgement
|
53
|
+
|
54
|
+
RubyShift is based on the excellent [gitlab](https://github.com/NARKOZ/gitlab) gem.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module RubyShift
|
2
|
+
|
3
|
+
class API < Request
|
4
|
+
attr_accessor(*Configuration::VALID_OPTIONS_KEYS)
|
5
|
+
|
6
|
+
# Creates a new API.
|
7
|
+
# @raise [Error:MissingCredentials]
|
8
|
+
def initialize(options={})
|
9
|
+
options = RubyShift.options.merge(options)
|
10
|
+
(Configuration::VALID_OPTIONS_KEYS + [:access_token]).each do |key|
|
11
|
+
send("#{key}=", options[key]) if options[key]
|
12
|
+
end
|
13
|
+
set_request_defaults
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
class RubyShift::Client
|
2
|
+
module Applications
|
3
|
+
def applications(options={})
|
4
|
+
if options[:domain_name]
|
5
|
+
get("/domain/#{options[:domain_name]}/applications", query: options)
|
6
|
+
else
|
7
|
+
get("/applications", query: options)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def application(id)
|
12
|
+
get("/application/#{id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def application_resolve(id)
|
16
|
+
get("/application/#{id}/dns_resolvable")
|
17
|
+
end
|
18
|
+
|
19
|
+
def application_create(name, options={})
|
20
|
+
url = "/domain/#{options[:domain_name]}/applications"
|
21
|
+
post(url, body: {name: name }.merge(options))
|
22
|
+
end
|
23
|
+
|
24
|
+
def application_update(id, options={})
|
25
|
+
put("/application/#{id}", body: options)
|
26
|
+
end
|
27
|
+
|
28
|
+
def application_delete(id)
|
29
|
+
delete("/application/#{id}")
|
30
|
+
end
|
31
|
+
|
32
|
+
def application_enable_ha(id)
|
33
|
+
post("/application/#{id}/events", body: {event: 'make-ha'})
|
34
|
+
end
|
35
|
+
|
36
|
+
def application_disable_ha(id)
|
37
|
+
post("/application/#{id}/events", body: {event: 'disable-ha'})
|
38
|
+
end
|
39
|
+
|
40
|
+
def application_start(id)
|
41
|
+
post("/application/#{id}/events", body: {event: 'start'})
|
42
|
+
end
|
43
|
+
|
44
|
+
def application_stop(id)
|
45
|
+
post("/application/#{id}/events", body: {event: 'stop'})
|
46
|
+
end
|
47
|
+
|
48
|
+
def application_force_stop(id)
|
49
|
+
post("/application/#{id}/events", body: {event: 'force-stop'})
|
50
|
+
end
|
51
|
+
|
52
|
+
def application_restart(id)
|
53
|
+
post("/application/#{id}/events", body: {event: 'restart'})
|
54
|
+
end
|
55
|
+
|
56
|
+
def application_reload(id)
|
57
|
+
post("/application/#{id}/events", body: {event: 'reload'})
|
58
|
+
end
|
59
|
+
|
60
|
+
def application_scale_up(id)
|
61
|
+
post("/application/#{id}/events", body: {event: 'scale-up'})
|
62
|
+
end
|
63
|
+
|
64
|
+
def application_scale_up(id)
|
65
|
+
post("/application/#{id}/events", body: {event: 'scale-up'})
|
66
|
+
end
|
67
|
+
|
68
|
+
def application_scale_down(id)
|
69
|
+
post("/application/#{id}/events", body: {event: 'scale-down'})
|
70
|
+
end
|
71
|
+
|
72
|
+
def application_tidy(id)
|
73
|
+
post("/application/#{id}/events", body: {event: 'tidy'})
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class RubyShift::Client
|
2
|
+
module Domains
|
3
|
+
def domains
|
4
|
+
get("/domains")
|
5
|
+
end
|
6
|
+
|
7
|
+
def domains_by_owner(owner="@self")
|
8
|
+
get("/domains", body: {owner: owner})
|
9
|
+
end
|
10
|
+
|
11
|
+
def domain(name)
|
12
|
+
get("/domains/#{name}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def domain_create(name, options={})
|
16
|
+
post("/domains", body: {name: name}.merge(options))
|
17
|
+
end
|
18
|
+
|
19
|
+
def domain_update(name, options={})
|
20
|
+
put("/domains/#{name}", body: options)
|
21
|
+
end
|
22
|
+
|
23
|
+
def domain_delete(name, options={})
|
24
|
+
delete("/domains/#{name}", body: options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def domain_remove_self(name)
|
28
|
+
delete("/domain/#{name}/members/self")
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module RubyShift
|
4
|
+
module Configuration
|
5
|
+
|
6
|
+
VALID_OPTIONS_KEYS = [:endpoint, :username, :password, :access_token, :user_agent, :httparty].freeze
|
7
|
+
|
8
|
+
DEFAULT_ENDPOINT = 'https://openshift.redhat.com/broker/rest'
|
9
|
+
DEFAULT_USER_AGENT = "RubyShift/#{RubyShift::VERSION}".freeze
|
10
|
+
|
11
|
+
attr_accessor(*VALID_OPTIONS_KEYS)
|
12
|
+
|
13
|
+
def self.exetended(base)
|
14
|
+
base.reset
|
15
|
+
end
|
16
|
+
|
17
|
+
def configure
|
18
|
+
yield self
|
19
|
+
end
|
20
|
+
|
21
|
+
def options
|
22
|
+
VALID_OPTIONS_KEYS.inject({}) do |option, key|
|
23
|
+
option.merge!(key => send(key))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def reset
|
28
|
+
self.endpoint = ENV['RUBYSHIFT_ENDPOINT']
|
29
|
+
self.username = ENV['RUBYSHIFT_USERNAME']
|
30
|
+
self.password = ENV['RUBYSHIFT_PASSWORD']
|
31
|
+
self.access_token = ENV['RUBYSHIFT_ACCESS_TOKEN']
|
32
|
+
self.httparty = get_httparty_config(ENV['RUBYSHIFT_HTTPARTY_OPTIONS'])
|
33
|
+
self.user_agent = DEFAULT_USER_AGENT
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def get_httparty_config(options)
|
39
|
+
return options if options.nil?
|
40
|
+
|
41
|
+
httparty = JSON.parse options
|
42
|
+
raise ArgumentError, "HTTParty config should be a Hash." unless httparty.is_a? Hash
|
43
|
+
symbolize_keys httparty
|
44
|
+
end
|
45
|
+
|
46
|
+
def symbolize_keys(hash)
|
47
|
+
if hash.is_a?(Hash)
|
48
|
+
hash = hash.each_with_object({}) do |(key, value), newhash|
|
49
|
+
begin
|
50
|
+
newhash[key.to_sym] = symbolize_keys(value)
|
51
|
+
rescue NoMethodError
|
52
|
+
raise "Error: cannot convert hash key to symbol: #{key}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
hash
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module RubyShift
|
2
|
+
module Error
|
3
|
+
# Custom error class for rescuing from all Gitlab errors.
|
4
|
+
class Error < StandardError; end
|
5
|
+
|
6
|
+
# Raised when API endpoint credentials not configured.
|
7
|
+
class MissingCredentials < Error; end
|
8
|
+
|
9
|
+
# Raised when impossible to parse response body.
|
10
|
+
class Parsing < Error; end
|
11
|
+
|
12
|
+
# Raised when API endpoint returns the HTTP status code 400.
|
13
|
+
class BadRequest < Error; end
|
14
|
+
|
15
|
+
# Raised when API endpoint returns the HTTP status code 401.
|
16
|
+
class Unauthorized < Error; end
|
17
|
+
|
18
|
+
# Raised when API endpoint returns the HTTP status code 403.
|
19
|
+
class Forbidden < Error; end
|
20
|
+
|
21
|
+
# Raised when API endpoint returns the HTTP status code 404.
|
22
|
+
class NotFound < Error; end
|
23
|
+
|
24
|
+
# Raised when API endpoint returns the HTTP status code 405.
|
25
|
+
class MethodNotAllowed < Error; end
|
26
|
+
|
27
|
+
# Raised when API endpoint returns the HTTP status code 409.
|
28
|
+
class Conflict < Error; end
|
29
|
+
|
30
|
+
# Raised when API endpoint returns the HTTP status code 422.
|
31
|
+
class Unprocessable < Error; end
|
32
|
+
|
33
|
+
# Raised when API endpoint returns the HTTP status code 500.
|
34
|
+
class InternalServerError < Error; end
|
35
|
+
|
36
|
+
# Raised when API endpoint returns the HTTP status code 502.
|
37
|
+
class BadGateway < Error; end
|
38
|
+
|
39
|
+
# Raised when API endpoint returns the HTTP status code 503.
|
40
|
+
class ServiceUnavailable < Error; end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'json'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
module RubyShift
|
6
|
+
class Request
|
7
|
+
include HTTParty
|
8
|
+
format :json
|
9
|
+
headers 'Accept' => 'application/json'
|
10
|
+
parser proc { |body, _| parse(body) }
|
11
|
+
|
12
|
+
attr_accessor :access_token, :endpoint
|
13
|
+
|
14
|
+
def self.parse(body)
|
15
|
+
data = decode(body)['data']
|
16
|
+
|
17
|
+
if data.is_a? Hash
|
18
|
+
data.delete('links')
|
19
|
+
data.delete('members')
|
20
|
+
OpenStruct.new data
|
21
|
+
elsif data.is_a? Array
|
22
|
+
data.collect! { |d|
|
23
|
+
d.delete('links')
|
24
|
+
d.delete('members')
|
25
|
+
OpenStruct.new(d)
|
26
|
+
}
|
27
|
+
elsif data
|
28
|
+
true
|
29
|
+
elsif !data
|
30
|
+
false
|
31
|
+
elsif data.nil?
|
32
|
+
false
|
33
|
+
else
|
34
|
+
raise Error::Parsing.new "Couldn't parse the response body: #{body.inspect}"
|
35
|
+
end
|
36
|
+
rescue
|
37
|
+
raise Error::Parsing.new "Couldn't parse the response body: #{body.inspect}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.decode(response)
|
41
|
+
JSON.load response
|
42
|
+
rescue JSON::ParserError
|
43
|
+
raise Error::Parsing.new "The response is not a valid JSON"
|
44
|
+
end
|
45
|
+
|
46
|
+
def get(path, options={})
|
47
|
+
set_httparty_config(options)
|
48
|
+
set_authorization_header(options)
|
49
|
+
validate self.class.get(@endpoint + path, options)
|
50
|
+
end
|
51
|
+
|
52
|
+
def post(path, options={})
|
53
|
+
set_httparty_config(options)
|
54
|
+
set_authorization_header(options, path)
|
55
|
+
validate self.class.post(@endpoint + path, options)
|
56
|
+
end
|
57
|
+
|
58
|
+
def put(path, options={})
|
59
|
+
set_httparty_config(options)
|
60
|
+
set_authorization_header(options)
|
61
|
+
validate self.class.put(@endpoint + path, options)
|
62
|
+
end
|
63
|
+
|
64
|
+
def delete(path, options={})
|
65
|
+
set_httparty_config(options)
|
66
|
+
set_authorization_header(options)
|
67
|
+
validate self.class.delete(@endpoint + path, options)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Checks the response code for common errors.
|
71
|
+
# Returns parsed response for successful requests.
|
72
|
+
def validate(response)
|
73
|
+
case response.code
|
74
|
+
when 400 then fail Error::BadRequest.new error_message(response)
|
75
|
+
when 401 then fail Error::Unauthorized.new error_message(response)
|
76
|
+
when 403 then fail Error::Forbidden.new error_message(response)
|
77
|
+
when 404 then fail Error::NotFound.new error_message(response)
|
78
|
+
when 405 then fail Error::MethodNotAllowed.new error_message(response)
|
79
|
+
when 409 then fail Error::Conflict.new error_message(response)
|
80
|
+
when 422 then fail Error::Unprocessable.new error_message(response)
|
81
|
+
when 500 then fail Error::InternalServerError.new error_message(response)
|
82
|
+
when 502 then fail Error::BadGateway.new error_message(response)
|
83
|
+
when 503 then fail Error::ServiceUnavailable.new error_message(response)
|
84
|
+
end
|
85
|
+
|
86
|
+
parsed = response.parsed_response
|
87
|
+
parsed.client = self if parsed.respond_to?(:client=)
|
88
|
+
parsed.parse_headers!(response.headers) if parsed.respond_to?(:parse_headers!)
|
89
|
+
parsed
|
90
|
+
end
|
91
|
+
|
92
|
+
# Sets default_params for requests.
|
93
|
+
# @raise [Error::MissingCredentials] if endpoint not set.
|
94
|
+
def set_request_defaults(httparty=nil)
|
95
|
+
raise Error::MissingCredentials.new("Please set an API endpoint") unless @endpoint
|
96
|
+
#self.class.default_params[:httparty] = {} if httparty.nil?
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
# Sets Authorization header for requests.
|
102
|
+
# @raise [Error::MissingCredentials] if access_token is not set.
|
103
|
+
def set_authorization_header(options, path=nil)
|
104
|
+
unless path and path.start_with? '/oauth'
|
105
|
+
raise Error::MissingCredentials.new("Please provide an access_token") unless @access_token
|
106
|
+
options[:headers] = { 'Authorization' => "Bearer #{@access_token}" }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Set HTTParty configuration
|
111
|
+
# @see https://github.com/jnunemaker/httparty
|
112
|
+
def set_httparty_config(options)
|
113
|
+
options.merge!(httparty) if httparty
|
114
|
+
end
|
115
|
+
|
116
|
+
def error_message(response)
|
117
|
+
parsed_response = response.parsed_response
|
118
|
+
message = parsed_response
|
119
|
+
|
120
|
+
"Server responded with code #{response.code}, message: " \
|
121
|
+
"#{handle_error(message)}. " \
|
122
|
+
"Request URI: #{response.request.base_uri}#{response.request.path}"
|
123
|
+
end
|
124
|
+
|
125
|
+
def handle_error(message)
|
126
|
+
case message
|
127
|
+
when OpenStruct
|
128
|
+
message.to_h.sort.map do |key, val|
|
129
|
+
"'#{key}' #{(val.is_a?(Hash) ? val.sort.map { |k, v| "(#{k}: #{v.join(' ')})" } : val).join(' ')}"
|
130
|
+
end.join(', ')
|
131
|
+
when Array
|
132
|
+
message.join(' ')
|
133
|
+
else
|
134
|
+
message
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
data/lib/rubyshift.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rubyshift/version'
|
2
|
+
require 'rubyshift/configuration'
|
3
|
+
require 'rubyshift/error'
|
4
|
+
require 'rubyshift/request'
|
5
|
+
require 'rubyshift/api'
|
6
|
+
require 'rubyshift/client'
|
7
|
+
|
8
|
+
module RubyShift
|
9
|
+
extend Configuration
|
10
|
+
|
11
|
+
def self.client(options={})
|
12
|
+
RubyShift::Client.new(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Delegate to RubyShift::Client
|
16
|
+
def self.method_missing(method, *args, &block)
|
17
|
+
return super unless client.respond_to?(method)
|
18
|
+
client.send(method, *args, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
def respond_to_missing?(method_name, include_private = false)
|
22
|
+
client.respond_to?(method_name) || super
|
23
|
+
end
|
24
|
+
|
25
|
+
# Delegate to HTTParty.http_proxy
|
26
|
+
def self.http_proxy(address=nil, port=nil, username=nil, password=nil)
|
27
|
+
RubyShift::Request.http_proxy(address, port, username, password)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Return an array of available client methods
|
31
|
+
def self.actions
|
32
|
+
hidden = /endpoint|username|password|access_token|user_agent|get|post|put|\Adelete\z|validate|set_request_defaults|httparty/
|
33
|
+
(RubyShift::Client.instance_methods - Object.methods).reject { |e| e[hidden]}
|
34
|
+
end
|
35
|
+
end
|
data/rubyshift.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'rubyshift/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "rubyshift"
|
7
|
+
gem.version = RubyShift::VERSION
|
8
|
+
gem.authors = ["Anurag Patel"]
|
9
|
+
gem.email = ["gnurag@gmail.com"]
|
10
|
+
gem.description = %q{Ruby client for OpenShift REST API}
|
11
|
+
gem.summary = %q{A Ruby wrapper for the OpenShift REST API}
|
12
|
+
gem.homepage = "https://github.com/gnurag/rubyshift"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.license = "BSD"
|
18
|
+
|
19
|
+
gem.add_runtime_dependency 'httparty', '~> 0.13'
|
20
|
+
|
21
|
+
gem.add_development_dependency 'pry', '~> 0.10'
|
22
|
+
gem.add_development_dependency 'rake', '~> 11.0'
|
23
|
+
gem.add_development_dependency 'rspec', '~> 3.4'
|
24
|
+
gem.add_development_dependency 'webmock', '~> 1.24'
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"api_version":1.7,"data":{"aliases":[],"app_url":"http://othello-rubyshift.rhcloud.com/","auto_deploy":true,"build_job_url":null,"building_app":null,"building_with":null,"creation_time":"2016-04-18T09:51:13Z","deployment_branch":"master","deployment_type":"git","domain_id":"rubyshift","embedded":{"haproxy-1.4":{}},"framework":"ruby-2.0","gear_count":1,"gear_profile":"small","git_url":"ssh://5714ae1189f5cf026b00002f@othello-rubyshift.rhcloud.com/~/git/othello.git/","ha":false,"health_check_path":"health","id":"5714ae1189f5cf026b00002f","initial_git_url":null,"keep_deployments":1,"links":{"GET":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f","method":"GET","optional_params":[],"rel":"Get application","required_params":[]},"GET_DESCRIPTOR":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/descriptor","method":"GET","optional_params":[],"rel":"Get application descriptor","required_params":[]},"GET_GEAR_GROUPS":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/gear_groups","method":"GET","optional_params":[],"rel":"Get application gear groups","required_params":[]},"START":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Start application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["start"]}]},"STOP":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Stop application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["stop"]}]},"FORCE_STOP":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Force stop application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["force-stop"]}]},"RESTART":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Restart application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["restart"]}]},"SCALE_UP":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Scale up application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["scale-up"]}]},"SCALE_DOWN":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Scale down application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["scale-down"]}]},"TIDY":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Tidy the application framework","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["tidy"]}]},"RELOAD":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Reload the application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["reload"]}]},"THREAD_DUMP":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Trigger thread dump","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["thread-dump"]}]},"ADD_CARTRIDGE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/cartridges","method":"POST","optional_params":[{"default_value":null,"description":"The component to colocate with","name":"colocate_with","type":"string","valid_options":["haproxy-1.4","ruby-2.0"]},{"default_value":null,"description":"Minimum number of gears to run the component on.","name":"scales_from","type":"integer","valid_options":[]},{"default_value":null,"description":"Maximum number of gears to run the component on.","name":"scales_to","type":"integer","valid_options":[]},{"default_value":null,"description":"Additional GB of space to request on all gears running this component.","name":"additional_gear_storage","type":"integer","valid_options":[]},{"default_value":"small","description":"Gear size for the cartridge.","name":"gear_size","type":"string","valid_options":["small"]},{"default_value":null,"description":"A URL to a downloadable cartridge.","name":"url","type":"string","valid_options":[]},{"default_value":null,"description":"Add or Update application environment variables, e.g.:[{'name':'FOO', 'value':'123'}, {'name':'BAR', 'value':'abc'}]","name":"environment_variables","type":"array","valid_options":[]}],"rel":"Add embedded cartridge","required_params":[{"description":"Name of a cartridge.","invalid_options":[],"name":"name","type":"string","valid_options":[]}]},"LIST_CARTRIDGES":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/cartridges","method":"GET","optional_params":[],"rel":"List embedded cartridges","required_params":[]},"DNS_RESOLVABLE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/dns_resolvable","method":"GET","optional_params":[],"rel":"Resolve DNS","required_params":[]},"ADD_ALIAS":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/aliases","method":"POST","optional_params":[{"default_value":null,"description":"Content of SSL Certificate","name":"ssl_certificate","type":"string","valid_options":[]},{"default_value":null,"description":"Private key for the certificate. Required if adding a certificate","name":"private_key","type":"string","valid_options":[]},{"default_value":null,"description":"Optional passphrase for the private key","name":"pass_phrase","type":"string","valid_options":[]}],"rel":"Create new alias","required_params":[{"description":"Alias for application","invalid_options":[],"name":"id","type":"string","valid_options":[]}]},"LIST_ALIASES":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/aliases","method":"GET","optional_params":[],"rel":"List application aliases","required_params":[]},"LIST_MEMBERS":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/members","method":"GET","optional_params":[],"rel":"List members of this application","required_params":[]},"ADD_ENVIRONMENT_VARIABLE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/environment-variables","method":"POST","optional_params":[],"rel":"Add an environment variable","required_params":[{"description":"Name of the environment variable","invalid_options":[],"name":"name","type":"string","valid_options":[]},{"description":"Value of the environment variable","invalid_options":[],"name":"value","type":"string","valid_options":[]}]},"SET_UNSET_ENVIRONMENT_VARIABLES":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/environment-variables","method":"PATCH","optional_params":[{"default_value":null,"description":"Name of the environment variable to add/update","name":"name","type":"string","valid_options":[]},{"default_value":null,"description":"Value of the environment variable","name":"value","type":"string","valid_options":[]},{"default_value":null,"description":"Add/Update/Delete application environment variables, e.g. Add/Update: [{'name':'FOO', 'value':'123'}, {'name':'BAR', 'value':'abc'}], {Delete: [{'name':'FOO'}, {'name':'BAR'}]}","name":"environment_variables","type":"array","valid_options":[]}],"rel":"Add/Update/Delete one or more environment variables","required_params":[]},"LIST_ENVIRONMENT_VARIABLES":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/environment-variables","method":"GET","optional_params":[],"rel":"List all environment variables","required_params":[]},"DEPLOY":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/deployments","method":"POST","optional_params":[{"default_value":"master","description":"Git ref (tag, branch, commit id)","name":"ref","type":"string","valid_options":[]},{"default_value":null,"description":"URL where the deployment artifact can be downloaded from","name":"artifact_url","type":"string","valid_options":[]},{"default_value":false,"description":"Indicates whether this is a hot deployment","name":"hot_deploy","type":"boolean","valid_options":["true or false"]},{"default_value":false,"description":"Indicates whether a clean build should be performed","name":"force_clean_build","type":"string","valid_options":["true or false"]}],"rel":"Deploy the application","required_params":[]},"UPDATE_DEPLOYMENTS":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/deployments","method":"POST","optional_params":[],"rel":"Update deployments (Special permissions is required to update deployments)","required_params":[{"description":"An array of deployments","invalid_options":[],"name":"deployments","type":"array","valid_options":[]}]},"ACTIVATE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Activate a specific deployment of the application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["activate"]},{"description":"The deployment ID to activate the application","invalid_options":[],"name":"deployment_id","type":"string","valid_options":[]}]},"LIST_DEPLOYMENTS":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/deployments","method":"GET","optional_params":[],"rel":"List all deployments","required_params":[]},"UPDATE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f","method":"PUT","optional_params":[{"default_value":null,"description":"Indicates if OpenShift should build and deploy automatically whenever the user executes git push","name":"auto_deploy","type":"boolean","valid_options":[true,false]},{"default_value":null,"description":"Indicates whether the app is setup for binary or git based deployments","name":"deployment_type","type":"string","valid_options":["git","binary"]},{"default_value":null,"description":"Indicates which branch should trigger an automatic deployment, if automatic deployment is enabled.","name":"deployment_branch","type":"string","valid_options":[]},{"default_value":null,"description":"Indicates how many total deployments to preserve. Must be greater than 0","name":"keep_deployments","type":"integer","valid_options":[]}],"rel":"Update application","required_params":[]},"MAKE_HA":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Make the application Highly Available (HA)","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["make-ha"]}]},"DISABLE_HA":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Disable Highly Available (HA) on the application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["disable-ha"]}]},"DELETE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f","method":"DELETE","optional_params":[],"rel":"Delete application","required_params":[]}},"members":[{"explicit_role":null,"from":[{"type":"domain","role":"admin"}],"id":"511a77b2f2cb83597b000d32","links":{"GET":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/member/511a77b2f2cb83597b000d32","method":"GET","optional_params":[],"rel":"Get member","required_params":[]},"UPDATE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/member/511a77b2f2cb83597b000d32","method":"PUT","optional_params":[],"rel":"Update member","required_params":[{"description":"New role for member","invalid_options":[],"name":"role","type":"string","valid_options":[]}]},"DELETE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/member/511a77b2f2cb83597b000d32","method":"DELETE","optional_params":[],"rel":"Delete member","required_params":[]}},"login":"anurag@xinh.org","owner":true,"role":"admin","type":"user"}],"name":"othello","scalable":true,"ssh_url":"ssh://5714ae1189f5cf026b00002f@othello-rubyshift.rhcloud.com"},"messages":[{"exit_code":0,"field":null,"index":null,"severity":"info","text":"Application 'othello' found"}],"status":"ok","supported_api_versions":[1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7],"type":"application","version":"1.7"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"api_version":1.7,"data":[{"aliases":[],"app_url":"http://hamlet-rubyshift.rhcloud.com/","auto_deploy":true,"build_job_url":null,"building_app":null,"building_with":null,"creation_time":"2016-04-18T10:01:49Z","deployment_branch":"master","deployment_type":"git","domain_id":"rubyshift","embedded":{"haproxy-1.4":{}},"framework":"python-3.3","gear_count":1,"gear_profile":"small","git_url":"ssh://5714b08d2d52710974000123@hamlet-rubyshift.rhcloud.com/~/git/hamlet.git/","ha":false,"health_check_path":"health","id":"5714b08d2d52710974000123","initial_git_url":null,"keep_deployments":1,"links":{"GET":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123","method":"GET","optional_params":[],"rel":"Get application","required_params":[]},"GET_DESCRIPTOR":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/descriptor","method":"GET","optional_params":[],"rel":"Get application descriptor","required_params":[]},"GET_GEAR_GROUPS":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/gear_groups","method":"GET","optional_params":[],"rel":"Get application gear groups","required_params":[]},"START":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/events","method":"POST","optional_params":[],"rel":"Start application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["start"]}]},"STOP":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/events","method":"POST","optional_params":[],"rel":"Stop application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["stop"]}]},"FORCE_STOP":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/events","method":"POST","optional_params":[],"rel":"Force stop application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["force-stop"]}]},"RESTART":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/events","method":"POST","optional_params":[],"rel":"Restart application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["restart"]}]},"SCALE_UP":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/events","method":"POST","optional_params":[],"rel":"Scale up application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["scale-up"]}]},"SCALE_DOWN":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/events","method":"POST","optional_params":[],"rel":"Scale down application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["scale-down"]}]},"TIDY":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/events","method":"POST","optional_params":[],"rel":"Tidy the application framework","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["tidy"]}]},"RELOAD":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/events","method":"POST","optional_params":[],"rel":"Reload the application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["reload"]}]},"THREAD_DUMP":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/events","method":"POST","optional_params":[],"rel":"Trigger thread dump","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["thread-dump"]}]},"ADD_CARTRIDGE":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/cartridges","method":"POST","optional_params":[{"default_value":null,"description":"The component to colocate with","name":"colocate_with","type":"string","valid_options":["haproxy-1.4","python-3.3"]},{"default_value":null,"description":"Minimum number of gears to run the component on.","name":"scales_from","type":"integer","valid_options":[]},{"default_value":null,"description":"Maximum number of gears to run the component on.","name":"scales_to","type":"integer","valid_options":[]},{"default_value":null,"description":"Additional GB of space to request on all gears running this component.","name":"additional_gear_storage","type":"integer","valid_options":[]},{"default_value":"small","description":"Gear size for the cartridge.","name":"gear_size","type":"string","valid_options":["small"]},{"default_value":null,"description":"A URL to a downloadable cartridge.","name":"url","type":"string","valid_options":[]},{"default_value":null,"description":"Add or Update application environment variables, e.g.:[{'name':'FOO', 'value':'123'}, {'name':'BAR', 'value':'abc'}]","name":"environment_variables","type":"array","valid_options":[]}],"rel":"Add embedded cartridge","required_params":[{"description":"Name of a cartridge.","invalid_options":[],"name":"name","type":"string","valid_options":[]}]},"LIST_CARTRIDGES":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/cartridges","method":"GET","optional_params":[],"rel":"List embedded cartridges","required_params":[]},"DNS_RESOLVABLE":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/dns_resolvable","method":"GET","optional_params":[],"rel":"Resolve DNS","required_params":[]},"ADD_ALIAS":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/aliases","method":"POST","optional_params":[{"default_value":null,"description":"Content of SSL Certificate","name":"ssl_certificate","type":"string","valid_options":[]},{"default_value":null,"description":"Private key for the certificate. Required if adding a certificate","name":"private_key","type":"string","valid_options":[]},{"default_value":null,"description":"Optional passphrase for the private key","name":"pass_phrase","type":"string","valid_options":[]}],"rel":"Create new alias","required_params":[{"description":"Alias for application","invalid_options":[],"name":"id","type":"string","valid_options":[]}]},"LIST_ALIASES":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/aliases","method":"GET","optional_params":[],"rel":"List application aliases","required_params":[]},"LIST_MEMBERS":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/members","method":"GET","optional_params":[],"rel":"List members of this application","required_params":[]},"ADD_ENVIRONMENT_VARIABLE":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/environment-variables","method":"POST","optional_params":[],"rel":"Add an environment variable","required_params":[{"description":"Name of the environment variable","invalid_options":[],"name":"name","type":"string","valid_options":[]},{"description":"Value of the environment variable","invalid_options":[],"name":"value","type":"string","valid_options":[]}]},"SET_UNSET_ENVIRONMENT_VARIABLES":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/environment-variables","method":"PATCH","optional_params":[{"default_value":null,"description":"Name of the environment variable to add/update","name":"name","type":"string","valid_options":[]},{"default_value":null,"description":"Value of the environment variable","name":"value","type":"string","valid_options":[]},{"default_value":null,"description":"Add/Update/Delete application environment variables, e.g. Add/Update: [{'name':'FOO', 'value':'123'}, {'name':'BAR', 'value':'abc'}], {Delete: [{'name':'FOO'}, {'name':'BAR'}]}","name":"environment_variables","type":"array","valid_options":[]}],"rel":"Add/Update/Delete one or more environment variables","required_params":[]},"LIST_ENVIRONMENT_VARIABLES":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/environment-variables","method":"GET","optional_params":[],"rel":"List all environment variables","required_params":[]},"DEPLOY":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/deployments","method":"POST","optional_params":[{"default_value":"master","description":"Git ref (tag, branch, commit id)","name":"ref","type":"string","valid_options":[]},{"default_value":null,"description":"URL where the deployment artifact can be downloaded from","name":"artifact_url","type":"string","valid_options":[]},{"default_value":false,"description":"Indicates whether this is a hot deployment","name":"hot_deploy","type":"boolean","valid_options":["true or false"]},{"default_value":false,"description":"Indicates whether a clean build should be performed","name":"force_clean_build","type":"string","valid_options":["true or false"]}],"rel":"Deploy the application","required_params":[]},"UPDATE_DEPLOYMENTS":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/deployments","method":"POST","optional_params":[],"rel":"Update deployments (Special permissions is required to update deployments)","required_params":[{"description":"An array of deployments","invalid_options":[],"name":"deployments","type":"array","valid_options":[]}]},"ACTIVATE":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/events","method":"POST","optional_params":[],"rel":"Activate a specific deployment of the application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["activate"]},{"description":"The deployment ID to activate the application","invalid_options":[],"name":"deployment_id","type":"string","valid_options":[]}]},"LIST_DEPLOYMENTS":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/deployments","method":"GET","optional_params":[],"rel":"List all deployments","required_params":[]},"UPDATE":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123","method":"PUT","optional_params":[{"default_value":null,"description":"Indicates if OpenShift should build and deploy automatically whenever the user executes git push","name":"auto_deploy","type":"boolean","valid_options":[true,false]},{"default_value":null,"description":"Indicates whether the app is setup for binary or git based deployments","name":"deployment_type","type":"string","valid_options":["git","binary"]},{"default_value":null,"description":"Indicates which branch should trigger an automatic deployment, if automatic deployment is enabled.","name":"deployment_branch","type":"string","valid_options":[]},{"default_value":null,"description":"Indicates how many total deployments to preserve. Must be greater than 0","name":"keep_deployments","type":"integer","valid_options":[]}],"rel":"Update application","required_params":[]},"MAKE_HA":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/events","method":"POST","optional_params":[],"rel":"Make the application Highly Available (HA)","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["make-ha"]}]},"DISABLE_HA":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/events","method":"POST","optional_params":[],"rel":"Disable Highly Available (HA) on the application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["disable-ha"]}]},"DELETE":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123","method":"DELETE","optional_params":[],"rel":"Delete application","required_params":[]}},"members":[{"explicit_role":null,"from":[{"type":"domain","role":"admin"}],"id":"511a77b2f2cb83597b000d32","links":{"GET":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/member/511a77b2f2cb83597b000d32","method":"GET","optional_params":[],"rel":"Get member","required_params":[]},"UPDATE":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/member/511a77b2f2cb83597b000d32","method":"PUT","optional_params":[],"rel":"Update member","required_params":[{"description":"New role for member","invalid_options":[],"name":"role","type":"string","valid_options":[]}]},"DELETE":{"href":"https://openshift.redhat.com/broker/rest/application/5714b08d2d52710974000123/member/511a77b2f2cb83597b000d32","method":"DELETE","optional_params":[],"rel":"Delete member","required_params":[]}},"login":"anurag@xinh.org","owner":true,"role":"admin","type":"user"}],"name":"hamlet","scalable":true,"ssh_url":"ssh://5714b08d2d52710974000123@hamlet-rubyshift.rhcloud.com"},{"aliases":[],"app_url":"http://macbeth-rubyshift.rhcloud.com/","auto_deploy":true,"build_job_url":null,"building_app":null,"building_with":null,"creation_time":"2016-04-18T09:55:11Z","deployment_branch":"master","deployment_type":"git","domain_id":"rubyshift","embedded":{},"framework":"php-5.4","gear_count":1,"gear_profile":"small","git_url":"ssh://5714aeff2d5271e5300000cb@macbeth-rubyshift.rhcloud.com/~/git/macbeth.git/","ha":false,"health_check_path":"health","id":"5714aeff2d5271e5300000cb","initial_git_url":null,"keep_deployments":1,"links":{"GET":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb","method":"GET","optional_params":[],"rel":"Get application","required_params":[]},"GET_DESCRIPTOR":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/descriptor","method":"GET","optional_params":[],"rel":"Get application descriptor","required_params":[]},"GET_GEAR_GROUPS":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/gear_groups","method":"GET","optional_params":[],"rel":"Get application gear groups","required_params":[]},"START":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/events","method":"POST","optional_params":[],"rel":"Start application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["start"]}]},"STOP":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/events","method":"POST","optional_params":[],"rel":"Stop application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["stop"]}]},"FORCE_STOP":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/events","method":"POST","optional_params":[],"rel":"Force stop application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["force-stop"]}]},"RESTART":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/events","method":"POST","optional_params":[],"rel":"Restart application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["restart"]}]},"SCALE_UP":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/events","method":"POST","optional_params":[],"rel":"Scale up application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["scale-up"]}]},"SCALE_DOWN":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/events","method":"POST","optional_params":[],"rel":"Scale down application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["scale-down"]}]},"TIDY":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/events","method":"POST","optional_params":[],"rel":"Tidy the application framework","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["tidy"]}]},"RELOAD":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/events","method":"POST","optional_params":[],"rel":"Reload the application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["reload"]}]},"THREAD_DUMP":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/events","method":"POST","optional_params":[],"rel":"Trigger thread dump","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["thread-dump"]}]},"ADD_CARTRIDGE":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/cartridges","method":"POST","optional_params":[{"default_value":null,"description":"The component to colocate with","name":"colocate_with","type":"string","valid_options":["php-5.4"]},{"default_value":null,"description":"Minimum number of gears to run the component on.","name":"scales_from","type":"integer","valid_options":[]},{"default_value":null,"description":"Maximum number of gears to run the component on.","name":"scales_to","type":"integer","valid_options":[]},{"default_value":null,"description":"Additional GB of space to request on all gears running this component.","name":"additional_gear_storage","type":"integer","valid_options":[]},{"default_value":"small","description":"Gear size for the cartridge.","name":"gear_size","type":"string","valid_options":["small"]},{"default_value":null,"description":"A URL to a downloadable cartridge.","name":"url","type":"string","valid_options":[]},{"default_value":null,"description":"Add or Update application environment variables, e.g.:[{'name':'FOO', 'value':'123'}, {'name':'BAR', 'value':'abc'}]","name":"environment_variables","type":"array","valid_options":[]}],"rel":"Add embedded cartridge","required_params":[{"description":"Name of a cartridge.","invalid_options":[],"name":"name","type":"string","valid_options":[]}]},"LIST_CARTRIDGES":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/cartridges","method":"GET","optional_params":[],"rel":"List embedded cartridges","required_params":[]},"DNS_RESOLVABLE":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/dns_resolvable","method":"GET","optional_params":[],"rel":"Resolve DNS","required_params":[]},"ADD_ALIAS":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/aliases","method":"POST","optional_params":[{"default_value":null,"description":"Content of SSL Certificate","name":"ssl_certificate","type":"string","valid_options":[]},{"default_value":null,"description":"Private key for the certificate. Required if adding a certificate","name":"private_key","type":"string","valid_options":[]},{"default_value":null,"description":"Optional passphrase for the private key","name":"pass_phrase","type":"string","valid_options":[]}],"rel":"Create new alias","required_params":[{"description":"Alias for application","invalid_options":[],"name":"id","type":"string","valid_options":[]}]},"LIST_ALIASES":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/aliases","method":"GET","optional_params":[],"rel":"List application aliases","required_params":[]},"LIST_MEMBERS":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/members","method":"GET","optional_params":[],"rel":"List members of this application","required_params":[]},"ADD_ENVIRONMENT_VARIABLE":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/environment-variables","method":"POST","optional_params":[],"rel":"Add an environment variable","required_params":[{"description":"Name of the environment variable","invalid_options":[],"name":"name","type":"string","valid_options":[]},{"description":"Value of the environment variable","invalid_options":[],"name":"value","type":"string","valid_options":[]}]},"SET_UNSET_ENVIRONMENT_VARIABLES":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/environment-variables","method":"PATCH","optional_params":[{"default_value":null,"description":"Name of the environment variable to add/update","name":"name","type":"string","valid_options":[]},{"default_value":null,"description":"Value of the environment variable","name":"value","type":"string","valid_options":[]},{"default_value":null,"description":"Add/Update/Delete application environment variables, e.g. Add/Update: [{'name':'FOO', 'value':'123'}, {'name':'BAR', 'value':'abc'}], {Delete: [{'name':'FOO'}, {'name':'BAR'}]}","name":"environment_variables","type":"array","valid_options":[]}],"rel":"Add/Update/Delete one or more environment variables","required_params":[]},"LIST_ENVIRONMENT_VARIABLES":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/environment-variables","method":"GET","optional_params":[],"rel":"List all environment variables","required_params":[]},"DEPLOY":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/deployments","method":"POST","optional_params":[{"default_value":"master","description":"Git ref (tag, branch, commit id)","name":"ref","type":"string","valid_options":[]},{"default_value":null,"description":"URL where the deployment artifact can be downloaded from","name":"artifact_url","type":"string","valid_options":[]},{"default_value":false,"description":"Indicates whether this is a hot deployment","name":"hot_deploy","type":"boolean","valid_options":["true or false"]},{"default_value":false,"description":"Indicates whether a clean build should be performed","name":"force_clean_build","type":"string","valid_options":["true or false"]}],"rel":"Deploy the application","required_params":[]},"UPDATE_DEPLOYMENTS":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/deployments","method":"POST","optional_params":[],"rel":"Update deployments (Special permissions is required to update deployments)","required_params":[{"description":"An array of deployments","invalid_options":[],"name":"deployments","type":"array","valid_options":[]}]},"ACTIVATE":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/events","method":"POST","optional_params":[],"rel":"Activate a specific deployment of the application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["activate"]},{"description":"The deployment ID to activate the application","invalid_options":[],"name":"deployment_id","type":"string","valid_options":[]}]},"LIST_DEPLOYMENTS":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/deployments","method":"GET","optional_params":[],"rel":"List all deployments","required_params":[]},"UPDATE":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb","method":"PUT","optional_params":[{"default_value":null,"description":"Indicates if OpenShift should build and deploy automatically whenever the user executes git push","name":"auto_deploy","type":"boolean","valid_options":[true,false]},{"default_value":null,"description":"Indicates whether the app is setup for binary or git based deployments","name":"deployment_type","type":"string","valid_options":["git","binary"]},{"default_value":null,"description":"Indicates which branch should trigger an automatic deployment, if automatic deployment is enabled.","name":"deployment_branch","type":"string","valid_options":[]},{"default_value":null,"description":"Indicates how many total deployments to preserve. Must be greater than 0","name":"keep_deployments","type":"integer","valid_options":[]}],"rel":"Update application","required_params":[]},"MAKE_HA":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/events","method":"POST","optional_params":[],"rel":"Make the application Highly Available (HA)","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["make-ha"]}]},"DISABLE_HA":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/events","method":"POST","optional_params":[],"rel":"Disable Highly Available (HA) on the application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["disable-ha"]}]},"DELETE":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb","method":"DELETE","optional_params":[],"rel":"Delete application","required_params":[]}},"members":[{"explicit_role":null,"from":[{"type":"domain","role":"admin"}],"id":"511a77b2f2cb83597b000d32","links":{"GET":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/member/511a77b2f2cb83597b000d32","method":"GET","optional_params":[],"rel":"Get member","required_params":[]},"UPDATE":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/member/511a77b2f2cb83597b000d32","method":"PUT","optional_params":[],"rel":"Update member","required_params":[{"description":"New role for member","invalid_options":[],"name":"role","type":"string","valid_options":[]}]},"DELETE":{"href":"https://openshift.redhat.com/broker/rest/application/5714aeff2d5271e5300000cb/member/511a77b2f2cb83597b000d32","method":"DELETE","optional_params":[],"rel":"Delete member","required_params":[]}},"login":"anurag@xinh.org","owner":true,"role":"admin","type":"user"}],"name":"macbeth","scalable":false,"ssh_url":"ssh://5714aeff2d5271e5300000cb@macbeth-rubyshift.rhcloud.com"},{"aliases":[],"app_url":"http://othello-rubyshift.rhcloud.com/","auto_deploy":true,"build_job_url":null,"building_app":null,"building_with":null,"creation_time":"2016-04-18T09:51:13Z","deployment_branch":"master","deployment_type":"git","domain_id":"rubyshift","embedded":{"haproxy-1.4":{}},"framework":"ruby-2.0","gear_count":1,"gear_profile":"small","git_url":"ssh://5714ae1189f5cf026b00002f@othello-rubyshift.rhcloud.com/~/git/othello.git/","ha":false,"health_check_path":"health","id":"5714ae1189f5cf026b00002f","initial_git_url":null,"keep_deployments":1,"links":{"GET":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f","method":"GET","optional_params":[],"rel":"Get application","required_params":[]},"GET_DESCRIPTOR":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/descriptor","method":"GET","optional_params":[],"rel":"Get application descriptor","required_params":[]},"GET_GEAR_GROUPS":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/gear_groups","method":"GET","optional_params":[],"rel":"Get application gear groups","required_params":[]},"START":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Start application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["start"]}]},"STOP":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Stop application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["stop"]}]},"FORCE_STOP":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Force stop application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["force-stop"]}]},"RESTART":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Restart application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["restart"]}]},"SCALE_UP":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Scale up application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["scale-up"]}]},"SCALE_DOWN":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Scale down application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["scale-down"]}]},"TIDY":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Tidy the application framework","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["tidy"]}]},"RELOAD":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Reload the application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["reload"]}]},"THREAD_DUMP":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Trigger thread dump","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["thread-dump"]}]},"ADD_CARTRIDGE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/cartridges","method":"POST","optional_params":[{"default_value":null,"description":"The component to colocate with","name":"colocate_with","type":"string","valid_options":["haproxy-1.4","ruby-2.0"]},{"default_value":null,"description":"Minimum number of gears to run the component on.","name":"scales_from","type":"integer","valid_options":[]},{"default_value":null,"description":"Maximum number of gears to run the component on.","name":"scales_to","type":"integer","valid_options":[]},{"default_value":null,"description":"Additional GB of space to request on all gears running this component.","name":"additional_gear_storage","type":"integer","valid_options":[]},{"default_value":"small","description":"Gear size for the cartridge.","name":"gear_size","type":"string","valid_options":["small"]},{"default_value":null,"description":"A URL to a downloadable cartridge.","name":"url","type":"string","valid_options":[]},{"default_value":null,"description":"Add or Update application environment variables, e.g.:[{'name':'FOO', 'value':'123'}, {'name':'BAR', 'value':'abc'}]","name":"environment_variables","type":"array","valid_options":[]}],"rel":"Add embedded cartridge","required_params":[{"description":"Name of a cartridge.","invalid_options":[],"name":"name","type":"string","valid_options":[]}]},"LIST_CARTRIDGES":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/cartridges","method":"GET","optional_params":[],"rel":"List embedded cartridges","required_params":[]},"DNS_RESOLVABLE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/dns_resolvable","method":"GET","optional_params":[],"rel":"Resolve DNS","required_params":[]},"ADD_ALIAS":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/aliases","method":"POST","optional_params":[{"default_value":null,"description":"Content of SSL Certificate","name":"ssl_certificate","type":"string","valid_options":[]},{"default_value":null,"description":"Private key for the certificate. Required if adding a certificate","name":"private_key","type":"string","valid_options":[]},{"default_value":null,"description":"Optional passphrase for the private key","name":"pass_phrase","type":"string","valid_options":[]}],"rel":"Create new alias","required_params":[{"description":"Alias for application","invalid_options":[],"name":"id","type":"string","valid_options":[]}]},"LIST_ALIASES":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/aliases","method":"GET","optional_params":[],"rel":"List application aliases","required_params":[]},"LIST_MEMBERS":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/members","method":"GET","optional_params":[],"rel":"List members of this application","required_params":[]},"ADD_ENVIRONMENT_VARIABLE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/environment-variables","method":"POST","optional_params":[],"rel":"Add an environment variable","required_params":[{"description":"Name of the environment variable","invalid_options":[],"name":"name","type":"string","valid_options":[]},{"description":"Value of the environment variable","invalid_options":[],"name":"value","type":"string","valid_options":[]}]},"SET_UNSET_ENVIRONMENT_VARIABLES":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/environment-variables","method":"PATCH","optional_params":[{"default_value":null,"description":"Name of the environment variable to add/update","name":"name","type":"string","valid_options":[]},{"default_value":null,"description":"Value of the environment variable","name":"value","type":"string","valid_options":[]},{"default_value":null,"description":"Add/Update/Delete application environment variables, e.g. Add/Update: [{'name':'FOO', 'value':'123'}, {'name':'BAR', 'value':'abc'}], {Delete: [{'name':'FOO'}, {'name':'BAR'}]}","name":"environment_variables","type":"array","valid_options":[]}],"rel":"Add/Update/Delete one or more environment variables","required_params":[]},"LIST_ENVIRONMENT_VARIABLES":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/environment-variables","method":"GET","optional_params":[],"rel":"List all environment variables","required_params":[]},"DEPLOY":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/deployments","method":"POST","optional_params":[{"default_value":"master","description":"Git ref (tag, branch, commit id)","name":"ref","type":"string","valid_options":[]},{"default_value":null,"description":"URL where the deployment artifact can be downloaded from","name":"artifact_url","type":"string","valid_options":[]},{"default_value":false,"description":"Indicates whether this is a hot deployment","name":"hot_deploy","type":"boolean","valid_options":["true or false"]},{"default_value":false,"description":"Indicates whether a clean build should be performed","name":"force_clean_build","type":"string","valid_options":["true or false"]}],"rel":"Deploy the application","required_params":[]},"UPDATE_DEPLOYMENTS":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/deployments","method":"POST","optional_params":[],"rel":"Update deployments (Special permissions is required to update deployments)","required_params":[{"description":"An array of deployments","invalid_options":[],"name":"deployments","type":"array","valid_options":[]}]},"ACTIVATE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Activate a specific deployment of the application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["activate"]},{"description":"The deployment ID to activate the application","invalid_options":[],"name":"deployment_id","type":"string","valid_options":[]}]},"LIST_DEPLOYMENTS":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/deployments","method":"GET","optional_params":[],"rel":"List all deployments","required_params":[]},"UPDATE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f","method":"PUT","optional_params":[{"default_value":null,"description":"Indicates if OpenShift should build and deploy automatically whenever the user executes git push","name":"auto_deploy","type":"boolean","valid_options":[true,false]},{"default_value":null,"description":"Indicates whether the app is setup for binary or git based deployments","name":"deployment_type","type":"string","valid_options":["git","binary"]},{"default_value":null,"description":"Indicates which branch should trigger an automatic deployment, if automatic deployment is enabled.","name":"deployment_branch","type":"string","valid_options":[]},{"default_value":null,"description":"Indicates how many total deployments to preserve. Must be greater than 0","name":"keep_deployments","type":"integer","valid_options":[]}],"rel":"Update application","required_params":[]},"MAKE_HA":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Make the application Highly Available (HA)","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["make-ha"]}]},"DISABLE_HA":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/events","method":"POST","optional_params":[],"rel":"Disable Highly Available (HA) on the application","required_params":[{"description":"event","invalid_options":[],"name":"event","type":"string","valid_options":["disable-ha"]}]},"DELETE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f","method":"DELETE","optional_params":[],"rel":"Delete application","required_params":[]}},"members":[{"explicit_role":null,"from":[{"type":"domain","role":"admin"}],"id":"511a77b2f2cb83597b000d32","links":{"GET":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/member/511a77b2f2cb83597b000d32","method":"GET","optional_params":[],"rel":"Get member","required_params":[]},"UPDATE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/member/511a77b2f2cb83597b000d32","method":"PUT","optional_params":[],"rel":"Update member","required_params":[{"description":"New role for member","invalid_options":[],"name":"role","type":"string","valid_options":[]}]},"DELETE":{"href":"https://openshift.redhat.com/broker/rest/application/5714ae1189f5cf026b00002f/member/511a77b2f2cb83597b000d32","method":"DELETE","optional_params":[],"rel":"Delete member","required_params":[]}},"login":"anurag@xinh.org","owner":true,"role":"admin","type":"user"}],"name":"othello","scalable":true,"ssh_url":"ssh://5714ae1189f5cf026b00002f@othello-rubyshift.rhcloud.com"}],"messages":[{"exit_code":0,"field":null,"index":null,"severity":"info","text":"Found 3 applications."}],"status":"ok","supported_api_versions":[1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7],"type":"applications","version":"1.7"}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyShift::Client do
|
4
|
+
it { should respond_to :applications }
|
5
|
+
|
6
|
+
describe ".applications" do
|
7
|
+
before do
|
8
|
+
stub_get("/applications", "applications")
|
9
|
+
@applications = RubyShift.applications
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should get the correct resource" do
|
13
|
+
expect(a_get("/applications")).to have_been_made
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return a list of applications" do
|
17
|
+
expect(@applications).to be_an Array
|
18
|
+
expect(@applications.first.name).to eq("hamlet")
|
19
|
+
expect(@applications.first.domain_id).to eq("rubyshift")
|
20
|
+
expect(@applications.first.framework).to eq("python-3.3")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".application" do
|
25
|
+
before do
|
26
|
+
stub_get("/application/5714ae1189f5cf026b00002f", "application")
|
27
|
+
@application = RubyShift.application("5714ae1189f5cf026b00002f")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should get the correct resource" do
|
31
|
+
expect(a_get("/application/5714ae1189f5cf026b00002f")).to have_been_made
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return application info json" do
|
35
|
+
expect(@application.name).to eq("othello")
|
36
|
+
expect(@application.domain_id).to eq("rubyshift")
|
37
|
+
expect(@application.framework).to eq("ruby-2.0")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyShift::Request do
|
4
|
+
it { should respond_to :get}
|
5
|
+
it { should respond_to :post}
|
6
|
+
it { should respond_to :put}
|
7
|
+
it { should respond_to :delete}
|
8
|
+
|
9
|
+
before do
|
10
|
+
@request = RubyShift::Request.new
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".default_options" do
|
14
|
+
it "should have default values set" do
|
15
|
+
default_options = RubyShift::Request.default_options
|
16
|
+
expect(default_options).to be_a Hash
|
17
|
+
expect(default_options[:parser]).to be_a Proc
|
18
|
+
expect(default_options[:format]).to eq(:json)
|
19
|
+
expect(default_options[:headers]).to eq({'Accept' => 'application/json'})
|
20
|
+
expect(default_options[:default_params]).to be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".parse" do
|
25
|
+
it "should return OpenStruct object" do
|
26
|
+
body = JSON.unparse(a: 1, b: 2)
|
27
|
+
expect(RubyShift::Request.parse(body)).to be_an OpenStruct
|
28
|
+
expect(RubyShift::Request.parse("true")).to be true
|
29
|
+
expect(RubyShift::Request.parse("false")).to be false
|
30
|
+
|
31
|
+
expect { RubyShift::Request.parse("test string") }.to raise_error(RubyShift::Error::Parsing)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#set_request_defaults" do
|
36
|
+
context "when endpoint is not set" do
|
37
|
+
it "should raise Error::MissingCredentials" do
|
38
|
+
@request.endpoint = nil
|
39
|
+
expect do
|
40
|
+
@request.set_request_defaults
|
41
|
+
end.to raise_error(RubyShift::Error::MissingCredentials, 'Please set an API endpoint')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when endpoint is set" do
|
46
|
+
before(:each) do
|
47
|
+
@request.endpoint = 'http://openshift_spec.redhat.com/broker/rest'
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should allow setting default_params" do
|
51
|
+
@request.set_request_defaults
|
52
|
+
expect(RubyShift::Request.default_params).to eq(httparty: {})
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#set_authorization_header" do
|
58
|
+
it "should raise MissingCredentials when access_token is not set" do
|
59
|
+
expect do
|
60
|
+
@request.send(:set_authorization_header, {})
|
61
|
+
end.to raise_error(RubyShift::Error::MissingCredentials)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should set Authorization header when access_token is provided" do
|
65
|
+
@request.access_token = 'Z5b5IhP1a0whYv5o6JyWcvj6WgZFbgDD3W7rZDCWMdacffBn5ZybTxtZXEFVYFUg'
|
66
|
+
expect(@request.send(:set_authorization_header, {})).to eq("Authorization" => "Bearer Z5b5IhP1a0whYv5o6JyWcvj6WgZFbgDD3W7rZDCWMdacffBn5ZybTxtZXEFVYFUg")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#handle_error" do
|
71
|
+
before do
|
72
|
+
@array = ['First message.', 'Second message.']
|
73
|
+
@obj = OpenStruct.new(firstkey: ['not set'], secondkey: ['x'], nested_key: { foo: ['bar'], baz: 'bleh' })
|
74
|
+
end
|
75
|
+
|
76
|
+
context "when passed an OpenStruct" do
|
77
|
+
end
|
78
|
+
|
79
|
+
context "when passed an Array" do
|
80
|
+
it "should return a concatenated string of messages" do
|
81
|
+
expect(@request.send(:handle_error, @array)).to eq('First message. Second message.')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "when passed a string" do
|
86
|
+
it "should return the string untouched" do
|
87
|
+
error = 'here be error string'
|
88
|
+
expect(@request.send(:handle_error, error)).to eq('here be error string')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyShift do
|
4
|
+
after { RubyShift.reset }
|
5
|
+
|
6
|
+
describe ".client" do
|
7
|
+
it "should be RubyShift::Client" do
|
8
|
+
expect(RubyShift.client).to be_a RubyShift::Client
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should not override other RubyShift::Client objects" do
|
12
|
+
client1 = RubyShift.client(endpoint: 'https://openshift1.example.com', access_token: 'hunter1')
|
13
|
+
client2 = RubyShift.client(endpoint: 'https://openshift2.example.com', access_token: 'hunter2')
|
14
|
+
expect(client1.endpoint).to eq('https://openshift1.example.com')
|
15
|
+
expect(client2.endpoint).to eq('https://openshift2.example.com')
|
16
|
+
expect(client1.access_token).to eq('hunter1')
|
17
|
+
expect(client2.access_token).to eq('hunter2')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe ".actions" do
|
22
|
+
it "should return an array of client methods" do
|
23
|
+
actions = RubyShift.actions
|
24
|
+
expect(actions).to be_an Array
|
25
|
+
expect(actions.first).to be_a Symbol
|
26
|
+
expect(actions.sort.first).to eq(:application)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe ".endpoint=" do
|
31
|
+
it "should set endpoint" do
|
32
|
+
RubyShift.endpoint = 'https://openshift.example.com'
|
33
|
+
expect(RubyShift.endpoint).to eq('https://openshift.example.com')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe ".username=" do
|
38
|
+
it "should set username" do
|
39
|
+
RubyShift.username = 'openshiftuser@example.com'
|
40
|
+
expect(RubyShift.username).to eq('openshiftuser@example.com')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe ".password=" do
|
45
|
+
it "should set password" do
|
46
|
+
RubyShift.password = 'hunter2'
|
47
|
+
expect(RubyShift.password).to eq('hunter2')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe ".access_token=" do
|
52
|
+
it "should set access_token" do
|
53
|
+
RubyShift.access_token = 'hunter2hunter2hunter2'
|
54
|
+
expect(RubyShift.access_token).to eq('hunter2hunter2hunter2')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe ".user_agent" do
|
59
|
+
it "should return default user_agent" do
|
60
|
+
expect(RubyShift.user_agent).to eq(RubyShift::Configuration::DEFAULT_USER_AGENT)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe ".user_agent=" do
|
65
|
+
it "should set access_token" do
|
66
|
+
RubyShift.user_agent = 'CustomUserAgent/1.1'
|
67
|
+
expect(RubyShift.user_agent).to eq('CustomUserAgent/1.1')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe ".configure" do
|
72
|
+
RubyShift::Configuration::VALID_OPTIONS_KEYS.each do |key|
|
73
|
+
it "should set #{key}" do
|
74
|
+
RubyShift.configure do |config|
|
75
|
+
config.send("#{key}=", key)
|
76
|
+
expect(RubyShift.send(key)).to eq(key)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe ".http_proxy" do
|
83
|
+
it "delegates the method to RubyShift::Request" do
|
84
|
+
RubyShift.endpoint = 'https://openshift.example.com'
|
85
|
+
request = class_spy(RubyShift::Request).as_stubbed_const
|
86
|
+
|
87
|
+
RubyShift.http_proxy('proxy.example.net', 1337, 'proxyuser', 'hunter2')
|
88
|
+
expect(request).to have_received(:http_proxy).
|
89
|
+
with('proxy.example.net', 1337, 'proxyuser', 'hunter2')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'webmock/rspec'
|
3
|
+
|
4
|
+
require File.expand_path('../../lib/rubyshift', __FILE__)
|
5
|
+
|
6
|
+
def capture_output
|
7
|
+
out = StringIO.new
|
8
|
+
$stdout = out
|
9
|
+
$stderr = out
|
10
|
+
yield
|
11
|
+
$stdout = STDOUT
|
12
|
+
$stderr = STDERR
|
13
|
+
out.string
|
14
|
+
end
|
15
|
+
|
16
|
+
def load_fixture(name)
|
17
|
+
File.new(File.dirname(__FILE__) + "/fixtures/#{name}.json")
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
RSpec.configure do |config|
|
22
|
+
config.before(:all) do
|
23
|
+
RubyShift.endpoint = 'https://openshift.example.com/broker/rest'
|
24
|
+
RubyShift.access_token = 'hunter2'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# GET
|
29
|
+
def stub_get(path, fixture)
|
30
|
+
stub_request(:get, "#{RubyShift.endpoint}#{path}").
|
31
|
+
with(headers: { 'Authorization' => "Bearer #{RubyShift.access_token}" }).
|
32
|
+
to_return(body: load_fixture(fixture))
|
33
|
+
end
|
34
|
+
|
35
|
+
def a_get(path)
|
36
|
+
a_request(:get, "#{RubyShift.endpoint}#{path}").
|
37
|
+
with(headers: { 'Authorization' => "Bearer #{RubyShift.access_token}" })
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubyshift
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anurag Patel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.13'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '11.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '11.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.24'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.24'
|
83
|
+
description: Ruby client for OpenShift REST API
|
84
|
+
email:
|
85
|
+
- gnurag@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- CHANGELOG.md
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- lib/rubyshift.rb
|
96
|
+
- lib/rubyshift/api.rb
|
97
|
+
- lib/rubyshift/client.rb
|
98
|
+
- lib/rubyshift/client/applications.rb
|
99
|
+
- lib/rubyshift/client/cartridges.rb
|
100
|
+
- lib/rubyshift/client/domains.rb
|
101
|
+
- lib/rubyshift/configuration.rb
|
102
|
+
- lib/rubyshift/error.rb
|
103
|
+
- lib/rubyshift/request.rb
|
104
|
+
- lib/rubyshift/version.rb
|
105
|
+
- rubyshift.gemspec
|
106
|
+
- spec/fixtures/application.json
|
107
|
+
- spec/fixtures/applications.json
|
108
|
+
- spec/rubyshift/client/applications_spec.rb
|
109
|
+
- spec/rubyshift/request_spec.rb
|
110
|
+
- spec/rubyshift_spec.rb
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
homepage: https://github.com/gnurag/rubyshift
|
113
|
+
licenses:
|
114
|
+
- BSD
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.5.1
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: A Ruby wrapper for the OpenShift REST API
|
136
|
+
test_files:
|
137
|
+
- spec/fixtures/application.json
|
138
|
+
- spec/fixtures/applications.json
|
139
|
+
- spec/rubyshift/client/applications_spec.rb
|
140
|
+
- spec/rubyshift/request_spec.rb
|
141
|
+
- spec/rubyshift_spec.rb
|
142
|
+
- spec/spec_helper.rb
|