Class: CloudFormation::Bridge::Request
- Inherits:
-
Object
- Object
- CloudFormation::Bridge::Request
- Includes:
- Names
- Defined in:
- lib/cloud_formation/bridge/request.rb
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #build_response(response = {}) ⇒ Object
- #create? ⇒ Boolean
- #delete? ⇒ Boolean
- #fail!(message) ⇒ Object
- #generate_physical_id ⇒ Object
-
#initialize(request) ⇒ Request
constructor
A new instance of Request.
- #logical_resource_id ⇒ Object
- #old_resource_properties ⇒ Object
- #physical_resource_id ⇒ Object
- #request_id ⇒ Object
- #request_type ⇒ Object
- #request_url ⇒ Object
- #resource_properties ⇒ Object
- #resource_type ⇒ Object
- #stack_id ⇒ Object
- #succeed!(response) ⇒ Object
- #update? ⇒ Boolean
Constructor Details
#initialize(request) ⇒ Request
Returns a new instance of Request.
13 14 15 |
# File 'lib/cloud_formation/bridge/request.rb', line 13 def initialize(request) @request = request end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
11 12 13 |
# File 'lib/cloud_formation/bridge/request.rb', line 11 def request @request end |
Instance Method Details
#build_response(response = {}) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/cloud_formation/bridge/request.rb', line 78 def build_response(response = {}) { FIELDS::STATUS => RESULTS::SUCCESS, FIELDS::PHYSICAL_RESOURCE_ID => response[FIELDS::PHYSICAL_RESOURCE_ID] || physical_resource_id || generate_physical_id, FIELDS::STACK_ID => stack_id, FIELDS::REQUEST_ID => request_id, FIELDS::LOGICAL_RESOURCE_ID => logical_resource_id, }.merge(response) end |
#create? ⇒ Boolean
21 22 23 |
# File 'lib/cloud_formation/bridge/request.rb', line 21 def create? request_type == TYPES::CREATE end |
#delete? ⇒ Boolean
25 26 27 |
# File 'lib/cloud_formation/bridge/request.rb', line 25 def delete? request_type == TYPES::DELETE end |
#fail!(message) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/cloud_formation/bridge/request.rb', line 65 def fail!() response = build_response( FIELDS::REASON => , FIELDS::STATUS => RESULTS::FAILED ) HttpBridge.put(request_url, response) end |
#generate_physical_id ⇒ Object
88 89 90 |
# File 'lib/cloud_formation/bridge/request.rb', line 88 def generate_physical_id "#{logical_resource_id}-#{SecureRandom.uuid}" end |
#logical_resource_id ⇒ Object
49 50 51 |
# File 'lib/cloud_formation/bridge/request.rb', line 49 def logical_resource_id request[FIELDS::LOGICAL_RESOURCE_ID] end |
#old_resource_properties ⇒ Object
61 62 63 |
# File 'lib/cloud_formation/bridge/request.rb', line 61 def old_resource_properties request[FIELDS::OLD_RESOURCE_PROPERTIES] end |
#physical_resource_id ⇒ Object
53 54 55 |
# File 'lib/cloud_formation/bridge/request.rb', line 53 def physical_resource_id request[FIELDS::PHYSICAL_RESOURCE_ID] end |
#request_id ⇒ Object
41 42 43 |
# File 'lib/cloud_formation/bridge/request.rb', line 41 def request_id request[FIELDS::REQUEST_ID] end |
#request_type ⇒ Object
29 30 31 |
# File 'lib/cloud_formation/bridge/request.rb', line 29 def request_type request[FIELDS::REQUEST_TYPE] end |
#request_url ⇒ Object
33 34 35 |
# File 'lib/cloud_formation/bridge/request.rb', line 33 def request_url request[FIELDS::RESPONSE_URL] end |
#resource_properties ⇒ Object
57 58 59 |
# File 'lib/cloud_formation/bridge/request.rb', line 57 def resource_properties request[FIELDS::RESOURCE_PROPERTIES] end |
#resource_type ⇒ Object
45 46 47 |
# File 'lib/cloud_formation/bridge/request.rb', line 45 def resource_type request[FIELDS::RESOURCE_TYPE] end |
#stack_id ⇒ Object
37 38 39 |
# File 'lib/cloud_formation/bridge/request.rb', line 37 def stack_id request[FIELDS::STACK_ID] end |
#succeed!(response) ⇒ Object
74 75 76 |
# File 'lib/cloud_formation/bridge/request.rb', line 74 def succeed!(response) HttpBridge.put(request_url, build_response(response || {})) end |
#update? ⇒ Boolean
17 18 19 |
# File 'lib/cloud_formation/bridge/request.rb', line 17 def update? request_type == TYPES::UPDATE end |