Class: CloudFormation::Bridge::Request
- Inherits:
-
Object
- Object
- CloudFormation::Bridge::Request
- Includes:
- Names
- Defined in:
- lib/cloud_formation/bridge/request.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#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, logger = Util::LOGGER) ⇒ 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
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
12 13 14 |
# File 'lib/cloud_formation/bridge/request.rb', line 12 def logger @logger end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
12 13 14 |
# File 'lib/cloud_formation/bridge/request.rb', line 12 def request @request end |
Instance Method Details
#build_response(response = {}) ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/cloud_formation/bridge/request.rb', line 87 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
23 24 25 |
# File 'lib/cloud_formation/bridge/request.rb', line 23 def create? request_type == TYPES::CREATE end |
#delete? ⇒ Boolean
27 28 29 |
# File 'lib/cloud_formation/bridge/request.rb', line 27 def delete? request_type == TYPES::DELETE end |
#fail!(message) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/cloud_formation/bridge/request.rb', line 67 def fail!() response = build_response( FIELDS::REASON => , FIELDS::STATUS => RESULTS::FAILED, ) HttpBridge.put(request_url, response) end |
#generate_physical_id ⇒ Object
97 98 99 |
# File 'lib/cloud_formation/bridge/request.rb', line 97 def generate_physical_id "#{logical_resource_id}-#{SecureRandom.uuid}" end |
#logical_resource_id ⇒ Object
51 52 53 |
# File 'lib/cloud_formation/bridge/request.rb', line 51 def logical_resource_id request[FIELDS::LOGICAL_RESOURCE_ID] end |
#old_resource_properties ⇒ Object
63 64 65 |
# File 'lib/cloud_formation/bridge/request.rb', line 63 def old_resource_properties request[FIELDS::OLD_RESOURCE_PROPERTIES] end |
#physical_resource_id ⇒ Object
55 56 57 |
# File 'lib/cloud_formation/bridge/request.rb', line 55 def physical_resource_id request[FIELDS::PHYSICAL_RESOURCE_ID] end |
#request_id ⇒ Object
43 44 45 |
# File 'lib/cloud_formation/bridge/request.rb', line 43 def request_id request[FIELDS::REQUEST_ID] end |
#request_type ⇒ Object
31 32 33 |
# File 'lib/cloud_formation/bridge/request.rb', line 31 def request_type request[FIELDS::REQUEST_TYPE] end |
#request_url ⇒ Object
35 36 37 |
# File 'lib/cloud_formation/bridge/request.rb', line 35 def request_url request[FIELDS::RESPONSE_URL] end |
#resource_properties ⇒ Object
59 60 61 |
# File 'lib/cloud_formation/bridge/request.rb', line 59 def resource_properties request[FIELDS::RESOURCE_PROPERTIES] end |
#resource_type ⇒ Object
47 48 49 |
# File 'lib/cloud_formation/bridge/request.rb', line 47 def resource_type request[FIELDS::RESOURCE_TYPE] end |
#stack_id ⇒ Object
39 40 41 |
# File 'lib/cloud_formation/bridge/request.rb', line 39 def stack_id request[FIELDS::STACK_ID] end |
#succeed!(response = {}) ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/cloud_formation/bridge/request.rb', line 76 def succeed!(response = {}) actual_response = case response when Hash build_response(response) else build_response end HttpBridge.put(request_url, actual_response) end |