-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
101 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class TopologicalInventory | ||
def self.api | ||
Thread.current[:api_instance] ||= raw_api | ||
end | ||
|
||
def self.call | ||
pass_thru_headers | ||
yield api | ||
rescue TopologicalInventoryApiClient::ApiError => err | ||
Rails.logger.error("TopologicalInventoryApiClient::ApiError #{err.message} ") | ||
raise ServiceCatalog::TopologyError, err.message | ||
end | ||
|
||
private_class_method def self.raw_api | ||
TopologicalInventoryApiClient.configure do |config| | ||
config.host = 'localhost' | ||
config.scheme = 'http' | ||
end | ||
#TopologicalInventoryApiClient::DefaultApi.new | ||
end | ||
|
||
private_class_method def self.pass_thru_headers | ||
{} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"id":"21","name":"rh-mediawiki-apb","description":"Mediawiki apb implementation"},{"id":"153","name":"s2i-fuse71-karaf-camel-rest-sql","description":"Camel example using Rest DSL with SQL Database in Karaf container. This example demonstrates how to use SQL via JDBC along with Camel's REST DSL to expose a RESTful API. The OpenShift MySQL container image should already be installed and running on your OpenShift installation, one simple way to run a MySQL service is following the documentation of the OpenShift MySQL container image related to the mysql-ephemeral template.."}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module ServiceCatalog | ||
class ServiceOffering | ||
def initialize | ||
@name = nil | ||
@description = nil | ||
@service_offering_ref = nil | ||
end | ||
|
||
def self.find(id) | ||
new.show(id) | ||
end | ||
|
||
def show(id) | ||
@service_offering_ref = id | ||
obj = nil | ||
TopologicalInventory.call do |api_instance| | ||
obj = JSON.parse(File.read("#{Rails.root}/spec/support/service_catalog/service_offering.json")) | ||
end | ||
resp = obj.select { |x| x['id'] == id } | ||
@normalized = resp.first | ||
self | ||
end | ||
|
||
def to_normalized_params | ||
hashy = instance_variables.each_with_object({}) do |var, hash| | ||
next if var == :@normalized | ||
hash[var.to_s.delete("@")] = instance_variable_get(var) | ||
end | ||
if @normalized | ||
@normalized["service_offering_ref"] = @normalized["id"] | ||
@normalized | ||
else | ||
hashy.compact | ||
end | ||
end | ||
|
||
private | ||
|
||
def apply_instance_vars(obj) | ||
uniq_ivars(obj).each do |ivar| | ||
value = obj.instance_variable_get(ivar) | ||
instance_variable_set(ivar, value) | ||
end | ||
self | ||
end | ||
|
||
def uniq_ivars(object) | ||
instance_variables & object.instance_variables | ||
end | ||
end | ||
end |