Class: BrpmRequest
Overview
Class for interacting with requests
Instance Method Summary collapse
-
#app ⇒ Object
Gets the app associated with the request.
-
#app_components ⇒ Object
Gets the components associated with request application.
-
#app_environments ⇒ Object
Gets the components associated with request application.
-
#app_routes ⇒ Object
Gets the routes available for the app.
-
#get_list(filter_param) ⇒ Object
Gets a list of requests based on a filter.
-
#groups ⇒ Object
Gets the groups available.
-
#initialize(id, base_url, options = {}, compat_options = {}) ⇒ BrpmRequest
constructor
Initializes an instance of the class.
-
#installed_components ⇒ Object
Gets the installed_components associated with request application.
-
#owner ⇒ Object
Gets the owner of the request.
-
#plan ⇒ Object
Gets the plan of the request.
-
#plan_routes ⇒ Object
Gets the routes available for the app/plan.
-
#plan_stages ⇒ Object
Gets the plan stages available for the plan.
-
#request ⇒ Object
Provides a host status for the passed targets.
-
#requestor ⇒ Object
Gets the requestor of the request.
-
#route_environments(route_id) ⇒ Object
Gets the environments available for the route.
-
#stage ⇒ Object
Gets the stage of the plan the request is in.
-
#steps ⇒ Object
Returns the steps for the request.
-
#update_state(aasm_event) ⇒ Object
Updates the aasm state of the request.
Methods inherited from BrpmRest
#assign_version_to_steps, #checking_interval, #create, #create_version_tags, #get, #monitor_request, #notify, #set_token, #steps_with_matching_component, #update, #version_tag_query
Constructor Details
#initialize(id, base_url, options = {}, compat_options = {}) ⇒ BrpmRequest
Initializes an instance of the class
Attributes
-
id
- id of the request to work with -
base_url
- url of brpm server -
options
- hash of options (see Rest.rest_call for description)
12 13 14 15 16 17 18 19 20 |
# File 'lib/brpm_request.rb', line 12 def initialize(id, base_url, = {}, = {}) if .has_key?("SS_output_dir") BrpmAuto.log "Load for this class has changed, no longer necessary to send params as 2nd argument" = end @id = id response = BrpmAuto.get("requests", @id) @request = response["data"] end |
Instance Method Details
#app ⇒ Object
Gets the app associated with the request
Returns
-
hash of app information
74 75 76 |
# File 'lib/brpm_request.rb', line 74 def app @request["apps"].first end |
#app_components ⇒ Object
Gets the components associated with request application
Returns
-
hash of components
94 95 96 97 |
# File 'lib/brpm_request.rb', line 94 def app_components installed_components unless defined?(@installed_components) @installed_components.map{|l| l["application_component"]["component"]}.uniq end |
#app_environments ⇒ Object
Gets the components associated with request application
Returns
-
hash of components
104 105 106 107 |
# File 'lib/brpm_request.rb', line 104 def app_environments installed_components unless defined?(@installed_components) @installed_components.map{|l| l["application_environment"]["environment"]}.uniq end |
#app_routes ⇒ Object
Gets the routes available for the app
Returns
-
array of hashes of routes
163 164 165 166 |
# File 'lib/brpm_request.rb', line 163 def app_routes res = get("apps", app["id"]) res["data"]["routes"] end |
#get_list(filter_param) ⇒ Object
Gets a list of requests based on a filter
Attributes
-
filter_param
- filter for requests there are extensive filter options ex: filters>2013-04-22
Returns
-
array of request hashs
32 33 34 35 |
# File 'lib/brpm_request.rb', line 32 def get_list(filter_param) response = Rest.rest_call(rest_url("requests", @id, filter_param), "get") @request = response["data"] end |
#groups ⇒ Object
Gets the groups available
Returns
-
array of hashes of groups
201 202 203 |
# File 'lib/brpm_request.rb', line 201 def groups result = get("groups") end |
#installed_components ⇒ Object
Gets the installed_components associated with request application
Returns
-
hash of installed_components
83 84 85 86 87 |
# File 'lib/brpm_request.rb', line 83 def installed_components return @installed_components if defined?(@installed_components) res = get("installed_components", nil, {"filters" => "filters[app_name]=#{url_encode(app["name"])}"}) @installed_components = res["data"] end |
#owner ⇒ Object
Gets the owner of the request
Returns
-
username of request owner
114 115 116 |
# File 'lib/brpm_request.rb', line 114 def owner request["owner"] end |
#plan ⇒ Object
Gets the plan of the request
Returns
-
hash of plan or nil if not part of a plan
132 133 134 135 136 |
# File 'lib/brpm_request.rb', line 132 def plan return nil if request["plan_member"].nil? plan_id = request["plan_member"]["plan"]["id"] res = get("plans", plan_id) end |
#plan_routes ⇒ Object
Gets the routes available for the app/plan
Returns
-
array of hashes of plan routes
153 154 155 156 |
# File 'lib/brpm_request.rb', line 153 def plan_routes return nil if request["plan_member"].nil? plan["plan_routes"] end |
#plan_stages ⇒ Object
Gets the plan stages available for the plan
Returns
-
array of hashes of plan stages
192 193 194 |
# File 'lib/brpm_request.rb', line 192 def plan_stages plan["plan_stages"] end |
#request ⇒ Object
Provides a host status for the passed targets
Returns
-
hash of request
65 66 67 |
# File 'lib/brpm_request.rb', line 65 def request @request end |
#requestor ⇒ Object
Gets the requestor of the request
Returns
-
username of requestor
123 124 125 |
# File 'lib/brpm_request.rb', line 123 def requestor request["requestor"] end |
#route_environments(route_id) ⇒ Object
Gets the environments available for the route
Attributes
-
route_id
- id of the route
Returns
-
array of environments for the route
177 178 179 180 181 182 183 184 185 |
# File 'lib/brpm_request.rb', line 177 def route_environments(route_id) # Returns environment list for a particular route envs = {} res = get("routes", route_id) res["data"]["route_gates"].each_with_index do |gate,idx| envs[gate["environment"]["name"]] = {"id" => gate["environment"]["id"], "position" => idx.to_s } end envs end |
#stage ⇒ Object
Gets the stage of the plan the request is in
Returns
-
hash of stage
143 144 145 146 |
# File 'lib/brpm_request.rb', line 143 def stage return nil if request["plan_member"].nil? request["plan_member"]["stage"] end |
#steps ⇒ Object
Returns the steps for the request
Returns
-
hash of steps from request
42 43 44 |
# File 'lib/brpm_request.rb', line 42 def steps steps = @request["steps"] end |
#update_state(aasm_event) ⇒ Object
Updates the aasm state of the request
Attributes
-
aasm_event
- event name [plan, start, problem, resolve]
Returns
-
hash of uppdated request
55 56 57 58 |
# File 'lib/brpm_request.rb', line 55 def update_state(aasm_event) request_info = {"request" => {"aasm_event" => aasm_event }} result = update("requests", @id, request_info) end |