in internal/pkg/api/openapi.gen.go [1903:1985]
func (siw *ServerInterfaceWrapper) AgentEnroll(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
ctx = context.WithValue(ctx, ApiKeyScopes, []string{})
// Parameter object where we will unmarshal all parameters from the context
var params AgentEnrollParams
headers := r.Header
// ------------- Required header parameter "User-Agent" -------------
if valueList, found := headers[http.CanonicalHeaderKey("User-Agent")]; found {
var UserAgent UserAgent
n := len(valueList)
if n != 1 {
siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "User-Agent", Count: n})
return
}
err = runtime.BindStyledParameterWithLocation("simple", false, "User-Agent", runtime.ParamLocationHeader, valueList[0], &UserAgent)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "User-Agent", Err: err})
return
}
params.UserAgent = UserAgent
} else {
err := fmt.Errorf("Header parameter User-Agent is required, but not found")
siw.ErrorHandlerFunc(w, r, &RequiredHeaderError{ParamName: "User-Agent", Err: err})
return
}
// ------------- Optional header parameter "X-Request-Id" -------------
if valueList, found := headers[http.CanonicalHeaderKey("X-Request-Id")]; found {
var XRequestId RequestId
n := len(valueList)
if n != 1 {
siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "X-Request-Id", Count: n})
return
}
err = runtime.BindStyledParameterWithLocation("simple", false, "X-Request-Id", runtime.ParamLocationHeader, valueList[0], &XRequestId)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "X-Request-Id", Err: err})
return
}
params.XRequestId = &XRequestId
}
// ------------- Optional header parameter "elastic-api-version" -------------
if valueList, found := headers[http.CanonicalHeaderKey("elastic-api-version")]; found {
var ElasticApiVersion ApiVersion
n := len(valueList)
if n != 1 {
siw.ErrorHandlerFunc(w, r, &TooManyValuesForParamError{ParamName: "elastic-api-version", Count: n})
return
}
err = runtime.BindStyledParameterWithLocation("simple", false, "elastic-api-version", runtime.ParamLocationHeader, valueList[0], &ElasticApiVersion)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "elastic-api-version", Err: err})
return
}
params.ElasticApiVersion = &ElasticApiVersion
}
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.AgentEnroll(w, r, params)
}))
for _, middleware := range siw.HandlerMiddlewares {
handler = middleware(handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}