gofish

package module
v0.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2026 License: BSD-3-Clause Imports: 17 Imported by: 63

README

Gofish - Redfish and Swordfish client library

Go Doc Go Report Card Releases LICENSE

Gofish Logo

Introduction

Gofish is a Golang library for interacting with DMTF Redfish and SNIA Swordfish enabled devices.

Usage

Basic usage would be:


package main

import (
    "fmt"

    "github.com/stmcginnis/gofish"
)

func main() {
    c, err := gofish.ConnectDefault("http://localhost:5000")
    if err != nil {
        panic(err)
    }

    service := c.Service
    chassis, err := service.Chassis()
    if err != nil {
        panic(err)
    }

    for _, chass := range chassis {
        fmt.Printf("Chassis: %#v\n\n", chass)
    }
}

Documentation

Overview

Example (ConditionalReload)

Example_conditionalReload shows schemas.Reload, the general form of a conditional GET where the caller supplies the request headers directly. Use it when you cache ETags outside the object, or when a vendor requires an unquoted ETag in If-None-Match. schemas.Refresh is the convenience wrapper over this.

package main

import (
	"errors"
	"fmt"
	"log"

	"github.com/stmcginnis/gofish"
	"github.com/stmcginnis/gofish/schemas"
)

func main() {
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Username: "my-username",
		Password: "my-password",
		Insecure: true,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Logout()

	chassis, err := c.Service.Chassis()
	if err != nil || len(chassis) == 0 {
		log.Print(err)
		return
	}

	power, err := chassis[0].Power()
	if err != nil {
		log.Print(err)
		return
	}

	power, err = schemas.Reload(power, map[string]string{"If-None-Match": power.GetETag()})
	if errors.Is(err, schemas.ErrNotModified) {
		fmt.Println("power metrics unchanged")
		return
	}
	if err != nil {
		log.Print(err)
		return
	}

	fmt.Printf("refreshed power resource: %s\n", power.Name)
}
Example (FirmwareInventory)

Example_firmwareInventory shows how to list all firmware components reported by the UpdateService, which is useful for auditing installed firmware versions across the managed system.

package main

import (
	"fmt"
	"log"

	"github.com/stmcginnis/gofish"
)

func main() {
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Username: "my-username",
		Password: "my-password",
		Insecure: true,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Logout()

	updateService, err := c.Service.UpdateService()
	if err != nil {
		log.Print(err)
		return
	}

	inventory, err := updateService.FirmwareInventory()
	if err != nil {
		log.Print(err)
		return
	}

	for _, item := range inventory {
		fmt.Printf("%-40s  version=%-20s  updateable=%v\n",
			item.Name, item.Version, item.Updateable)
	}
}
Example (FirmwareUpdate)

Example_firmwareUpdate demonstrates a simple firmware update using an image URI. The update is submitted to the service and a task monitor is returned for polling completion status.

package main

import (
	"fmt"
	"log"

	"github.com/stmcginnis/gofish"
	"github.com/stmcginnis/gofish/schemas"
)

func main() {
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Username: "my-username",
		Password: "my-password",
		Insecure: true,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Logout()

	updateService, err := c.Service.UpdateService()
	if err != nil {
		log.Print(err)
		return
	}

	taskInfo, err := updateService.SimpleUpdate(&schemas.UpdateServiceSimpleUpdateParameters{
		ImageURI:         "https://firmware-server/bmc-firmware-2.0.bin",
		TransferProtocol: schemas.HTTPSTransferProtocolType,
	})
	if err != nil {
		log.Print(err)
		return
	}

	if taskInfo != nil {
		fmt.Printf("Update task submitted: %s\n", taskInfo.TaskMonitor)
	}
}
Example (MountVirtualMedia)

Example_mountVirtualMedia demonstrates how to mount a remote ISO image as virtual media on a manager, enabling virtual CD/DVD boot without physical media.

package main

import (
	"fmt"
	"log"

	"github.com/stmcginnis/gofish"
	"github.com/stmcginnis/gofish/schemas"
)

func main() {
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Username: "my-username",
		Password: "my-password",
		Insecure: true,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Logout()

	managers, err := c.Service.Managers()
	if err != nil {
		log.Print(err)
		return
	}

	for _, mgr := range managers {
		virtualMedia, err := mgr.VirtualMedia()
		if err != nil {
			continue
		}

		for _, vm := range virtualMedia {
			// Find the CD/DVD slot.
			if vm.MediaTypes == nil {
				continue
			}
			for _, mt := range vm.MediaTypes {
				if mt != schemas.CDVirtualMediaType && mt != schemas.DVDVirtualMediaType {
					continue
				}

				_, err := vm.InsertMedia(&schemas.VirtualMediaInsertMediaParameters{
					Image:                "https://file-server/os-installer.iso",
					TransferProtocolType: gofish.ToRef(schemas.HTTPSTransferProtocolType),
					Inserted:             gofish.ToRef(true),
					WriteProtected:       gofish.ToRef(true),
				})
				if err != nil {
					log.Printf("error inserting media: %v", err)
					continue
				}

				fmt.Printf("Mounted ISO on %s\n", vm.Name)
			}
		}
	}
}
Example (PollThermalConditionally)

Example_pollThermalConditionally shows how to poll a resource efficiently with a conditional GET. schemas.Refresh re-fetches the object using its own ETag as If-None-Match; when the service reports no change it returns schemas.ErrNotModified and the existing object stays valid, avoiding the JSON parse and most of the bytes on the wire. This is the intended pattern for polling fleets of BMCs for resources that change infrequently.

package main

import (
	"errors"
	"fmt"
	"log"
	"time"

	"github.com/stmcginnis/gofish"
	"github.com/stmcginnis/gofish/schemas"
)

func main() {
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Username: "my-username",
		Password: "my-password",
		Insecure: true,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Logout()

	chassis, err := c.Service.Chassis()
	if err != nil || len(chassis) == 0 {
		log.Print(err)
		return
	}

	// Initial fetch captures the resource and its ETag.
	thermal, err := chassis[0].Thermal()
	if err != nil {
		log.Print(err)
		return
	}

	// Poll on an interval; only re-parse when the BMC reports a change.
	for range time.Tick(30 * time.Second) {
		refreshed, err := schemas.Refresh(thermal)
		switch {
		case errors.Is(err, schemas.ErrNotModified):
			continue // unchanged since last poll; keep using the cached object
		case err != nil:
			log.Printf("error refreshing thermal: %v", err)
			continue
		}

		thermal = refreshed
		for i := range thermal.Temperatures {
			if temp := &thermal.Temperatures[i]; temp.ReadingCelsius != nil {
				fmt.Printf("%s: %.1f °C\n", temp.Name, *temp.ReadingCelsius)
			}
		}
	}
}
Example (QueryManagers)

Example_queryManagers shows how to list BMC/management controller details, such as firmware version and network protocol configuration.

package main

import (
	"fmt"
	"log"

	"github.com/stmcginnis/gofish"
)

func main() {
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Username: "my-username",
		Password: "my-password",
		Insecure: true,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Logout()

	managers, err := c.Service.Managers()
	if err != nil {
		log.Print(err)
		return
	}

	for _, mgr := range managers {
		fmt.Printf("Manager: %s  type=%s  firmware=%s\n",
			mgr.Name, mgr.ManagerType, mgr.FirmwareVersion)

		netProto, err := mgr.NetworkProtocol()
		if err != nil {
			continue
		}
		fmt.Printf("  Hostname: %s\n", netProto.HostName)
	}
}
Example (QuerySystemInventory)

Example_querySystemInventory demonstrates how to retrieve processor and memory information from all systems registered with the service.

package main

import (
	"fmt"
	"log"

	"github.com/stmcginnis/gofish"
)

func main() {
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Username: "my-username",
		Password: "my-password",
		Insecure: true,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Logout()

	systems, err := c.Service.Systems()
	if err != nil {
		log.Print(err)
		return
	}

	for _, system := range systems {
		fmt.Printf("System: %s\n", system.Name)

		processors, err := system.Processors()
		if err != nil {
			log.Printf("error getting processors: %v", err)
		}
		for _, p := range processors {
			fmt.Printf("  CPU: %s %s\n", p.Manufacturer, p.Model)
			fmt.Printf("    Cores: %d  Threads: %d\n",
				gofish.Deref(p.TotalCores), gofish.Deref(p.TotalThreads))
			fmt.Printf("    Max speed: %d MHz\n", gofish.Deref(p.MaxSpeedMHz))
		}

		memory, err := system.Memory()
		if err != nil {
			log.Printf("error getting memory: %v", err)
		}
		for _, dimm := range memory {
			fmt.Printf("  DIMM: %s  %d MiB  %d MHz\n",
				dimm.Name,
				gofish.Deref(dimm.CapacityMiB),
				gofish.Deref(dimm.OperatingSpeedMhz))
		}
	}
}
Example (QueryThermal)

Example_queryThermal shows how to read temperature sensor and fan speed readings from all chassis managed by the service.

package main

import (
	"fmt"
	"log"

	"github.com/stmcginnis/gofish"
)

func main() {
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Username: "my-username",
		Password: "my-password",
		Insecure: true,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Logout()

	chassis, err := c.Service.Chassis()
	if err != nil {
		log.Print(err)
		return
	}

	for _, ch := range chassis {
		thermal, err := ch.Thermal()
		if err != nil {
			log.Printf("error getting thermal for chassis %s: %v", ch.Name, err)
			continue
		}

		fmt.Printf("Chassis: %s\n", ch.Name)

		for i := range thermal.Temperatures {
			temp := &thermal.Temperatures[i]
			if temp.ReadingCelsius == nil {
				continue
			}
			fmt.Printf("  Temp: %-30s  %.1f °C\n", temp.Name, *temp.ReadingCelsius)
		}

		for i := range thermal.Fans {
			fan := &thermal.Fans[i]
			if fan.Reading == nil {
				continue
			}
			fmt.Printf("  Fan:  %-30s  %d %s\n", fan.Name, *fan.Reading, fan.ReadingUnits)
		}
	}
}
Example (ReadEventLog)

Example_readEventLog shows how to read entries from the system event log via the Manager's LogService. This is useful for diagnostics and auditing.

package main

import (
	"fmt"
	"log"

	"github.com/stmcginnis/gofish"
)

func main() {
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Username: "my-username",
		Password: "my-password",
		Insecure: true,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Logout()

	managers, err := c.Service.Managers()
	if err != nil {
		log.Print(err)
		return
	}

	for _, mgr := range managers {
		logServices, err := mgr.LogServices()
		if err != nil {
			continue
		}

		for _, ls := range logServices {
			entries, err := ls.Entries()
			if err != nil {
				continue
			}

			fmt.Printf("Log: %s\n", ls.Name)
			for _, entry := range entries {
				fmt.Printf("  [%s] %s: %s\n",
					entry.Severity, entry.Created, entry.Message)
			}
		}
	}
}
Example (SubscribeEvents)

Example_subscribeEvents shows how to register a webhook endpoint to receive Redfish event notifications. The returned subscription URI can be used later to modify or delete the subscription.

package main

import (
	"fmt"
	"log"

	"github.com/stmcginnis/gofish"
	"github.com/stmcginnis/gofish/schemas"
)

func main() {
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Username: "my-username",
		Password: "my-password",
		Insecure: true,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Logout()

	eventService, err := c.Service.EventService()
	if err != nil {
		log.Print(err)
		return
	}

	// Subscribe using registry prefixes (Redfish v1.5+).
	subscriptionURI, err := eventService.CreateEventSubscriptionInstance(
		"https://my-event-receiver/redfish/events", // destination
		[]string{"Alert", "ResourceEvent"},         // registry prefixes
		[]string{},                                 // all resource types
		nil,                                        // no custom HTTP headers
		schemas.RedfishEventDestinationProtocol,
		"my-monitoring-service", // client-supplied context string
		schemas.RetryForeverDeliveryRetryPolicy,
		nil, // no OEM data
	)
	if err != nil {
		log.Print(err)
		return
	}

	fmt.Printf("Subscription created: %s\n", subscriptionURI)

	// Delete the subscription when no longer needed.
	if err := eventService.DeleteEventSubscription(subscriptionURI); err != nil {
		log.Print(err)
	}
}
Example (UpdateBiosAttributes)

Example_updateBiosAttributes shows how to read and modify BIOS settings. Changes are applied at the next reboot unless an immediate apply time is specified.

package main

import (
	"fmt"
	"log"

	"github.com/stmcginnis/gofish"
	"github.com/stmcginnis/gofish/schemas"
)

func main() {
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Username: "my-username",
		Password: "my-password",
		Insecure: true,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Logout()

	systems, err := c.Service.Systems()
	if err != nil {
		log.Print(err)
		return
	}

	for _, system := range systems {
		bios, err := system.Bios()
		if err != nil {
			log.Printf("error getting BIOS for %s: %v", system.Name, err)
			continue
		}

		// Print current attribute values.
		for name, value := range bios.Attributes {
			fmt.Printf("  %s = %v\n", name, value)
		}

		// Update an attribute to take effect on next reboot.
		if err := bios.UpdateBiosAttributesApplyAt(
			schemas.SettingsAttributes{"NumaGroupSizeOpt": "Flat"},
			schemas.OnResetSettingsApplyTime,
		); err != nil {
			log.Printf("error updating BIOS: %v", err)
		}
	}
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deref added in v0.21.0

func Deref[T any](v *T) T

Deref is a convenience wrapper to get optional values from schema objects.

Pointer values in objects are optional values, so if you want to see if the service reported a value, then you need to explicitly check for nil:

// Did we get a display order?
if attribuate.DisplayOrder {
		// Nothing reported
}

But if we don't care if it was reported by the service and we just want its value, being fine with its zero-value if it wasn't provided, we can do:

var value int
value = Deref(attribute.DisplayOrder)

func ToRef added in v0.21.0

func ToRef[T any](v T) *T

ToRef is a convenience wrapper to get a pointer to a value. This is useful when assigning a value to an optional API object field that expects a pointer.

Types

type APIClient

type APIClient struct {

	// HTTPClient is for direct http actions
	HTTPClient *http.Client

	// Service is the ServiceRoot of this Redfish instance
	Service *Service

	Settings schemas.ClientSettings
	// contains filtered or unexported fields
}

APIClient represents a connection to a Redfish/Swordfish enabled service or device.

func Connect

func Connect(config ClientConfig) (c *APIClient, err error)

Connect creates a new client connection to a Redfish service.

Example

ExampleConnect demonstrates the basic pattern for connecting to a Redfish service and ensuring the session is cleaned up on exit.

package main

import (
	"fmt"
	"log"

	"github.com/stmcginnis/gofish"
)

func main() {
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Username: "my-username",
		Password: "my-password",
		Insecure: true,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Logout()

	fmt.Println(c.Service.RedfishVersion)
}
Example (BasicAuth)

ExampleConnect_basicAuth shows how to use HTTP Basic Auth instead of session-based authentication. Basic Auth avoids creating a server-side session but sends credentials with every request.

package main

import (
	"fmt"
	"log"

	"github.com/stmcginnis/gofish"
)

func main() {
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint:  "https://bmc-ip",
		Username:  "my-username",
		Password:  "my-password",
		Insecure:  true,
		BasicAuth: true,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Logout()

	fmt.Println(c.Service.RedfishVersion)
}
Example (ReuseSession)

ExampleConnect_reuseSession shows how to save a session token from one connection and reuse it in a later connection, avoiding the overhead of creating a new session each time.

package main

import (
	"fmt"
	"log"

	"github.com/stmcginnis/gofish"
)

func main() {
	// Initial connection that creates a session.
	c, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Username: "my-username",
		Password: "my-password",
		Insecure: true,
	})
	if err != nil {
		log.Fatal(err)
	}

	// Save the session token for later reuse.
	session, err := c.GetSession()
	if err != nil {
		log.Fatal(err)
	}

	// ... save session.ID and session.Token to persistent storage ...

	// Reconnect later using the saved session instead of credentials.
	c2, err := gofish.Connect(gofish.ClientConfig{
		Endpoint: "https://bmc-ip",
		Insecure: true,
		Session: &gofish.Session{
			ID:    session.ID,
			Token: session.Token,
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c2.Logout()

	fmt.Println(c2.Service.RedfishVersion)
}

func ConnectContext added in v0.8.0

func ConnectContext(ctx context.Context, config ClientConfig) (c *APIClient, err error)

ConnectContext is the same as Connect, but sets the ctx.

func ConnectDefault

func ConnectDefault(endpoint string) (c *APIClient, err error)

ConnectDefault creates an unauthenticated connection to a Redfish service.

func ConnectDefaultContext added in v0.8.0

func ConnectDefaultContext(ctx context.Context, endpoint string) (c *APIClient, err error)

ConnectDefaultContext is the same as ConnectDefault, but sets the ctx.

func (*APIClient) CloneWithSession added in v0.8.0

func (c *APIClient) CloneWithSession() (*APIClient, error)

CloneWithSession will create a new Client with a session instead of basic auth.

func (*APIClient) Delete

func (c *APIClient) Delete(url string) (*http.Response, error)

Delete performs a Delete request against the Redfish service

func (*APIClient) DeleteWithHeaders added in v0.10.0

func (c *APIClient) DeleteWithHeaders(url string, customHeaders map[string]string) (*http.Response, error)

DeleteWithHeaders performs a Delete request against the Redfish service but allowing custom headers

func (*APIClient) Get

func (c *APIClient) Get(url string) (*http.Response, error)

Get performs a GET request against the Redfish service.

func (*APIClient) GetService added in v0.14.0

func (c *APIClient) GetService() *Service

GetService returns the APIClient's service.

func (*APIClient) GetSession added in v0.6.0

func (c *APIClient) GetSession() (*Session, error)

GetSession retrieves the session data from an initialized APIClient. An error is returned if the client is not authenticated.

func (*APIClient) GetSettings added in v0.21.0

func (c *APIClient) GetSettings() schemas.ClientSettings

func (*APIClient) GetWithHeaders added in v0.10.0

func (c *APIClient) GetWithHeaders(url string, customHeaders map[string]string) (*http.Response, error)

GetWithHeaders performs a GET request against the Redfish service but allowing custom headers

func (*APIClient) Head added in v0.15.0

func (c *APIClient) Head(url string) (*http.Response, error)

Get performs a HEAD request against the Redfish service.

func (*APIClient) HeadWithHeaders added in v0.15.0

func (c *APIClient) HeadWithHeaders(url string, customHeaders map[string]string) (*http.Response, error)

GetWithHeaders performs a HEAD request against the Redfish service but allowing custom headers

func (*APIClient) Logout

func (c *APIClient) Logout()

Logout will delete any active session. Useful to defer logout when creating a new connection.

func (*APIClient) Patch

func (c *APIClient) Patch(url string, payload any) (*http.Response, error)

Patch performs a Patch request against the Redfish service.

func (*APIClient) PatchWithHeaders added in v0.10.0

func (c *APIClient) PatchWithHeaders(url string, payload any, customHeaders map[string]string) (*http.Response, error)

PatchWithHeaders performs a Patch request against the Redfish service but allowing custom headers

func (*APIClient) Post

func (c *APIClient) Post(url string, payload any) (*http.Response, error)

Post performs a Post request against the Redfish service.

func (*APIClient) PostMultipart added in v0.8.0

func (c *APIClient) PostMultipart(url string, payload map[string]io.Reader) (*http.Response, error)

PostMultipart performs a Post request against the Redfish service with multipart payload.

func (*APIClient) PostMultipartWithHeaders added in v0.10.0

func (c *APIClient) PostMultipartWithHeaders(url string, payload map[string]io.Reader, customHeaders map[string]string) (*http.Response, error)

PostMultipartWithHeadersperforms a Post request against the Redfish service with multipart payload but allowing custom headers

func (*APIClient) PostWithHeaders added in v0.10.0

func (c *APIClient) PostWithHeaders(url string, payload any, customHeaders map[string]string) (*http.Response, error)

PostWithHeaders performs a Post request against the Redfish service but allowing custom headers

func (*APIClient) Put

func (c *APIClient) Put(url string, payload any) (*http.Response, error)

Put performs a Put request against the Redfish service.

func (*APIClient) PutWithHeaders added in v0.10.0

func (c *APIClient) PutWithHeaders(url string, payload any, customHeaders map[string]string) (*http.Response, error)

PutWithHeaders performs a Put request against the Redfish service but allowing custom headers

func (*APIClient) RunRawRequestWithHeaders added in v0.13.0

func (c *APIClient) RunRawRequestWithHeaders(method, url string, payloadBuffer io.ReadSeeker, contentType string, customHeaders map[string]string) (*http.Response, error)

RunRawRequestWithHeaders actually performs the REST calls but allowing custom headers

func (*APIClient) SetDumpWriter added in v0.8.0

func (c *APIClient) SetDumpWriter(writer io.Writer)

SetDumpWriter sets the client the DumpWriter dynamically

func (*APIClient) WithContext added in v0.21.0

func (c *APIClient) WithContext(ctx context.Context) *APIClient

WithContext returns a copy of the client using the provided context

type ClientConfig

type ClientConfig struct {
	// Endpoint is the URL of the redfish service
	Endpoint string

	// Username is the optional user name to authenticate with.
	Username string

	// Password is the password to use for authentication.
	Password string

	// Session is an optional session ID+token obtained from a previous session
	// If this is set, it is preferred over Username and Password
	Session *Session

	// Insecure controls whether to enforce SSL certificate validity.
	Insecure bool

	// Controls TLS handshake timeout
	TLSHandshakeTimeout int

	// HTTPClient is the optional client to connect with.
	HTTPClient *http.Client

	// DumpWriter is an optional io.Writer to receive dumps of HTTP
	// requests and responses.
	DumpWriter io.Writer

	// BasicAuth tells the APIClient if basic auth should be used (true) or token based auth must be used (false)
	BasicAuth bool

	// The maximum number of concurrent HTTP requests that will be made (default: 1)
	MaxConcurrentRequests int64

	// ReuseConnections can be useful if executing a lot of requests. Setting to `true` allows
	// the TCP sessions to remain open and reused betweeen subsequent calls.
	ReuseConnections bool

	// NoModifyTransport if set indicates that the API client won't attempt to make any changes to the transport
	NoModifyTransport bool

	// AutoExpand enables $expand if supported and automatically falls back if $expand fails.
	AutoExpand bool
}

ClientConfig holds the settings for establishing a connection.

type DeepOperations added in v0.16.0

type DeepOperations struct {
	// DeepPATCH shall indicate whether this service supports the Redfish
	// Specification-defined deep 'PATCH' operation.
	//
	// Version added: v1.7.0
	DeepPATCH bool
	// DeepPOST shall indicate whether this service supports the Redfish
	// Specification-defined deep 'POST' operation.
	//
	// Version added: v1.7.0
	DeepPOST bool
	// MaxLevels shall contain the maximum levels of resources allowed in deep
	// operations.
	//
	// Version added: v1.7.0
	MaxLevels uint
}

DeepOperations shall contain information about deep operations that the service supports.

type Expand

type Expand struct {
	// ExpandAll shall indicate whether this service supports the asterisk ('*')
	// option of the '$expand' query parameter.
	//
	// Version added: v1.3.0
	ExpandAll bool
	// Levels shall indicate whether the service supports the '$levels' option of
	// the '$expand' query parameter.
	//
	// Version added: v1.3.0
	Levels bool
	// Links shall be a boolean indicating whether this service supports the use
	// of tilde (expand only entries in the Links section) as a value for the
	// $expand query parameter as described by the specification.
	Links bool
	// MaxLevels shall contain the maximum '$levels' option value in the '$expand'
	// query parameter. This property shall be present if the 'Levels' property
	// contains 'true'.
	//
	// Version added: v1.3.0
	MaxLevels uint
	// NoLinks shall indicate whether the service supports the period ('.') option
	// of the '$expand' query parameter.
	//
	// Version added: v1.3.0
	NoLinks bool
	// managerProvidingService is the URI for ManagerProvidingService.
	ManagerProvidingService string
	// sessions is the URI for Sessions.
	Sessions string
}

Expand shall contain information about the support of the '$expand' query parameter by the service.

type ProtocolFeaturesSupported

type ProtocolFeaturesSupported struct {
	// DeepOperations shall contain information about deep operations that the
	// service supports.
	//
	// Version added: v1.7.0
	DeepOperations DeepOperations
	// ExcerptQuery shall indicate whether this service supports the 'excerpt'
	// query parameter.
	//
	// Version added: v1.4.0
	ExcerptQuery bool
	// ExpandQuery shall contain information about the support of the '$expand'
	// query parameter by the service.
	//
	// Version added: v1.3.0
	ExpandQuery Expand
	// FilterQuery shall indicate whether this service supports the '$filter' query
	// parameter.
	//
	// Version added: v1.3.0
	FilterQuery bool
	// FilterQueryComparisonOperations shall indicate whether the service supports
	// the 'eq', 'ge', 'gt', 'le', 'lt', and 'ne' options for the '$filter' query
	// parameter. This property shall not be present if 'FilterQuery' contains
	// 'false'.
	//
	// Version added: v1.17.0
	FilterQueryComparisonOperations bool
	// FilterQueryCompoundOperations shall indicate whether the service supports
	// the Redfish Specification-defined grouping operators '()', 'and', 'not', and
	// 'or' options for the '$filter' query parameter. This property shall not be
	// present if 'FilterQuery' contains 'false'.
	//
	// Version added: v1.17.0
	FilterQueryCompoundOperations bool
	// IncludeOriginOfConditionQuery shall indicate whether the service supports
	// the 'includeoriginofcondition' query parameter.
	//
	// Version added: v1.18.0
	IncludeOriginOfConditionQuery bool
	// MultipleHTTPRequests shall indicate whether this service supports multiple
	// outstanding HTTP requests.
	//
	// Version added: v1.14.0
	MultipleHTTPRequests bool
	// OnlyMemberQuery shall indicate whether this service supports the 'only'
	// query parameter.
	//
	// Version added: v1.4.0
	OnlyMemberQuery bool
	// SelectQuery shall indicate whether this service supports the '$select' query
	// parameter.
	//
	// Version added: v1.3.0
	SelectQuery bool
	// TopSkipQuery shall indicate whether this service supports both the '$top'
	// and '$skip' query parameters.
	//
	// Version added: v1.17.0
	TopSkipQuery bool
}

ProtocolFeaturesSupported shall contain information about protocol features that the service supports.

type Service

type Service struct {
	schemas.Entity

	// ODataContext is the odata context.
	ODataContext string `json:"@odata.context"`
	// ODataType is the odata type.
	ODataType string `json:"@odata.type"`
	// OEM shall contain the OEM extensions. All values for properties that this
	// object contains shall conform to the Redfish Specification-described
	// requirements.
	OEM json.RawMessage `json:"Oem"`

	// Product shall include the name of the product represented by this Redfish
	// service.
	//
	// Version added: v1.3.0
	Product string
	// ProtocolFeaturesSupported shall contain information about protocol features
	// that the service supports.
	//
	// Version added: v1.3.0
	ProtocolFeaturesSupported ProtocolFeaturesSupported
	// RedfishVersion shall represent the Redfish protocol version, as specified in
	// the 'Protocol version' clause of the Redfish Specification, to which this
	// service conforms.
	RedfishVersion string

	// ServiceIdentification shall contain a vendor-provided or user-provided value
	// that identifies and associates a discovered Redfish service with a
	// particular product instance. The value of the property shall contain the
	// value of the 'ServiceIdentification' property in the 'Manager' resource
	// providing the Redfish service root resource. The value of this property is
	// used in conjunction with the 'Product' and 'Vendor' properties to match user
	// credentials or other a priori product instance information necessary for
	// initial deployment to the correct, matching Redfish service. This property
	// shall not be present if the value of the 'ServiceIdentification' property in
	// the 'Manager' resource providing the Redfish service root resource is an
	// empty string or 'null'.
	//
	// Version added: v1.14.0
	ServiceIdentification string
	// ServiceUseNotification shall contain the usage notification message for this
	// service. The value of the property shall contain the value of the
	// 'ServiceUseNotification' property in the 'Manager' resource providing the
	// Redfish service root resource. This property shall not be present if the
	// value of the 'ServiceUseNotification' property in the 'Manager' resource
	// providing the Redfish service root resource is an empty string or 'null'.
	//
	// Version added: v1.20.0
	ServiceUseNotification string

	// UUID shall contain the identifier of the Redfish service instance. If SSDP
	// is used, this value shall contain the same UUID returned in an HTTP '200 OK'
	// response from an SSDP 'M-SEARCH' request during discovery. RFC4122 describes
	// methods to use to create a UUID value. The value should be considered to be
	// opaque. Client software should only treat the overall value as a universally
	// unique identifier and should not interpret any subfields within the UUID.
	UUID string

	// Vendor shall include the name of the manufacturer or vendor represented by
	// this Redfish service. If this property is supported, the vendor name shall
	// not be included in the 'Product' property value.
	//
	// Version added: v1.5.0
	Vendor string
	// contains filtered or unexported fields
}

Service shall represent the root of the Redfish service.

func ServiceRoot

func ServiceRoot(c schemas.Client) (*Service, error)

ServiceRoot will get a Service instance from the service.

func (*Service) AccountService

func (s *Service) AccountService() (*schemas.AccountService, error)

AccountService gets the AccountService linked resource.

func (*Service) AggregationService added in v0.16.0

func (s *Service) AggregationService() (*schemas.AggregationService, error)

AggregationService gets the AggregationService linked resource.

func (*Service) AutomationNodes added in v0.21.0

func (s *Service) AutomationNodes() ([]*schemas.AutomationNode, error)

AutomationNodes gets the AutomationNodes collection.

func (*Service) Cables added in v0.16.0

func (s *Service) Cables() ([]*schemas.Cable, error)

Cables gets the Cables collection.

func (*Service) CertificateService added in v0.16.0

func (s *Service) CertificateService() (*schemas.CertificateService, error)

CertificateService gets the CertificateService linked resource.

func (*Service) Chassis

func (s *Service) Chassis() ([]*schemas.Chassis, error)

Chassis gets the Chassis collection.

func (*Service) ComponentIntegrity added in v0.16.0

func (s *Service) ComponentIntegrity() ([]*schemas.ComponentIntegrity, error)

ComponentIntegrity gets the ComponentIntegrity collection.

func (*Service) CompositionService

func (s *Service) CompositionService() (*schemas.CompositionService, error)

CompositionService gets the CompositionService linked resource.

func (*Service) CreateSession

func (s *Service) CreateSession(username, password string) (*schemas.AuthToken, error)

CreateSession creates a new session and returns the token and id

func (*Service) DeleteSession

func (s *Service) DeleteSession(url string) error

DeleteSession logout the specified session

func (*Service) EventService

func (s *Service) EventService() (*schemas.EventService, error)

EventService gets the EventService linked resource.

func (*Service) Fabrics added in v0.16.0

func (s *Service) Fabrics() ([]*schemas.Fabric, error)

Fabrics gets the Fabrics collection.

func (*Service) Facilities added in v0.16.0

func (s *Service) Facilities() ([]*schemas.Facility, error)

Facilities gets the Facilities collection.

func (*Service) JSONSchemas added in v0.21.0

func (s *Service) JSONSchemas() ([]*schemas.JSONSchemaFile, error)

JSONSchemas gets the JSONSchemas collection.

func (*Service) JobService added in v0.15.0

func (s *Service) JobService() (*schemas.JobService, error)

JobService gets the JobService linked resource.

func (*Service) KeyService added in v0.16.0

func (s *Service) KeyService() (*schemas.KeyService, error)

KeyService gets the KeyService linked resource.

func (*Service) LicenseService added in v0.16.0

func (s *Service) LicenseService() (*schemas.LicenseService, error)

LicenseService gets the LicenseService linked resource.

func (*Service) ManagerProvidingService added in v0.16.0

func (s *Service) ManagerProvidingService() (*schemas.Manager, error)

ManagerProvidingService gets the ManagerProvidingService linked resource.

func (*Service) Managers

func (s *Service) Managers() ([]*schemas.Manager, error)

Managers gets the Managers collection.

func (*Service) NVMeDomains added in v0.21.0

func (s *Service) NVMeDomains() ([]*schemas.NVMeDomain, error)

NVMeDomains gets the NVMeDomains collection.

func (*Service) PowerEquipment added in v0.15.0

func (s *Service) PowerEquipment() (*schemas.PowerEquipment, error)

PowerEquipment gets the PowerEquipment linked resource.

func (*Service) RegisteredClients added in v0.16.0

func (s *Service) RegisteredClients() ([]*schemas.RegisteredClient, error)

RegisteredClients gets the RegisteredClients collection.

func (*Service) Registries added in v0.8.0

func (s *Service) Registries() ([]*schemas.MessageRegistryFile, error)

Registries gets the Registries collection.

func (*Service) ResourceBlocks added in v0.16.0

func (s *Service) ResourceBlocks() ([]*schemas.ResourceBlock, error)

ResourceBlocks gets the ResourceBlocks collection.

func (*Service) ServiceConditions added in v0.16.0

func (s *Service) ServiceConditions() (*schemas.ServiceConditions, error)

ServiceConditions gets the ServiceConditions linked resource.

func (*Service) SessionService added in v0.16.0

func (s *Service) SessionService() (*schemas.SessionService, error)

SessionService gets the SessionService linked resource.

func (*Service) Sessions

func (s *Service) Sessions() (*schemas.Session, error)

Sessions gets the Sessions linked resource.

func (*Service) Storage added in v0.16.0

func (s *Service) Storage() ([]*schemas.Storage, error)

Storage gets the Storage collection.

func (*Service) StorageServices

func (s *Service) StorageServices() ([]*schemas.StorageService, error)

StorageServices gets the StorageServices collection.

func (*Service) StorageSystems

func (s *Service) StorageSystems() ([]*schemas.ComputerSystem, error)

StorageSystems gets the StorageSystems collection.

func (*Service) Systems

func (s *Service) Systems() ([]*schemas.ComputerSystem, error)

Systems gets the Systems collection.

func (*Service) Tasks

func (s *Service) Tasks() (*schemas.TaskService, error)

Tasks gets the Tasks linked resource.

func (*Service) TelemetryService added in v0.16.0

func (s *Service) TelemetryService() (*schemas.TelemetryService, error)

TelemetryService gets the TelemetryService linked resource.

func (*Service) ThermalEquipment added in v0.16.0

func (s *Service) ThermalEquipment() (*schemas.ThermalEquipment, error)

ThermalEquipment gets the ThermalEquipment linked resource.

func (*Service) UnmarshalJSON

func (s *Service) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a Service object from the raw JSON.

func (*Service) UpdateService added in v0.6.0

func (s *Service) UpdateService() (*schemas.UpdateService, error)

UpdateService gets the UpdateService linked resource.

type Session added in v0.6.0

type Session struct {
	ID    string
	Token string
}

Session holds the session ID and auth token needed to identify an authenticated client

Directories

Path Synopsis
oem
ami
hpe
smc
zt

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL