// HandleUpdateInput is the handler of Update an Input API.
HandleUpdateInput is the handler of Update an Input API.
// HandleUpdateInput is the handler of Update an Input API .
func HandleUpdateInput(
	user *graylog.User, lgc *logic.Logic,
	w http.ResponseWriter, r *http.Request, ps httprouter.Params,
) (interface{}, int, error) {
	id := ps.ByName("inputID")
	if sc, err := lgc.Authorize(user, "inputs:edit", id); err != nil {
		return nil, sc, err
	}
	body, sc, err := validateRequestBody(
		r.Body, &validateReqBodyPrms{
			Required:     set.NewStrSet("title", "type", "configuration"),
			Optional:     set.NewStrSet("global", "node"),
			ExtForbidden: true,
		})
	if err != nil {
		return nil, sc, err
	}
	body["attributes"] = body["configuration"]
	delete(body, "configuration")
	d := &graylog.InputUpdateParamsData{}
	if err := util.MSDecode(body, d); err != nil {
		lgc.Logger().WithFields(log.Fields{
			"body": body, "error": err,
		}).Info("Failed to parse request body as InputUpdateParamsData")
		return nil, 400, err
	}
	prms := &graylog.InputUpdateParams{}
	if err := d.ToInputUpdateParams(prms); err != nil {
		return nil, 400, err
	}
	lgc.Logger().WithFields(log.Fields{
		"body": body, "input": prms, "id": id,
	}).Debug("request body")
	prms.ID = id
	input, sc, err := lgc.UpdateInput(prms)
	if err != nil {
		return nil, sc, err
	}
	if err := lgc.Save(); err != nil {
		return nil, 500, err
	}
	return input, sc, nil
}
func HandleUpdateInput ( user * graylog . User , lgc * logic . Logic , w http . ResponseWriter , r * http . Request , ps httprouter . Params , ) ( interface { } , int , error ) { id := ps . ByName ( " " ) if sc , err := lgc . Authorize ( user , " " , id ) ; err != nil { return nil , sc , err } body , sc , err := validateRequestBody ( r . Body , & validateReqBodyPrms { Required : set . NewStrSet ( " " , " " , " " ) , Optional : set . NewStrSet ( " " , " " ) , ExtForbidden : true , } ) if err != nil { return nil , sc , err } body [ " " ] = body [ " " ] delete ( body , " " ) d := & graylog . InputUpdateParamsData { } if err := util . MSDecode ( body , d ) ; err != nil { lgc . Logger ( ) . WithFields ( log . Fields { " " : body , " " : err , } ) . Info ( " " ) return nil , 400 , err } prms := & graylog . InputUpdateParams { } if err := d . ToInputUpdateParams ( prms ) ; err != nil { return nil , 400 , err } lgc . Logger ( ) . WithFields ( log . Fields { " " : body , " " : prms , " " : id , } ) . Debug ( " " ) prms . ID = id input , sc , err := lgc . UpdateInput ( prms ) if err != nil { return nil , sc , err } if err := lgc . Save ( ) ; err != nil { return nil , 500 , err } return input , sc , nil }
HandleUpdateInput is the handler of Update an Input API.
HandleUpdateInput is the handler of Update an Input API .
// PUT /system/inputs/{inputID} Update input on this node // change configuration to attributes // https://github.com/Graylog2/graylog2-server/issues/3480