// BodyParameter creates a new Parameter of kind Body for documentation purposes.
// It is initialized as required without a DataType.
351444
func BodyParameter(name, description string) *Parameter {
	p := &Parameter{&ParameterData{Name: name, Description: description, Required: true}}
	p.beBody()
	return p
}
853040
func (o *CreateTaskParams) WithBody(body *models.Task) *CreateTaskParams {
	o.SetBody(body)
	return o
}
749315
func (c *Network) GetResponseBodyWithParams(v *NetworkGetResponseBodyParams) (string, bool, error) {
	resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Network.getResponseBody", Params: v})
	if err != nil {
		return "", false, err
	}

	var chromeData struct {
		Result struct {
			Body          string
			Base64Encoded bool
		}
	}

	if resp == nil {
		return "", false, &gcdmessage.ChromeEmptyResponseErr{}
	}

	// test if error first
	cerr := &gcdmessage.ChromeErrorResponse{}
	json.Unmarshal(resp.Data, cerr)
	if cerr != nil && cerr.Error != nil {
		return "", false, &gcdmessage.ChromeRequestErr{Resp: cerr}
	}

	if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
		return "", false, err
	}

	return chromeData.Result.Body, chromeData.Result.Base64Encoded, nil
}
1088925
func (s *IndicesPutMappingService) BodyString(mapping string) *IndicesPutMappingService {
	s.bodyString = mapping
	return s
}
1103596
func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) {
	errors := make([]error, 0)
	x := &Parameter{}
	matched := false
	// BodyParameter body_parameter = 1;
	{
		m, ok := compiler.UnpackMap(in)
		if ok {
			// errors might be ok here, they mean we just don't have the right subtype
			t, matchingError := NewBodyParameter(m, compiler.NewContext("bodyParameter", context))
			if matchingError == nil {
				x.Oneof = &Parameter_BodyParameter{BodyParameter: t}
				matched = true
			} else {
				errors = append(errors, matchingError)
			}
		}
	}
	// NonBodyParameter non_body_parameter = 2;
	{
		m, ok := compiler.UnpackMap(in)
		if ok {
			// errors might be ok here, they mean we just don't have the right subtype
			t, matchingError := NewNonBodyParameter(m, compiler.NewContext("nonBodyParameter", context))
			if matchingError == nil {
				x.Oneof = &Parameter_NonBodyParameter{NonBodyParameter: t}
				matched = true
			} else {
				errors = append(errors, matchingError)
			}
		}
	}
	if matched {
		// since the oneof matched one of its possibilities, discard any matching errors
		errors = make([]error, 0)
	}
	return x, compiler.NewErrorGroupOrNil(errors)
}
1135939
func (s *SnapshotCreateRepositoryService) buildBody() (interface{}, error) {
	if s.bodyJson != nil {
		return s.bodyJson, nil
	}
	if s.bodyString != "" {
		return s.bodyString, nil
	}

	body := map[string]interface{}{
		"type": s.typ,
	}
	if len(s.settings) > 0 {
		body["settings"] = s.settings
	}
	return body, nil
}
1114015
func NewNonBodyParameter(in interface{}, context *compiler.Context) (*NonBodyParameter, error) {
	errors := make([]error, 0)
	x := &NonBodyParameter{}
	matched := false
	m, ok := compiler.UnpackMap(in)
	if !ok {
		message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
		errors = append(errors, compiler.NewError(context, message))
	} else {
		requiredKeys := []string{"in", "name", "type"}
		missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
		if len(missingKeys) > 0 {
			message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
			errors = append(errors, compiler.NewError(context, message))
		}
		// HeaderParameterSubSchema header_parameter_sub_schema = 1;
		{
			// errors might be ok here, they mean we just don't have the right subtype
			t, matchingError := NewHeaderParameterSubSchema(m, compiler.NewContext("headerParameterSubSchema", context))
			if matchingError == nil {
				x.Oneof = &NonBodyParameter_HeaderParameterSubSchema{HeaderParameterSubSchema: t}
				matched = true
			} else {
				errors = append(errors, matchingError)
			}
		}
		// FormDataParameterSubSchema form_data_parameter_sub_schema = 2;
		{
			// errors might be ok here, they mean we just don't have the right subtype
			t, matchingError := NewFormDataParameterSubSchema(m, compiler.NewContext("formDataParameterSubSchema", context))
			if matchingError == nil {
				x.Oneof = &NonBodyParameter_FormDataParameterSubSchema{FormDataParameterSubSchema: t}
				matched = true
			} else {
				errors = append(errors, matchingError)
			}
		}
		// QueryParameterSubSchema query_parameter_sub_schema = 3;
		{
			// errors might be ok here, they mean we just don't have the right subtype
			t, matchingError := NewQueryParameterSubSchema(m, compiler.NewContext("queryParameterSubSchema", context))
			if matchingError == nil {
				x.Oneof = &NonBodyParameter_QueryParameterSubSchema{QueryParameterSubSchema: t}
				matched = true
			} else {
				errors = append(errors, matchingError)
			}
		}
		// PathParameterSubSchema path_parameter_sub_schema = 4;
		{
			// errors might be ok here, they mean we just don't have the right subtype
			t, matchingError := NewPathParameterSubSchema(m, compiler.NewContext("pathParameterSubSchema", context))
			if matchingError == nil {
				x.Oneof = &NonBodyParameter_PathParameterSubSchema{PathParameterSubSchema: t}
				matched = true
			} else {
				errors = append(errors, matchingError)
			}
		}
	}
	if matched {
		// since the oneof matched one of its possibilities, discard any matching errors
		errors = make([]error, 0)
	}
	return x, compiler.NewErrorGroupOrNil(errors)
}
723433
func (s *IndicesPutMappingService) BodyJson(mapping map[string]interface{}) *IndicesPutMappingService {
	s.bodyJson = mapping
	return s
}
459255
func (tib *TypeInBody) Body() raml.Bodies {
	if tib.ReqResp == HTTPRequest {
		return tib.Endpoint.Method.Bodies
	}
	for code, resp := range tib.Endpoint.Method.Responses {
		if code == tib.RespCode {
			return resp.Bodies
		}
	}
	panic("failed to get body of " + tib.Endpoint.Verb + " " + tib.Endpoint.Addr)
}
353175
func (b *IndicesCreateService) Body(body string) *IndicesCreateService {
	b.bodyString = body
	return b
}
148262
func (s *PutMappingService) BodyString(mapping string) *PutMappingService {
	s.bodyString = mapping
	return s
}
784087
func ParseBody(input string) (Body, error) {
	stmts, _, err := ParseStatements("", input)
	if err != nil {
		return nil, err
	}

	result := Body{}

	for _, stmt := range stmts {
		switch stmt := stmt.(type) {
		case Body:
			result = append(result, stmt...)
		case *Comment:
			// skip
		default:
			return nil, fmt.Errorf("expected body but got %T", stmt)
		}
	}

	setExprIndices(result)

	return result, nil
}
110405
func (s *CountService) BodyString(body string) *CountService {
	s.bodyString = body
	return s
}
740014
func (r *Response) Body() []byte {
	if r.RawResponse == nil {
		return []byte{}
	}
	return r.body
}
901635
func (r *Response) BodyString(body string) *Response {
	r.BodyBuffer = []byte(body)
	return r
}
796850
func (c *Client) NewRequestWithBody(method, path string, body io.Reader) *Request {
	r := c.NewRequest(method, path)

	// Set request body
	r.body = body

	return r
}
980476
func Body(r *http.Request, v interface{}) error {
	if err := json.NewDecoder(r.Body).Decode(v); err != nil {
		return err
	}
	return Validate.StructCtx(r.Context(), v)
}