More minor changes

This commit is contained in:
David Allen 2024-08-12 13:09:15 -06:00
parent e02558fd00
commit c0a6d3bb6f
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC
5 changed files with 227 additions and 18 deletions

View file

@ -6,8 +6,6 @@ package client
import (
"fmt"
"net/http"
"github.com/OpenCHAMI/magellan/internal/util"
)
type SmdClient struct {
@ -31,14 +29,14 @@ func (c SmdClient) GetClient() *http.Client {
// Add() has a similar function definition to that of the default implementation,
// but also allows further customization and data/header manipulation that would
// be specific and/or unique to SMD's API.
func (c SmdClient) Add(data util.HTTPBody, headers util.HTTPHeader) error {
func (c SmdClient) Add(data HTTPBody, headers HTTPHeader) error {
if data == nil {
return fmt.Errorf("failed to add redfish endpoint: no data found")
}
// Add redfish endpoint via POST `/hsm/v2/Inventory/RedfishEndpoints` endpoint
url := c.RootEndpoint("/Inventory/RedfishEndpoints")
res, body, err := util.MakeRequest(c.Client, url, http.MethodPost, data, headers)
res, body, err := MakeRequest(c.Client, url, http.MethodPost, data, headers)
if res != nil {
statusOk := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOk {
@ -49,13 +47,13 @@ func (c SmdClient) Add(data util.HTTPBody, headers util.HTTPHeader) error {
return err
}
func (c SmdClient) Update(data util.HTTPBody, headers util.HTTPHeader) error {
func (c SmdClient) Update(data HTTPBody, headers HTTPHeader) error {
if data == nil {
return fmt.Errorf("failed to add redfish endpoint: no data found")
}
// Update redfish endpoint via PUT `/hsm/v2/Inventory/RedfishEndpoints` endpoint
url := c.RootEndpoint("/Inventory/RedfishEndpoints/" + c.Xname)
res, body, err := util.MakeRequest(c.Client, url, http.MethodPut, data, headers)
res, body, err := MakeRequest(c.Client, url, http.MethodPut, data, headers)
fmt.Printf("%v (%v)\n%s\n", url, res.Status, string(body))
if res != nil {
statusOk := res.StatusCode >= 200 && res.StatusCode < 300