in internal/pkg/apivalidator/request.go [98:133]
func buildRequest(host, path, method string) *http.Request {
// We are setting some defaults and populating empty bodies
// in order to avoid validation errors from API
path = strings.ReplaceAll(path, "{resource_kind}", "kibana")
path = strings.ReplaceAll(path, "{stateless_resource_kind}", "apm")
isPost := method == "POST"
isPut := method == "PUT"
isPatch := method == "PATCH"
isUsersAuthKeys := strings.Contains(path, "/users/auth/keys")
isDeploymentTemplates := strings.Contains(path, "deployments/templates")
if isDeploymentTemplates {
path += "?region=ece-region"
}
if isPost || isPut || isPatch || isUsersAuthKeys {
r := strings.NewReader(`{}`)
return &http.Request{
Method: method,
Body: io.NopCloser(r),
URL: &url.URL{
Host: host,
Path: path,
},
}
}
return &http.Request{
Method: method,
URL: &url.URL{
Host: host,
Path: path,
},
}
}