func HandleCreateInput(
	user *graylog.User, lgc *logic.Logic,
	w http.ResponseWriter, r *http.Request, _ httprouter.Params,
) (interface{}, int, error) {
	// POST /system/inputs Launch input on this node
	if sc, err := lgc.Authorize(user, "inputs:create"); 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
	}
	// change configuration to attributes
	// https://github.com/Graylog2/graylog2-server/issues/3480
	body["attributes"] = body["configuration"]
	delete(body, "configuration")
	d := &graylog.InputData{}
	if err := util.MSDecode(body, d); err != nil {
		lgc.Logger().WithFields(log.Fields{
			"body": body, "error": err,
		}).Info("Failed to parse request body as InputData")
		return nil, 400, err
	}
	input := &graylog.Input{}
	if err := d.ToInput(input); err != nil {
		return nil, 400, err
	}
	sc, err = lgc.AddInput(input)
	if err != nil {
		return nil, sc, err
	}
	if err := lgc.Save(); err != nil {
		return nil, 500, err
	}
	return &map[string]string{"id": input.ID}, sc, nil
}
// HandleCreateInput is the handler of Create an Input API.
HandleCreateInput is the handler of Create an Input API.
// HandleCreateInput is the handler of Create an Input API .
func HandleCreateInput(
	user *graylog.User, lgc *logic.Logic,
	w http.ResponseWriter, r *http.Request, _ httprouter.Params,
) (interface{}, int, error) {
	if sc, err := lgc.Authorize(user, "inputs:create"); 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.InputData{}
	if err := util.MSDecode(body, d); err != nil {
		lgc.Logger().WithFields(log.Fields{
			"body": body, "error": err,
		}).Info("Failed to parse request body as InputData")
		return nil, 400, err
	}
	input := &graylog.Input{}
	if err := d.ToInput(input); err != nil {
		return nil, 400, err
	}
	sc, err = lgc.AddInput(input)
	if err != nil {
		return nil, sc, err
	}
	if err := lgc.Save(); err != nil {
		return nil, 500, err
	}
	return &map[string]string{"id": input.ID}, sc, nil
}
func HandleCreateInput ( user * graylog . User , lgc * logic . Logic , w http . ResponseWriter , r * http . Request , _ httprouter . Params , ) ( interface { } , int , error ) { if sc , err := lgc . Authorize ( user , " " ) ; 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 . InputData { } if err := util . MSDecode ( body , d ) ; err != nil { lgc . Logger ( ) . WithFields ( log . Fields { " " : body , " " : err , } ) . Info ( " " ) return nil , 400 , err } input := & graylog . Input { } if err := d . ToInput ( input ) ; err != nil { return nil , 400 , err } sc , err = lgc . AddInput ( input ) if err != nil { return nil , sc , err } if err := lgc . Save ( ) ; err != nil { return nil , 500 , err } return & map [ string ] string { " " : input . ID } , sc , nil }
HandleCreateInput is the handler of Create an Input API.
HandleCreateInput is the handler of Create an Input API .
// POST /system/inputs Launch input on this node // change configuration to attributes // https://github.com/Graylog2/graylog2-server/issues/3480