func batchExport(entities []string, entityType string, pwg *sync.WaitGroup, mu *sync.Mutex) {
	defer pwg.Done()
	var bwg sync.WaitGroup
	bwg.Add(len(entities))
	for _, entity := range entities {
		u, _ := url.Parse(apiclient.BaseURL)
		u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "environments", apiclient.GetApigeeEnv(), entityType, entity)
		go apiclient.GetAsyncEntity(u.String(), &bwg, mu)
	}
	bwg.Wait()
}
batch created a batch of targetservers to query
package targetservers
import (
	"encoding/json"
	"io/ioutil"
	"net/url"
	"os"
	"path"
	"sync"
	"github.com/srinandan/apigeecli/apiclient"
	"github.com/srinandan/apigeecli/clilog"
)
type targetserver struct {
	Name        string  `json:"name,omitempty"`
	Description string  `json:"description,omitempty"`
	Host        string  `json:"host,omitempty"`
	Port        int     `json:"port,omitempty"`
	IsEnabled   bool    `json:"isEnabled,omitempty"`
	Protocol    string  `json:"protocol,omitempty"`
	SslInfo     sslInfo `json:"sSLInfo,omitempty"`
}
type sslInfo struct {
	Enabled                bool       `json:"enabled,omitempty"`
	ClientAuthEnabled      bool       `json:"clientAuthEnabled,omitempty"`
	Keystore               string     `json:"keyStore,omitempty"`
	Keyalias               string     `json:"keyAlias,omitempty"`
	Truststore             string     `json:"trustStore,omitempty"`
	IgnoreValidationErrors bool       `json:"ignoreValidationErrors,omitempty"`
	Protocols              []string   `json:"protocols,omitempty"`
	Ciphers                []string   `json:"ciphers,omitempty"`
	CommonName             commonName `json:"commonName,omitempty"`
}
type commonName struct {
	Value         string `json:"value,omitempty"`
	WildcardMatch bool   `json:"wildcardMatch,omitempty"`
}
func Create(name string, description string, host string, port int, enable bool, grpc bool, keyStore string, keyAlias string, tlsenabled bool, clientAuthEnabled bool, ignoreValidationErrors bool) (respBody []byte, err error) {
	targetsvr := targetserver{}
	targetsvr.Name = name
	return createOrUpdate("create", targetsvr, name, description, host, port, enable, grpc, keyStore, keyAlias, tlsenabled, clientAuthEnabled, ignoreValidationErrors)
}
func Update(name string, description string, host string, port int, enable bool, grpc bool, keyStore string, keyAlias string, tlsenabled bool, clientAuthEnabled bool, ignoreValidationErrors bool) (respBody []byte, err error) {
	var targetRespBody []byte
	var targetsvr = targetserver{}
	apiclient.SetPrintOutput(false)
	if targetRespBody, err = Get(name); err != nil {
		return nil, err
	}
	apiclient.SetPrintOutput(true)
	if err = json.Unmarshal(targetRespBody, &targetsvr); err != nil {
		return nil, err
	}
	return createOrUpdate("update", targetsvr, name, description, host, port, enable, grpc, keyStore, keyAlias, tlsenabled, clientAuthEnabled, ignoreValidationErrors)
}
func createOrUpdate(action string, targetsvr targetserver, name string, description string, host string, port int, enable bool, grpc bool, keyStore string, keyAlias string, tlsenabled bool, clientAuthEnabled bool, ignoreValidationErrors bool) (respBody []byte, err error) {
	var reqBody []byte
	if description != "" {
		targetsvr.Description = description
	}
	if host != "" {
		targetsvr.Host = host
	}
	if port != -1 {
		targetsvr.Port = port
	}
	if grpc {
		targetsvr.Protocol = "GRPC"
	}
	if enable {
		targetsvr.IsEnabled = enable
	}
	if tlsenabled {
		targetsvr.SslInfo.Enabled = tlsenabled
	}
	if clientAuthEnabled {
		targetsvr.SslInfo.ClientAuthEnabled = clientAuthEnabled
	}
	if ignoreValidationErrors {
		targetsvr.SslInfo.IgnoreValidationErrors = ignoreValidationErrors
	}
	if keyAlias != "" {
		targetsvr.SslInfo.Keyalias = keyAlias
	}
	if keyStore != "" {
		targetsvr.SslInfo.Keystore = keyStore
	}
	if reqBody, err = json.Marshal(targetsvr); err != nil {
		return nil, err
	}
	u, _ := url.Parse(apiclient.BaseURL)
	if action == "create" {
		u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "environments", apiclient.GetApigeeEnv(), "targetservers")
		respBody, err = apiclient.HttpClient(apiclient.GetPrintOutput(), u.String(), string(reqBody))
	} else {
		u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "environments", apiclient.GetApigeeEnv(), "targetservers", name)
		respBody, err = apiclient.HttpClient(apiclient.GetPrintOutput(), u.String(), string(reqBody), "PUT")
	}
	return respBody, err
}
func Get(name string) (respBody []byte, err error) {
	u, _ := url.Parse(apiclient.BaseURL)
	u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "environments", apiclient.GetApigeeEnv(), "targetservers", name)
	respBody, err = apiclient.HttpClient(apiclient.GetPrintOutput(), u.String())
	return respBody, err
}
func Delete(name string) (respBody []byte, err error) {
	u, _ := url.Parse(apiclient.BaseURL)
	u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "environments", apiclient.GetApigeeEnv(), "targetservers", name)
	respBody, err = apiclient.HttpClient(apiclient.GetPrintOutput(), u.String(), "", "DELETE")
	return respBody, err
}
func List() (respBody []byte, err error) {
	u, _ := url.Parse(apiclient.BaseURL)
	u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "environments", apiclient.GetApigeeEnv(), "targetservers")
	respBody, err = apiclient.HttpClient(apiclient.GetPrintOutput(), u.String())
	return respBody, err
}
func Export(conn int) (payload [][]byte, err error) {
	var pwg sync.WaitGroup
	var mu sync.Mutex
	const entityType = "targetservers"
	u, _ := url.Parse(apiclient.BaseURL)
	u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "environments", apiclient.GetApigeeEnv(), entityType)
	respBody, err := apiclient.HttpClient(false, u.String())
	if err != nil {
		return apiclient.GetEntityPayloadList(), err
	}
	var targetservers []string
	err = json.Unmarshal(respBody, &targetservers)
	if err != nil {
		return apiclient.GetEntityPayloadList(), err
	}
	numEntities := len(targetservers)
	clilog.Info.Printf("Found %d targetservers in the org\n", numEntities)
	clilog.Info.Printf("Exporting targetservers with %d connections\n", conn)
	numOfLoops, remaining := numEntities/conn, numEntities%conn
	if conn > numEntities {
		conn = numEntities
	}
	start := 0
	for i, end := 0, 0; i < numOfLoops; i++ {
		pwg.Add(1)
		end = (i * conn) + conn
		clilog.Info.Printf("Exporting batch %d of targetservers\n", (i + 1))
		go batchExport(targetservers[start:end], entityType, &pwg, &mu)
		start = end
		pwg.Wait()
	}
	if remaining > 0 {
		pwg.Add(1)
		clilog.Info.Printf("Exporting remaining %d targetservers\n", remaining)
		go batchExport(targetservers[start:numEntities], entityType, &pwg, &mu)
		pwg.Wait()
	}
	payload = make([][]byte, len(apiclient.GetEntityPayloadList()))
	copy(payload, apiclient.GetEntityPayloadList())
	apiclient.ClearEntityPayloadList()
	return payload, nil
}