func (handle *EapiReqHandle) Close() error {
	return Close(handle)
}
Close closes the relationship between this EapiReqHandle and
a Node. Any queued commands are deleted.  User is responsible for
proper handling of the handle after the close.
package goeapi
import (
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"github.com/mitchellh/mapstructure"
)
type Request struct {
	Jsonrpc string     `json:"jsonrpc"`
	Method  string     `json:"method"`
	Params  Parameters `json:"params"`
	ID      string     `json:"id"`
}
type Parameters struct {
	Version int           `json:"version"`
	Cmds    []interface{} `json:"cmds"`
	Format  string        `json:"format"`
}
type RawJSONRPCResponse struct {
	Jsonrpc string                 `json:"jsonrpc"`
	Result  []json.RawMessage      `json:"result"`
	Error   map[string]interface{} `json:"error"`
	ID      string                 `json:"id"`
}
type JSONRPCResponse struct {
	Jsonrpc string                   `json:"jsonrpc"`
	Result  []map[string]interface{} `json:"result"`
	ID      string                   `json:"id"`
	Error   *RespError               `json:"error"`
}
type RespError struct {
	Code    int
	Message string
	Data    interface{}
}
type EapiCommand interface {
	GetCmd() string
}
type commandBlock struct {
	command interface{}
	EapiCommand
}
const (
	maxCmdBuflen = 64
)
type EapiReqHandle struct {
	node         *Node
	encoding     string
	eapiCommands []commandBlock
	err          error
}
func debugJSON(data []byte) {
	var out bytes.Buffer
	err := json.Indent(&out, data, "", "  ")
	if err == nil {
		fmt.Printf("-------------------- JSON ---------------------------\n")
		fmt.Printf("%s\n", out.Bytes())
		fmt.Printf("-----------------------------------------------------\n")
	}
}
func (handle *EapiReqHandle) checkHandle() error {
	if handle == nil {
		return fmt.Errorf("Invalid EapiReqHandle")
	}
	if handle.node == nil {
		return fmt.Errorf("No connection")
	}
	return nil
}
func (handle *EapiReqHandle) getNode() (*Node, error) {
	if err := handle.checkHandle(); err != nil {
		return nil, err
	}
	return handle.node, nil
}
func AddCommandStr(handle *EapiReqHandle, command string, v EapiCommand) error {
	if err := handle.checkHandle(); err != nil {
		return err
	}
	if command == "" {
		handle.err = fmt.Errorf("Invalid null Command string")
		return handle.err
	}
	if len(handle.eapiCommands) == maxCmdBuflen {
		handle.err = fmt.Errorf("Limit of %d commands reached for AddCommand",
			maxCmdBuflen)
		return handle.err
	}
	cmd := commandBlock{command: command, EapiCommand: v}
	handle.eapiCommands = append(handle.eapiCommands, cmd)
	return nil
}
func (handle *EapiReqHandle) AddCommandStr(command string, v EapiCommand) error {
	return AddCommandStr(handle, command, v)
}
func AddCommand(handle *EapiReqHandle, v EapiCommand) error {
	command := v.GetCmd()
	return AddCommandStr(handle, command, v)
}
func (handle *EapiReqHandle) AddCommand(v EapiCommand) error {
	command := v.GetCmd()
	return AddCommandStr(handle, command, v)
}
func (handle *EapiReqHandle) getAllCommands() []interface{} {
	if err := handle.checkHandle(); err != nil {
		return nil
	}
	var tmp []interface{}
	if handle.eapiCommands == nil {
		return nil
	}
	for _, cmd := range handle.eapiCommands {
		tmp = append(tmp, cmd.command)
	}
	return tmp
}
func (handle *EapiReqHandle) getCmdLen() int {
	if handle == nil {
		return 0
	}
	return len(handle.eapiCommands)
}
func (handle *EapiReqHandle) clearCommands() {
	if handle == nil {
		return
	}
	handle.eapiCommands = nil
}
func (handle *EapiReqHandle) Call() error {
	if err := handle.checkHandle(); err != nil {
		return err
	}
	if handle.err != nil {
		return handle.err
	}
	var cmd interface{}
	if handle.node.enablePasswd != "" {
		cmd = map[string]string{
			"cmd":   "enable",
			"input": handle.node.enablePasswd,
		}
	} else {
		cmd = "enable"
	}
	tmpSlice := []commandBlock{{command: cmd,
		EapiCommand: nil}}
	handle.eapiCommands = append(tmpSlice, handle.eapiCommands...)
	commands := handle.getAllCommands()
	jsonrsp, err := handle.node.conn.Execute(commands, handle.encoding)
	if err != nil {
		return err
	}
	err = handle.parseResponse(jsonrsp)
	handle.clearCommands()
	return err
}
func (handle *EapiReqHandle) Enable(v EapiCommand) error {
	if err := handle.AddCommand(v); err != nil {
		return err
	}
	return handle.Call()
}