Class: NetconfResponse
- Inherits:
-
Object
- Object
- NetconfResponse
- Defined in:
- lib/utils/netconf_response.rb
Overview
Copyright © 2015, BROCADE COMMUNICATIONS SYSTEMS, INC
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(netconf_response_status = nil, json_body = nil) ⇒ NetconfResponse
constructor
A new instance of NetconfResponse.
- #message ⇒ Object
Constructor Details
#initialize(netconf_response_status = nil, json_body = nil) ⇒ NetconfResponse
Returns a new instance of NetconfResponse.
37 38 39 40 |
# File 'lib/utils/netconf_response.rb', line 37 def initialize(netconf_response_status = nil, json_body = nil) @status = netconf_response_status @body = json_body end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
35 36 37 |
# File 'lib/utils/netconf_response.rb', line 35 def body @body end |
#status ⇒ Object
Returns the value of attribute status.
34 35 36 |
# File 'lib/utils/netconf_response.rb', line 34 def status @status end |
Instance Method Details
#message ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/utils/netconf_response.rb', line 42 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.message}" if @body && @body. msg when NetconfResponseStatus::DATA_NOT_FOUND "Requested data not found" end end |