// GetEncodedResponse invokes the Audits method. Returns the response body and
// size if it were re-encoded with the specified settings. Only applies to
// images.
776006
func (d *domainClient) GetEncodedResponse(ctx context.Context, args *GetEncodedResponseArgs) (reply *GetEncodedResponseReply, err error) {
	reply = new(GetEncodedResponseReply)
	if args != nil {
		err = rpcc.Invoke(ctx, "Audits.getEncodedResponse", args, reply, d.conn)
	} else {
		err = rpcc.Invoke(ctx, "Audits.getEncodedResponse", nil, reply, d.conn)
	}
	if err != nil {
		err = &internal.OpError{Domain: "Audits", Op: "GetEncodedResponse", Err: err}
	}
	return
}
191864
func (p *Pushover) GetReceiptDetails(receipt string) (*ReceiptDetails, error) {
	url := fmt.Sprintf("%s/receipts/%s.json?token=%s", APIEndpoint, receipt, p.token)

	if receipt == "" {
		return nil, ErrEmptyReceipt
	}

	// Send request
	resp, err := http.Get(url)
	if err != nil {
		return nil, err
	}

	// Decode the JSON response
	var details *ReceiptDetails
	if err = json.NewDecoder(resp.Body).Decode(&details); err != nil {
		return nil, err
	}

	return details, nil
}
1254988
func EncodeClientRequest(method string, args interface{}) ([]byte, error) {
	c := &clientRequest{
		Version: "2.0",
		Method:  method,
		Params:  args,
		Id:      uint64(rand.Int63()),
	}
	return json.Marshal(c)
}
868949
func (cb *CommonBlock) GetEncodedSize() uint32 {
	cb.cacheMtx.RLock()
	defer cb.cacheMtx.RUnlock()
	return cb.cachedEncodedSize
}
1143407
func DecodeSEOQueryParams(r *http.Request, v interface{}) (err error) {

	if rvi := r.Context().Value(defaultContextIdentifier); rvi != nil {

		rv := rvi.(*requestVars)

		values := make(url.Values, len(rv.params))

		for _, p := range rv.params {
			values.Add(p.key, p.value)
		}

		err = DefaultDecoder.Decode(v, values)
	}

	return
}
233914
func RequestBodyEncodeError(req *transport.Request, err error) error {
	return newClientEncodingError(req, false /*isResponse*/, false /*isHeader*/, err)
}
277967
func (c *UserConfig) GetAccessToken(token string, verifier string, service *Service, client *http.Client) error {
	// This code used to error out if RequestTokenKey were empty, but
	// in the interest of being able to operate in a stateless manner this
	// has been removed.  If you want to make sure that the request token
	// is validated against what is being returned, populate the UserConfig
	// with a request token stored server-side somewhere, accessed by the
	// user's session.
	if c.RequestTokenKey != "" && c.RequestTokenKey != token {
		return fmt.Errorf("Returned token did not match request token")
	}
	c.Verifier = verifier
	data := url.Values{}
	if service.ClientConfig.CallbackURL != "" {
		data.Set("oauth_verifier", verifier)
	}
	body := strings.NewReader(data.Encode())
	request, err := http.NewRequest("POST", service.AccessURL, body)
	if err != nil {
		return err
	}
	request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	response, err := c.send(request, service, client)
	if err != nil {
		return err
	}
	err = c.parseAccessToken(response)
	return err
}
1014303
func encodeResponseJSON(response interface{}) []byte {
	var bytesBuffer bytes.Buffer
	e := json.NewEncoder(&bytesBuffer)
	e.Encode(response)
	return bytesBuffer.Bytes()
}
274239
func DefaultRequestEncoder(_ context.Context, req interface{}) (json.RawMessage, error) {
	return json.Marshal(req)
}
834386
func (inst *openstackInstance) getAddresses(ctx context.ProviderCallContext) (map[string][]nova.IPAddress, error) {
	addrs := inst.getServerDetail().Addresses
	if len(addrs) == 0 {
		server, err := inst.e.nova().GetServer(string(inst.Id()))
		if err != nil {
			common.HandleCredentialError(IsAuthorisationFailure, err, ctx)
			return nil, err
		}
		addrs = server.Addresses
	}
	return addrs, nil
}
464576
func (r Account_ProofOfConcept) GetReviewerEmailFromAccessToken(accessToken *string) (resp string, err error) {
	params := []interface{}{
		accessToken,
	}
	err = r.Session.DoRequest("SoftLayer_Account_ProofOfConcept", "getReviewerEmailFromAccessToken", params, &r.Options, &resp)
	return
}
1286381
func GetBearerTokenFromReq(ctx types.Context, req *http.Request) string {
	m := rxBearer.FindStringSubmatch(
		req.Header.Get(types.AuthorizationHeader))
	if len(m) == 0 {
		return ""
	}
	return m[1]
}
220308
func EncodeResponse(w http.ResponseWriter, res interface{}, err bool) {
	w.Header().Set("Content-Type", DefaultContentTypeV1_1)
	if err {
		w.WriteHeader(http.StatusInternalServerError)
	}
	json.NewEncoder(w).Encode(res)
}
674091
func getExpandedAddress(user, instanceURL string) (string, error) {

	if user == "" || instanceURL == "" {
		return "", errors.New("some required account data is missing")
	}

	parsedURL, err := url.Parse(instanceURL)
	if err != nil {
		return "", err
	}

	return fmt.Sprintf("@%s@%s", user, parsedURL.Host), nil
}
639684
func encodeHTTPGenericResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {
	if f, ok := response.(endpoint.Failer); ok && f.Failed() != nil {
		errorEncoder(ctx, f.Failed(), w)
		return nil
	}
	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	return json.NewEncoder(w).Encode(response)
}
1315699
func EncodeHTTPCreateSessionResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {
	res := response.(createSessionResponse)
	if res.Err != nil {
		return businessErrorEncoder(ctx, res.Err, w)
	}
	defer kitty.TraceStatusAndFinish(ctx, w.Header(), 201)
	encodeSession(w, res.Session, 201)
	return nil
}
953484
func (parser *EndorserResponseParser) ParseResponse(channel string, res ServiceResponse) error {
	rawResponse := res.Raw()
	if len(rawResponse.Results) == 0 {
		return errors.New("empty results")
	}

	if e := rawResponse.Results[0].GetError(); e != nil {
		return errors.Errorf("server returned: %s", e.Content)
	}

	ccQueryRes := rawResponse.Results[0].GetCcQueryRes()
	if ccQueryRes == nil {
		return errors.Errorf("server returned response of unexpected type: %v", reflect.TypeOf(rawResponse.Results[0]))
	}

	jsonBytes, _ := json.MarshalIndent(parseEndorsementDescriptors(ccQueryRes.Content), "", "\t")
	fmt.Fprintln(parser.Writer, string(jsonBytes))
	return nil
}