Class: AkamaiApi::CLI::CCU::StatusRenderer
- Inherits:
-
Object
- Object
- AkamaiApi::CLI::CCU::StatusRenderer
- Defined in:
- lib/akamai_api/cli/ccu/status_renderer.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response) ⇒ StatusRenderer
constructor
A new instance of StatusRenderer.
- #purge_description ⇒ Object
- #purge_status ⇒ Object
- #queue_status ⇒ Object
- #render ⇒ Object
- #render_error ⇒ Object
- #render_generic_error ⇒ Object
- #render_not_found ⇒ Object
- #successful_completed_purge ⇒ Object
- #successful_pending_purge ⇒ Object
Constructor Details
#initialize(response) ⇒ StatusRenderer
Returns a new instance of StatusRenderer.
8 9 10 |
# File 'lib/akamai_api/cli/ccu/status_renderer.rb', line 8 def initialize(response) @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/akamai_api/cli/ccu/status_renderer.rb', line 6 def response @response end |
Instance Method Details
#purge_description ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/akamai_api/cli/ccu/status_renderer.rb', line 48 def purge_description if response.completed_at "Purge request has been successfully completed:" else "Purge request is currently enqueued:" end end |
#purge_status ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/akamai_api/cli/ccu/status_renderer.rb', line 38 def purge_status output = [ purge_description, "\t* Result: #{response.code} - #{response.status}", "\t* Purge ID: #{response.purge_id} | Support ID: #{response.support_id}", "\t* Submitted by: #{response.submitted_by} on #{response.submitted_at}" ] output.concat response.completed_at ? successful_completed_purge : successful_pending_purge end |
#queue_status ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/akamai_api/cli/ccu/status_renderer.rb', line 29 def queue_status [ "Akamai CCU Queue Status", "\t* Result: #{response.code} - #{response.}", "\t* Support ID: #{response.support_id}", "\t* Queue Length: #{response.queue_length}" ] end |
#render ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/akamai_api/cli/ccu/status_renderer.rb', line 20 def render res = response.is_a?(AkamaiApi::CCU::Status::Response) ? queue_status : purge_status [ '----------', res, '----------' ].join "\n" end |
#render_error ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/akamai_api/cli/ccu/status_renderer.rb', line 12 def render_error if response.is_a? AkamaiApi::CCU::PurgeStatus::NotFound render_not_found else render_generic_error end end |
#render_generic_error ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/akamai_api/cli/ccu/status_renderer.rb', line 67 def render_generic_error [ "----------", "Error #{response.code}: '#{response.}' (#{response.detail})", " Described by: #{response.described_by}", " Support ID: #{response.support_id}", "----------" ].join "\n" end |
#render_not_found ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/akamai_api/cli/ccu/status_renderer.rb', line 56 def render_not_found [ "----------", "No purge request found using #{response.progress_uri}:", "\t* Result: #{response.code} - #{response.}", "\t* Support ID: #{response.support_id}", "\t* Time to wait before next check: #{response.time_to_wait} secs.", "----------" ].join "\n" end |
#successful_completed_purge ⇒ Object
77 78 79 |
# File 'lib/akamai_api/cli/ccu/status_renderer.rb', line 77 def successful_completed_purge ["\t* Completed on: #{response.completed_at}"] end |
#successful_pending_purge ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/akamai_api/cli/ccu/status_renderer.rb', line 81 def successful_pending_purge [ "\t* Estimated time was: #{response.original_estimated_time} secs.", "\t* Queue length was: #{response.original_queue_length}", "\t* Time to wait before next check: #{response.time_to_wait} secs.", ] end |