Skip to content

Commit

Permalink
Adding a few forgotten functions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlovelltroy committed Oct 10, 2024
1 parent a458565 commit 9e0c3fa
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion cmd/smd/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9e0c3fa

Please sign in to comment.