Class: StormMQ::Rest
- Inherits:
-
Object
- Object
- StormMQ::Rest
- Defined in:
- lib/stormmq/rest.rb
Overview
The Rest class implements the client for StormMQ’s RESTful API. The API allows clients to access company, system and environment information.
Instance Method Summary collapse
- #amqp_password(company, system, environment, amqp_user) ⇒ Object
- #amqp_users(company, system, environment) ⇒ Object
- #apis ⇒ Object
- #bindings(company, system, environment) ⇒ Object
- #clusters(company) ⇒ Object
-
#companies ⇒ Object
Returns an Array of company indentifiers associated with the user.
- #create_system(company, system, json) ⇒ Object
- #delete_system(company, system) ⇒ Object
-
#describe_company(company) ⇒ Object
Takes a String containing a valid company identifier and returns a Hash representation of the detailed information stored on the StormMQ system about the company.
- #describe_system(company, system) ⇒ Object
- #exchanges(company, system, environment) ⇒ Object
-
#initialize(options = {}) ⇒ Rest
constructor
A new instance of Rest.
- #queues(company, system, environment) ⇒ Object
- #systems(company) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Rest
Returns a new instance of Rest.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/stormmq/rest.rb', line 33 def initialize(={}) unless @user = .delete(:user) raise Error::UserNotProvidedError, "could not determine the user name - either provide it via the :user param", caller end unless @secret_key = .delete(:secret_key) || self.class.secret_key_from_key_store(@user) raise Error::SecretKeyNotProvidedError, "could not determine the secret key for user '#{@user}' - either provide it via the :secret_key param or ensure it is available in the secret key file", caller end @host = .delete(:host) || API_HOST @api = .delete(:api) || API @version = .delete(:version) || API_VERSION @url_options = end |
Instance Method Details
#amqp_password(company, system, environment, amqp_user) ⇒ Object
100 101 102 |
# File 'lib/stormmq/rest.rb', line 100 def amqp_password(company, system, environment, amqp_user) signed_get(COMPANIES_PATH, escape(company), escape(system), escape(environment), 'users', escape(amqp_user)) end |
#amqp_users(company, system, environment) ⇒ Object
104 105 106 |
# File 'lib/stormmq/rest.rb', line 104 def amqp_users(company, system, environment) signed_get(COMPANIES_PATH, escape(company), escape(system), escape(environment), 'users/') end |
#apis ⇒ Object
96 97 98 |
# File 'lib/stormmq/rest.rb', line 96 def apis signed_get(APIS_PATH) end |
#bindings(company, system, environment) ⇒ Object
88 89 90 |
# File 'lib/stormmq/rest.rb', line 88 def bindings(company, system, environment) signed_get(COMPANIES_PATH, escape(company), escape(system), escape(environment), 'bindings/') end |
#clusters(company) ⇒ Object
80 81 82 |
# File 'lib/stormmq/rest.rb', line 80 def clusters(company) signed_get(CLUSTERS_PATH, escape(company)) end |
#companies ⇒ Object
Returns an Array of company indentifiers associated with the user.
53 54 55 |
# File 'lib/stormmq/rest.rb', line 53 def companies signed_get(COMPANIES_PATH) end |
#create_system(company, system, json) ⇒ Object
68 69 70 |
# File 'lib/stormmq/rest.rb', line 68 def create_system(company, system, json) signed_put(json, COMPANIES_PATH, escape(company), escape(system)) end |
#delete_system(company, system) ⇒ Object
76 77 78 |
# File 'lib/stormmq/rest.rb', line 76 def delete_system(company, system) signed_delete(COMPANIES_PATH, escape(company), escape(system)) end |
#describe_company(company) ⇒ Object
Takes a String containing a valid company identifier and returns a Hash representation of the detailed information stored on the StormMQ system about the company.
60 61 62 |
# File 'lib/stormmq/rest.rb', line 60 def describe_company(company) signed_get(COMPANIES_PATH, escape(company)) end |
#describe_system(company, system) ⇒ Object
72 73 74 |
# File 'lib/stormmq/rest.rb', line 72 def describe_system(company, system) signed_get(COMPANIES_PATH, escape(company), escape(system)) end |
#exchanges(company, system, environment) ⇒ Object
92 93 94 |
# File 'lib/stormmq/rest.rb', line 92 def exchanges(company, system, environment) signed_get(COMPANIES_PATH, escape(company), escape(system), escape(environment), 'exchanges/') end |
#queues(company, system, environment) ⇒ Object
84 85 86 |
# File 'lib/stormmq/rest.rb', line 84 def queues(company, system, environment) signed_get(COMPANIES_PATH, escape(company), escape(system), escape(environment), 'queues/') end |
#systems(company) ⇒ Object
64 65 66 |
# File 'lib/stormmq/rest.rb', line 64 def systems(company) signed_get(COMPANIES_PATH, escape(company), '/') end |