diff options
author | Ritu Sood <ritu.sood@intel.com> | 2020-08-04 14:46:34 -0700 |
---|---|---|
committer | Ritu Sood <ritu.sood@intel.com> | 2020-08-20 11:42:12 -0700 |
commit | 6fc3a329aba55dfa2d4867bde9d8a3126b45f59a (patch) | |
tree | 21e39a03255198a8f0781a78ad9e2ade1f3c28ed /src/orchestrator/api/add_intents_handler.go | |
parent | 6e5ca4741dab0de3b4d89f410f0ff9d0313d6aee (diff) |
Add Validation for API's
Adding input validations for API based
on Json schemas
Issue-ID: MULTICLOUD-1096
Signed-off-by: Ritu Sood <ritu.sood@intel.com>
Change-Id: If6591bdef6305f87cbce7ef56d894376f687c6c1
Diffstat (limited to 'src/orchestrator/api/add_intents_handler.go')
-rw-r--r-- | src/orchestrator/api/add_intents_handler.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/orchestrator/api/add_intents_handler.go b/src/orchestrator/api/add_intents_handler.go index ac8b400d..21a33739 100644 --- a/src/orchestrator/api/add_intents_handler.go +++ b/src/orchestrator/api/add_intents_handler.go @@ -31,6 +31,7 @@ type intentHandler struct { client moduleLib.IntentManager } +// Add Intent in Deployment Group func (h intentHandler) addIntentHandler(w http.ResponseWriter, r *http.Request) { var i moduleLib.Intent @@ -45,8 +46,11 @@ func (h intentHandler) addIntentHandler(w http.ResponseWriter, r *http.Request) return } - if i.MetaData.Name == "" { - http.Error(w, "Missing Intent in POST request", http.StatusBadRequest) + jsonFile := "json-schemas/deployment-intent.json" + // Verify JSON Body + err, httpError := validation.ValidateJsonSchemaData(jsonFile, i) + if err != nil { + http.Error(w, err.Error(), httpError) return } |