mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
More minor changes
This commit is contained in:
parent
e02558fd00
commit
c0a6d3bb6f
5 changed files with 227 additions and 18 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue