func (a *action) Query(chaincodeID, fctn string, args [][]byte) ([]byte, error) {
	channelClient, err := a.ChannelClient()
	if err != nil {
		return nil, errors.Errorf(errors.GeneralError, "Error getting channel client: %s", err)
	}
	resp, err := channelClient.Query(
		channel.Request{
			ChaincodeID: chaincodeID,
			Fcn:         fctn,
			Args:        args,
		},
		channel.WithTargets(a.peers...),
		channel.WithRetry(retry.DefaultChannelOpts),
	)
	if err != nil {
		return nil, err
	}
	return resp.Payload, nil
}
Query queries the given chaincode with the given function and args and returns a response
package action
import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"github.com/hyperledger/fabric-sdk-go/pkg/common/errors/retry"
	"github.com/hyperledger/fabric-sdk-go/pkg/client/channel"
	"github.com/hyperledger/fabric-sdk-go/pkg/common/logging"
	"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core"
	fabApi "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
	"github.com/hyperledger/fabric-sdk-go/pkg/core/cryptosuite/bccsp/multisuite"
	"github.com/hyperledger/fabric-sdk-go/pkg/fab/peer"
	"github.com/hyperledger/fabric-sdk-go/pkg/fabsdk"
	"github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/factory/defcore"
	mgmtapi "github.com/securekey/fabric-snaps/configmanager/api"
	"github.com/securekey/fabric-snaps/configurationsnap/cmd/configcli/cliconfig"
	"github.com/securekey/fabric-snaps/configurationsnap/cmd/configcli/configkeyutil"
	"github.com/securekey/fabric-snaps/util/errors"
)
type Action interface {
	Initialize() error
	ChannelClient() (*channel.Client, error)
	Peers() []fabApi.Peer
	OrgID() string
	Query(chaincodeID, fctn string, args [][]byte) ([]byte, error)
	ExecuteTx(chaincodeID, fctn string, args [][]byte) error
	ConfigKey() (*mgmtapi.ConfigKey, error)
}
type action struct {
	peers       []fabApi.Peer
	orgIDByPeer map[string]string
	sdk         *fabsdk.FabricSDK
}
func New() Action {
	return &action{}
}
func (a *action) Initialize() error {
	if err := cliconfig.InitConfig(); err != nil {
		return err
	}
	if err := a.initSDK(); err != nil {
		return err
	}
	logging.SetLevel("", levelFromName(cliconfig.Config().LoggingLevel()))
	channelID := cliconfig.Config().ChannelID()
	if channelID == "" {
		return errors.New(errors.GeneralError, "no channel ID specified")
	}
	return a.initTargetPeers()
}
func (a *action) ChannelClient() (*channel.Client, error) {
	userName := cliconfig.Config().UserName()
	chClient, err := channel.New(a.sdk.ChannelContext(cliconfig.Config().ChannelID(), fabsdk.WithUser(userName), fabsdk.WithOrg(a.OrgID())))
	if err != nil {
		return nil, errors.Wrapf(errors.GeneralError, err, "failed to create new channel client")
	}
	return chClient, nil
}
func (a *action) Peers() []fabApi.Peer {
	return a.peers
}
func (a *action) OrgID() string {
	if len(a.Peers()) == 0 {
		panic("no peers to choose from!")
	}
	peer := a.Peers()[0]
	orgID, ok := a.orgIDByPeer[peer.URL()]
	if !ok {
		panic(fmt.Sprintf("org not found for peer %s", peer.URL()))
	}
	cliconfig.Config().Logger().Debugf("Org of peer [%s]=[%s]", peer.URL(), orgID)
	return orgID
}