func CheramiDestinationType(internalDestinationType shared.DestinationType) (cheramiDestinationType cherami.DestinationType, err error) {
	return cherami.DestinationTypeFromString(internalDestinationType.String())
}
CheramiDestinationType converts from shared.DestinationType to cherami.DestinationType
package common
import (
	"fmt"
	"net/http"
	"strconv"
	"github.com/uber/cherami-thrift/.generated/go/cherami"
	"github.com/uber/cherami-thrift/.generated/go/shared"
	"github.com/uber/cherami-thrift/.generated/go/store"
)
const (
	keyDestinationUUID   = "DestinationUUID"
	keyDestinationType   = "DestinationType"
	keyExtentUUID        = "ExtentUUID"
	keyConsumerGroupUUID = "ConsumerGroupUUID"
	keyAddress           = "Address"
	keyInclusive         = "Inclusive"
)
func newBadRequestError(msg string) error {
	err := cherami.NewBadRequestError()
	err.Message = msg
	return err
}
func GetOpenAppendStreamRequestHeaders(req *store.OpenAppendStreamRequest) (headers map[string]string) {
	headers = make(map[string]string)
	headers[keyDestinationUUID] = req.GetDestinationUUID()
	headers[keyDestinationType] = req.GetDestinationType().String()
	headers[keyExtentUUID] = req.GetExtentUUID()
	return
}
func GetOpenAppendStreamRequestStruct(headers map[string]string) (req *store.OpenAppendStreamRequest, err error) {
	req = &store.OpenAppendStreamRequest{}
	req = store.NewOpenAppendStreamRequest()
	var ok bool
	destinationUUIDString, ok := headers[keyDestinationUUID]
	if !ok {
		return nil, newBadRequestError("DestinationUUID not specified")
	}
	req.DestinationUUID = StringPtr(destinationUUIDString)
	destinationTypeString, ok := headers[keyDestinationType]
	if !ok {
		return nil, newBadRequestError("DestinationType not specified")
	}
	destinationType, err := cherami.DestinationTypeFromString(destinationTypeString)
	if err != nil {
		return nil, newBadRequestError(fmt.Sprintf("error parsing DestinationType (%s)", destinationTypeString))
	}
	req.DestinationType = cherami.DestinationTypePtr(destinationType)
	extentUUIDString, ok := headers[keyExtentUUID]
	if !ok {
		return nil, newBadRequestError("ExtentUUID not specified")
	}
	req.ExtentUUID = StringPtr(extentUUIDString)
	return req, nil
}
func GetOpenAppendStreamRequestHTTP(httpHeader http.Header) (req *store.OpenAppendStreamRequest, err error) {
	req = store.NewOpenAppendStreamRequest()
	destinationUUIDString := httpHeader.Get(keyDestinationUUID)
	if len(destinationUUIDString) == 0 {
		return nil, newBadRequestError("DestinationUUID not specified")
	}
	req.DestinationUUID = StringPtr(destinationUUIDString)
	destinationTypeString := httpHeader.Get(keyDestinationType)
	if len(destinationTypeString) == 0 {
		return nil, newBadRequestError("DestinationType not specified")
	}
	destinationType, err := cherami.DestinationTypeFromString(destinationTypeString)
	if err != nil {
		return nil, newBadRequestError(fmt.Sprintf("error parsing DestinationType (%s)", destinationTypeString))
	}
	req.DestinationType = cherami.DestinationTypePtr(destinationType)
	extentUUIDString := httpHeader.Get(keyExtentUUID)
	if len(extentUUIDString) == 0 {
		return nil, newBadRequestError("ExtentUUID not specified")
	}
	req.ExtentUUID = StringPtr(extentUUIDString)
	return req, nil
}
func GetOpenReadStreamRequestHeaders(req *store.OpenReadStreamRequest) (headers map[string]string) {
	headers = make(map[string]string)
	headers[keyDestinationUUID] = req.GetDestinationUUID()
	headers[keyDestinationType] = req.GetDestinationType().String()
	headers[keyExtentUUID] = req.GetExtentUUID()
	headers[keyConsumerGroupUUID] = req.GetConsumerGroupUUID()
	headers[keyAddress] = fmt.Sprintf("%v", req.GetAddress())
	headers[keyInclusive] = fmt.Sprintf("%v", req.GetInclusive())
	return
}
func GetOpenReplicationReadStreamRequestHTTPHeaders(req *OpenReplicationReadStreamRequest) http.Header {
	headers := GetOpenReadStreamRequestHeaders(&req.OpenReadStreamRequest)
	httpHeaders := http.Header{}
	for k, v := range headers {
		httpHeaders.Add(k, v)
	}
	return httpHeaders
}
func GetOpenReplicationRemoteReadStreamRequestHTTPHeaders(req *OpenReplicationRemoteReadStreamRequest) http.Header {
	headers := GetOpenReadStreamRequestHeaders(&req.OpenReadStreamRequest)
	httpHeaders := http.Header{}
	for k, v := range headers {
		httpHeaders.Add(k, v)
	}
	return httpHeaders
}
func GetOpenReadStreamRequestHTTPHeaders(req *store.OpenReadStreamRequest) http.Header {
	headers := GetOpenReadStreamRequestHeaders(req)
	httpHeaders := http.Header{}
	for k, v := range headers {
		httpHeaders.Add(k, v)
	}
	return httpHeaders
}
func GetOpenReadStreamRequestStruct(headers map[string]string) (req *store.OpenReadStreamRequest, err error) {
	req = &store.OpenReadStreamRequest{}
	var ok bool
	destinationUUIDString, ok := headers[keyDestinationUUID]
	if !ok {
		return nil, newBadRequestError("DestinationUUID not specified")
	}
	req.DestinationUUID = StringPtr(destinationUUIDString)
	destinationTypeString, ok := headers[keyDestinationType]
	if !ok {
		return nil, newBadRequestError("DestinationType not specified")
	}
	destinationType, err := cherami.DestinationTypeFromString(destinationTypeString)
	if err != nil {
		return nil, newBadRequestError(fmt.Sprintf("error parsing DestinationType (%s): %v", destinationTypeString, err))
	}
	req.DestinationType = cherami.DestinationTypePtr(destinationType)
	extentUUIDString, ok := headers[keyExtentUUID]
	if !ok {
		return nil, newBadRequestError("ExtentUUID not specified")
	}
	req.ExtentUUID = StringPtr(extentUUIDString)
	consumerGroupUUIDString, ok := headers[keyConsumerGroupUUID]
	if !ok {
		return nil, newBadRequestError("ConsumerGroupUUID not specified")
	}
	req.ConsumerGroupUUID = StringPtr(consumerGroupUUIDString)
	addressString, ok := headers[keyAddress]
	if !ok {
		return nil, newBadRequestError("Address not specified")
	}
	address, err := strconv.ParseInt(addressString, 10, 64)
	if err != nil {
		return nil, newBadRequestError(fmt.Sprintf("error parsing Address (%s): %v", addressString, err))
	}
	req.Address = Int64Ptr(address)
	inclusiveString, ok := headers[keyInclusive]
	if !ok {
		return nil, newBadRequestError("Inclusive not specified")
	}
	inclusive, err := strconv.ParseBool(inclusiveString)
	if err != nil {
		return nil, newBadRequestError(fmt.Sprintf("error parsing Inclusive (%s): %v", inclusiveString, err))
	}
	req.Inclusive = BoolPtr(inclusive)
	return req, nil
}
func GetOpenReadStreamRequestHTTP(httpHeader http.Header) (req *store.OpenReadStreamRequest, err error) {
	req = store.NewOpenReadStreamRequest()
	destinationUUIDString := httpHeader.Get(keyDestinationUUID)
	if len(destinationUUIDString) == 0 {
		return nil, newBadRequestError("DestinationUUID not specified")
	}
	req.DestinationUUID = StringPtr(destinationUUIDString)
	destinationTypeString := httpHeader.Get(keyDestinationType)
	if len(destinationTypeString) == 0 {
		return nil, newBadRequestError("DestinationType not specified")
	}
	destinationType, err := cherami.DestinationTypeFromString(destinationTypeString)
	if err != nil {
		return nil, newBadRequestError(fmt.Sprintf("error parsing DestinationType (%s): %v", destinationTypeString, err))
	}
	req.DestinationType = cherami.DestinationTypePtr(destinationType)
	extentUUIDString := httpHeader.Get(keyExtentUUID)
	if len(extentUUIDString) == 0 {
		return nil, newBadRequestError("ExtentUUID not specified")
	}
	req.ExtentUUID = StringPtr(extentUUIDString)
	consumerGroupUUIDString := httpHeader.Get(keyConsumerGroupUUID)
	if len(consumerGroupUUIDString) == 0 {
		return nil, newBadRequestError("ConsumerGroupUUID not specified")
	}
	req.ConsumerGroupUUID = StringPtr(consumerGroupUUIDString)
	addressString := httpHeader.Get(keyAddress)
	if len(addressString) == 0 {
		return nil, newBadRequestError("Address not specified")
	}
	address, err := strconv.ParseInt(addressString, 10, 64)
	if err != nil {
		return nil, newBadRequestError(fmt.Sprintf("error parsing Address (%s): %v", addressString, err))
	}
	req.Address = Int64Ptr(address)
	inclusiveString := httpHeader.Get(keyInclusive)
	if len(inclusiveString) == 0 {
		return nil, newBadRequestError("Inclusive not specified")
	}
	inclusive, err := strconv.ParseBool(inclusiveString)
	if err != nil {
		return nil, newBadRequestError(fmt.Sprintf("error parsing Inclusive (%s): %v", inclusiveString, err))
	}
	req.Inclusive = BoolPtr(inclusive)
	return req, nil
}
func GetOpenReplicationRemoteReadStreamRequestHTTP(httpHeader http.Header) (req *OpenReplicationRemoteReadStreamRequest, err error) {
	openReadStreamRequest, err := GetOpenReadStreamRequestHTTP(httpHeader)
	if err != nil {
		return
	}
	req = &OpenReplicationRemoteReadStreamRequest{*openReadStreamRequest}
	return
}
func GetOpenReplicationReadStreamRequestHTTP(httpHeader http.Header) (req *OpenReplicationReadStreamRequest, err error) {
	openReadStreamRequest, err := GetOpenReadStreamRequestHTTP(httpHeader)
	if err != nil {
		return
	}
	req = &OpenReplicationReadStreamRequest{*openReadStreamRequest}
	return
}