diff --git a/cmd/smd/response.go b/cmd/smd/response.go index a0e7657..9007732 100644 --- a/cmd/smd/response.go +++ b/cmd/smd/response.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - base "github.com/Cray-HPE/hms-base/v2" + base "github.com/Cray-HPE/hms-base" "github.com/OpenCHAMI/smd/v2/pkg/sm" ) @@ -60,6 +60,31 @@ func sendResource(w http.ResponseWriter, code int, uri *sm.ResourceURI) { sendJSON(w, code, uri) } + +func sendJsonNewResourceIDArray(w http.ResponseWriter, collectionURI string, uris []*sm.ResourceURI) { + if len(uris) == 0 { + sendJSON(w, http.StatusNoContent, nil) + } else { + sendResourceArray(w, http.StatusCreated, collectionURI, uris) + } +} + +func sendJsonNewResourceID(w http.ResponseWriter, uri *sm.ResourceURI) { + if uri == nil { + sendJSON(w, http.StatusNoContent, nil) + } else { + sendResource(w, http.StatusCreated, uri) + } +} + +func sendJsonResourceIDArray(w http.ResponseWriter, uris []*sm.ResourceURI) { + if len(uris) == 0 { + sendJSON(w, http.StatusNoContent, nil) + } else { + sendJSON(w, http.StatusOK, uris) + } +} + func sendJsonObject(w http.ResponseWriter, code int, obj interface{}) { if obj == nil { sendJSON(w, http.StatusNoContent, nil)