def send(self, data):
        """Sends the eAPI request to the destination node

        This method is responsible for sending an eAPI request to the
        destination node and returning a response based on the eAPI response
        object.  eAPI responds to request messages with either a success
        message or failure message.

        eAPI Response - success

        .. code-block:: json

            {
                "jsonrpc": "2.0",
                "result": [
                    {},
                    {}
                    {
                        "warnings": [
                            <message>
                        ]
                    },
                ],
                "id": <reqid>
            }

        eAPI Response - failure

        .. code-block:: json

            {
                "jsonrpc": "2.0",
                "error": {
                    "code": <int>,
                    "message": <string>
                    "data": [
                        {},
                        {},
                        {
                            "errors": [
                                <message>
                            ]
                        }
                    ]
                }
                "id": <reqid>
            }

        Args:
            data (string): The data to be included in the body of the eAPI
                request object

        Returns:
            A decoded response.  The response object is deserialized from
                JSON and returned as a standard Python dictionary object

        Raises:
            CommandError if an eAPI failure response object is returned from
                the node.   The CommandError exception includes the error
                code and error message from the eAPI response.
        """
        try:
            _LOGGER.debug("Request content: {}".format(data))
            # debug('eapi_request: %s' % data)

            self.transport.putrequest('POST', '/command-api')

            self.transport.putheader('Content-type', 'application/json-rpc')
            self.transport.putheader('Content-length', '%d' % len(data))

            if self._auth:
                self.transport.putheader('Authorization',
                                         'Basic %s' % (self._auth))

            if int(sys.version[0]) > 2:
                # For Python 3.x compatibility
                data = data.encode()

            self.transport.endheaders(message_body=data)

            try:  # Python 2.7: use buffering of HTTP responses
                response = self.transport.getresponse(buffering=True)
            except TypeError:  # Python 2.6: older, and 3.x on
                response = self.transport.getresponse()

            response_content = response.read()
            _LOGGER.debug("Response: status:{status}, reason:{reason}".format(
                          status=response.status,
                          reason=response.reason))
            _LOGGER.debug("Response content: {}".format(response_content))

            # Work around for Python 2.7/3.x compatibility
            if not type(response_content) == str:
                # For Python 3.x - decode bytes into string
                response_content = response_content.decode()
            decoded = json.loads(response_content)
            _LOGGER.debug('eapi_response: %s' % decoded)

            if 'error' in decoded:
                (code, msg, err, out) = self._parse_error_message(decoded)
                raise CommandError(code, msg, command_error=err, output=out)

            return decoded

        except (socket.error, ValueError) as exc:
            if isinstance(exc, socket.error):
                self.socket_error = exc
            _LOGGER.exception(exc)
            self.error = exc
            raise ConnectionError(str(self), 'unable to connect to eAPI')

        finally:
            self.transport.close()
dataset/ETHPy150Open arista-eosplus/pyeapi/pyeapi/eapilib.py/EapiConnection.send/original