v1

package
v1.19.2-redfish.preview.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package v1 provides Redfish-compliant error handling utilities.

Package v1 provides Redfish v1 API middleware.

Package v1 provides Redfish message registry lookup functionality.

Package v1 provides Redfish v1 API route setup and configuration.

Package v1 provides Redfish v1 API route setup and configuration.

Package v1 provides Redfish v1 API handlers for SessionService

Package v1 provides HTTP handlers for Redfish Computer Systems endpoints.

Package v1 provides Redfish v1 API handlers for system actions.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRegistryNotFound is returned when a registry is not found
	ErrRegistryNotFound = errors.New("registry not found")
	// ErrMessageNotFound is returned when a message is not found in a registry
	ErrMessageNotFound = errors.New("message not found in registry")
)
View Source
var ErrUnknownErrorType = errors.New("unknown error type")

ErrUnknownErrorType is returned when an unknown error type is requested

Functions

func BadRequestError

func BadRequestError(c *gin.Context, customMessage string)

BadRequestError returns a Redfish-compliant 400 error

func BasicAuthValidator

func BasicAuthValidator(expectedUsername, expectedPassword string) gin.HandlerFunc

BasicAuthValidator validates HTTP Basic Authentication

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr creates a pointer to a bool value.

func ConflictError

func ConflictError(c *gin.Context, _, message string)

ConflictError returns a Redfish-compliant 409 error

func CreateDescription

CreateDescription creates a Description from a string using ResourceDescription. If an error occurs during description creation, it logs the error and returns nil. This allows the calling code to continue with a nil description while ensuring the error is captured for debugging purposes.

func ForbiddenError

func ForbiddenError(c *gin.Context)

ForbiddenError returns a Redfish-compliant 403 error for insufficient privileges

func Int64Ptr

func Int64Ptr(i int64) *int64

Int64Ptr creates a pointer to an int64 value.

func IntPtr

func IntPtr(i int) *int

IntPtr creates a pointer to an int value.

func InternalServerError

func InternalServerError(c *gin.Context, err error)

InternalServerError returns a Redfish-compliant 500 error

func MalformedJSONError

func MalformedJSONError(c *gin.Context)

MalformedJSONError returns a Redfish-compliant 400 error for malformed JSON

func MethodNotAllowedError

func MethodNotAllowedError(c *gin.Context)

MethodNotAllowedError returns a Redfish-compliant 405 error

func NotFoundError

func NotFoundError(c *gin.Context, resource string, id ...string)

NotFoundError returns a Redfish-compliant 404 error

func PowerStateConflictError

func PowerStateConflictError(c *gin.Context, _ string)

PowerStateConflictError returns a Redfish-compliant 409 error for power state conflicts

func PropertyMissingError

func PropertyMissingError(c *gin.Context, propertyName string)

PropertyMissingError returns a Redfish-compliant 400 error for missing required property

func PropertyValueNotInListError

func PropertyValueNotInListError(c *gin.Context, propertyName string)

PropertyValueNotInListError returns a Redfish-compliant 400 error for invalid property value

func ServiceUnavailableError

func ServiceUnavailableError(c *gin.Context, retryAfterSeconds int)

ServiceUnavailableError returns a Redfish-compliant 503 error

func SessionAuthMiddleware

func SessionAuthMiddleware(sessionUseCase *sessions.UseCase) gin.HandlerFunc

SessionAuthMiddleware validates X-Auth-Token header This middleware integrates DMT JWT tokens with Redfish session authentication

func SessionConflictError

func SessionConflictError(c *gin.Context)

SessionConflictError returns a Redfish-compliant 409 error for duplicate sessions

func SetRedfishHeaders

func SetRedfishHeaders(c *gin.Context)

SetRedfishHeaders sets Redfish-compliant headers

func StringPtr

func StringPtr(s string) *string

StringPtr creates a pointer to a string value.

func SystemTypePtr

SystemTypePtr creates a pointer to a ComputerSystemSystemType value.

func UnauthorizedError

func UnauthorizedError(c *gin.Context)

UnauthorizedError returns a Redfish-compliant 401 error

Types

type ErrorConfig

type ErrorConfig struct {
	RegistryKey    string
	StatusCode     int
	CustomMessage  string
	OverrideMsg    bool
	RetryAfter     int
	MessageOveride func(string) string
}

ErrorConfig defines configuration for a specific error type

type MessageDetails

type MessageDetails struct {
	Description     string   `json:"Description"`
	Message         string   `json:"Message"`
	MessageSeverity string   `json:"MessageSeverity"`
	NumberOfArgs    int      `json:"NumberOfArgs"`
	ParamTypes      []string `json:"ParamTypes,omitempty"`
	Resolution      string   `json:"Resolution"`
	ClearingLogic   *struct {
		ClearsIf      string   `json:"ClearsIf,omitempty"`
		ClearsAll     bool     `json:"ClearsAll,omitempty"`
		ClearsMessage []string `json:"ClearsMessage,omitempty"`
	} `json:"ClearingLogic,omitempty"`
	Deprecated string `json:"Deprecated,omitempty"`
}

MessageDetails contains the details of a specific message in the registry

type MessageRegistry

type MessageRegistry struct {
	ID              string                    `json:"Id"`
	Name            string                    `json:"Name"`
	Language        string                    `json:"Language"`
	Description     string                    `json:"Description"`
	RegistryPrefix  string                    `json:"RegistryPrefix"`
	RegistryVersion string                    `json:"RegistryVersion"`
	OwningEntity    string                    `json:"OwningEntity"`
	Messages        map[string]MessageDetails `json:"Messages"`
}

MessageRegistry represents a Redfish message registry

type ODataService

type ODataService struct {
	Name string `json:"name"`
	Kind string `json:"kind"`
	URL  string `json:"url"`
}

ODataService represents a Redfish service in the OData service document

func ExtractServicesFromOpenAPIData

func ExtractServicesFromOpenAPIData(data []byte) ([]ODataService, error)

GetRedfishV1 returns the service root ExtractServicesFromOpenAPIData parses the embedded OpenAPI spec data and extracts all top-level Redfish services Automatically discovers services from /redfish/v1/* paths in the spec

func GetDefaultServices

func GetDefaultServices() []ODataService

GetDefaultServices returns the standard Redfish services as fallback

type RedfishServer

type RedfishServer struct {
	ComputerSystemUC *usecase.ComputerSystemUseCase
	SessionUC        *sessions.UseCase
	Config           *dmtconfig.Config
	Logger           logger.Interface
	Services         []ODataService // Cached OData services loaded from OpenAPI spec
}

RedfishServer implements the Redfish API handlers and delegates operations to specialized handlers

func (*RedfishServer) DeleteRedfishV1SessionServiceSessionsSessionId

func (r *RedfishServer) DeleteRedfishV1SessionServiceSessionsSessionId(c *gin.Context, sessionId string)

DeleteRedfishV1SessionServiceSessionsSessionId handles DELETE /redfish/v1/SessionService/Sessions/{SessionId}.

func (*RedfishServer) GetRedfishV1

func (s *RedfishServer) GetRedfishV1(c *gin.Context)

Path: GET /redfish/v1 Spec: Redfish ServiceRoot.v1_19_0 This is the entry point for the Redfish API, providing links to all available resources. Per Redfish specification, this endpoint must be accessible without authentication.

func (*RedfishServer) GetRedfishV1Metadata

func (s *RedfishServer) GetRedfishV1Metadata(c *gin.Context)

GetRedfishV1Metadata returns the OData CSDL metadata document describing the service's data model. Path: GET /redfish/v1/$metadata Spec: OData CSDL v4.0 - Redfish specification mandates this endpoint is accessible without authentication.

func (*RedfishServer) GetRedfishV1Odata

func (s *RedfishServer) GetRedfishV1Odata(c *gin.Context)

GetRedfishV1Odata returns the OData service document listing available Redfish services Path: GET /redfish/v1/odata Spec: OData v4.0 Service Document - DMTF Redfish compliant (services auto-discovered from OpenAPI spec)

func (*RedfishServer) GetRedfishV1SessionService

func (r *RedfishServer) GetRedfishV1SessionService(c *gin.Context)

GetRedfishV1SessionService handles GET /redfish/v1/SessionService

func (*RedfishServer) GetRedfishV1SessionServiceSessions

func (r *RedfishServer) GetRedfishV1SessionServiceSessions(c *gin.Context)

GetRedfishV1SessionServiceSessions handles GET /redfish/v1/SessionService/Sessions

func (*RedfishServer) GetRedfishV1SessionServiceSessionsSessionId

func (r *RedfishServer) GetRedfishV1SessionServiceSessionsSessionId(c *gin.Context, sessionId string)

GetRedfishV1SessionServiceSessionsSessionId handles GET /redfish/v1/SessionService/Sessions/{SessionId}.

func (*RedfishServer) GetRedfishV1Systems

func (s *RedfishServer) GetRedfishV1Systems(c *gin.Context)

GetRedfishV1Systems handles GET requests for the systems collection

func (*RedfishServer) GetRedfishV1SystemsComputerSystemId

func (s *RedfishServer) GetRedfishV1SystemsComputerSystemId(c *gin.Context, computerSystemID string)

GetRedfishV1SystemsComputerSystemId handles GET requests for individual computer systems. Validates system ID parameter before retrieval to prevent injection attacks.

func (*RedfishServer) PatchRedfishV1SessionService

func (r *RedfishServer) PatchRedfishV1SessionService(c *gin.Context)

PatchRedfishV1SessionService handles PATCH /redfish/v1/SessionService

func (*RedfishServer) PatchRedfishV1SystemsComputerSystemId

func (s *RedfishServer) PatchRedfishV1SystemsComputerSystemId(c *gin.Context, computerSystemID string)

PatchRedfishV1SystemsComputerSystemId handles PATCH requests to modify a ComputerSystem resource. This endpoint supports updating boot settings and other system properties.

func (*RedfishServer) PostRedfishV1SessionServiceSessions

func (r *RedfishServer) PostRedfishV1SessionServiceSessions(c *gin.Context)

PostRedfishV1SessionServiceSessions handles POST /redfish/v1/SessionService/Sessions

func (*RedfishServer) PostRedfishV1SystemsComputerSystemIdActionsComputerSystemReset

func (s *RedfishServer) PostRedfishV1SystemsComputerSystemIdActionsComputerSystemReset(c *gin.Context, computerSystemID string)

PostRedfishV1SystemsComputerSystemIdActionsComputerSystemReset handles reset action for a computer system. Validates system ID and reset type before executing power state change.

func (*RedfishServer) PutRedfishV1SessionService

func (r *RedfishServer) PutRedfishV1SessionService(c *gin.Context)

PutRedfishV1SessionService handles PUT /redfish/v1/SessionService

type RegistryManager

type RegistryManager struct {
	// contains filtered or unexported fields
}

RegistryManager manages message registries

func GetRegistryManager

func GetRegistryManager() *RegistryManager

GetRegistryManager returns the singleton registry manager instance

func (*RegistryManager) LookupMessage

func (rm *RegistryManager) LookupMessage(registryName, messageKey string) (*RegistryMessage, error)

LookupMessage looks up a message from the registry

type RegistryMessage

type RegistryMessage struct {
	MessageID       string
	Message         string
	Severity        string
	Resolution      string
	RegistryPrefix  string
	RegistryVersion string
	NumberOfArgs    int
	ParamTypes      []string
}

RegistryMessage contains the formatted message details from registry

func (*RegistryMessage) FormatMessage

func (rm *RegistryMessage) FormatMessage(args ...interface{}) string

FormatMessage formats the message with the provided arguments Converts DMTF placeholders (%1, %2, etc.) to Go format specifiers (%v)

Jump to

Keyboard shortcuts

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