# HG changeset patch # User Sascha L. Teichmann # Date 1547035869 -3600 # Node ID 7c54babe10f7f8f59c9ee68e46a994047079fe2e # Parent 74f7d4c531bc46a4cc1962cf3317b86a48769ac6 Configured imports: Added GET /imports/config/{id:[0-9]+}/run" to run a configured import. diff -r 74f7d4c531bc -r 7c54babe10f7 pkg/controllers/importconfig.go --- a/pkg/controllers/importconfig.go Wed Jan 09 13:03:24 2019 +0100 +++ b/pkg/controllers/importconfig.go Wed Jan 09 13:11:09 2019 +0100 @@ -83,6 +83,32 @@ ` ) +func runImportConfig( + _ interface{}, + req *http.Request, + _ *sql.Conn, +) (jr JSONResult, err error) { + + id, _ := strconv.ParseInt(mux.Vars(req)["id"], 10, 64) + + var jobID int64 + if jobID, err = imports.RunConfiguredImport(id); err != nil { + return + } + + var result = struct { + ID int64 `json:"id"` + }{ + ID: jobID, + } + + jr = JSONResult{ + Code: http.StatusCreated, + Result: &result, + } + return +} + func modifyImportConfig( input interface{}, req *http.Request, diff -r 74f7d4c531bc -r 7c54babe10f7 pkg/controllers/routes.go --- a/pkg/controllers/routes.go Wed Jan 09 13:03:24 2019 +0100 +++ b/pkg/controllers/routes.go Wed Jan 09 13:11:09 2019 +0100 @@ -197,6 +197,12 @@ })).Methods(http.MethodPost) // Import scheduler configuration + api.Handle("/imports/config/{id:[0-9]+}/run", + waterwayAdmin(&JSONHandler{ + Handle: runImportConfig, + NoConn: true, + })).Methods(http.MethodGet) + api.Handle("/imports/config/{id:[0-9]+}", waterwayAdmin(&JSONHandler{ Handle: modifyImportConfig,