Class: NetconfResponse
- Inherits:
-
Object
- Object
- NetconfResponse
- Defined in:
- lib/utils/netconf_response.rb
Overview
Class defining response to most requests made in rubybvc.
Instance Attribute Summary collapse
-
#body ⇒ Object
<variable>: the response from the request or more information about failure.
-
#status ⇒ Object
integer: success or failure status of request.
Instance Method Summary collapse
-
#initialize(netconf_response_status = nil, json_body = nil) ⇒ NetconfResponse
constructor
:nodoc:.
-
#message ⇒ Object
Return a string for the status.
Constructor Details
#initialize(netconf_response_status = nil, json_body = nil) ⇒ NetconfResponse
:nodoc:
40 41 42 43 |
# File 'lib/utils/netconf_response.rb', line 40 def initialize(netconf_response_status = nil, json_body = nil) #:nodoc: @status = netconf_response_status @body = json_body end |
Instance Attribute Details
#body ⇒ Object
<variable>: the response from the request or more information about failure
38 39 40 |
# File 'lib/utils/netconf_response.rb', line 38 def body @body end |
#status ⇒ Object
integer: success or failure status of request
36 37 38 |
# File 'lib/utils/netconf_response.rb', line 36 def status @status end |
Instance Method Details
#message ⇒ Object
Return a string for the status.
Return Value
-
string : A string describing the status of the response (success or reason for failure).
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/utils/netconf_response.rb', line 50 def case(@status) when NetconfResponseStatus::OK "Success" when NetconfResponseStatus::NODE_CONNECTED "Node is connected" when NetconfResponseStatus::NODE_DISCONNECTED "Node is disconnected" when NetconfResponseStatus::NODE_NOT_FOUND "Node not found" when NetconfResponseStatus::NODE_CONFIGURED "Node is configured" when NetconfResponseStatus::CONN_ERROR "Server connection error" when NetconfResponseStatus::CTRL_INTERNAL_ERROR "Internal server error" when NetconfResponseStatus::HTTP_ERROR msg = "HTTP error" msg += " #{@body.code}" if @body && @body.code msg += " - #{@body.}" if @body && @body. msg when NetconfResponseStatus::DATA_NOT_FOUND "Requested data not found" end end |