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 ¶
- Variables
- func BadRequestError(c *gin.Context, customMessage string)
- func BasicAuthValidator(expectedUsername, expectedPassword string) gin.HandlerFunc
- func BoolPtr(b bool) *bool
- func ConflictError(c *gin.Context, _, message string)
- func CreateDescription(desc string, lgr logger.Interface) *generated.ComputerSystemCollectionComputerSystemCollection_Description
- func ForbiddenError(c *gin.Context)
- func Int64Ptr(i int64) *int64
- func IntPtr(i int) *int
- func InternalServerError(c *gin.Context, err error)
- func MalformedJSONError(c *gin.Context)
- func MethodNotAllowedError(c *gin.Context)
- func NotFoundError(c *gin.Context, resource string, id ...string)
- func PowerStateConflictError(c *gin.Context, _ string)
- func PropertyMissingError(c *gin.Context, propertyName string)
- func PropertyValueNotInListError(c *gin.Context, propertyName string)
- func ServiceUnavailableError(c *gin.Context, retryAfterSeconds int)
- func SessionAuthMiddleware(sessionUseCase *sessions.UseCase) gin.HandlerFunc
- func SessionConflictError(c *gin.Context)
- func SetRedfishHeaders(c *gin.Context)
- func StringPtr(s string) *string
- func SystemTypePtr(st generated.ComputerSystemSystemType) *generated.ComputerSystemSystemType
- func UnauthorizedError(c *gin.Context)
- type ErrorConfig
- type MessageDetails
- type MessageRegistry
- type ODataService
- type RedfishServer
- func (r *RedfishServer) DeleteRedfishV1SessionServiceSessionsSessionId(c *gin.Context, sessionId string)
- func (s *RedfishServer) GetRedfishV1(c *gin.Context)
- func (s *RedfishServer) GetRedfishV1Metadata(c *gin.Context)
- func (s *RedfishServer) GetRedfishV1Odata(c *gin.Context)
- func (r *RedfishServer) GetRedfishV1SessionService(c *gin.Context)
- func (r *RedfishServer) GetRedfishV1SessionServiceSessions(c *gin.Context)
- func (r *RedfishServer) GetRedfishV1SessionServiceSessionsSessionId(c *gin.Context, sessionId string)
- func (s *RedfishServer) GetRedfishV1Systems(c *gin.Context)
- func (s *RedfishServer) GetRedfishV1SystemsComputerSystemId(c *gin.Context, computerSystemID string)
- func (r *RedfishServer) PatchRedfishV1SessionService(c *gin.Context)
- func (s *RedfishServer) PatchRedfishV1SystemsComputerSystemId(c *gin.Context, computerSystemID string)
- func (r *RedfishServer) PostRedfishV1SessionServiceSessions(c *gin.Context)
- func (s *RedfishServer) PostRedfishV1SystemsComputerSystemIdActionsComputerSystemReset(c *gin.Context, computerSystemID string)
- func (r *RedfishServer) PutRedfishV1SessionService(c *gin.Context)
- type RegistryManager
- type RegistryMessage
Constants ¶
This section is empty.
Variables ¶
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") )
var ErrUnknownErrorType = errors.New("unknown error type")
ErrUnknownErrorType is returned when an unknown error type is requested
Functions ¶
func BadRequestError ¶
BadRequestError returns a Redfish-compliant 400 error
func BasicAuthValidator ¶
func BasicAuthValidator(expectedUsername, expectedPassword string) gin.HandlerFunc
BasicAuthValidator validates HTTP Basic Authentication
func ConflictError ¶
ConflictError returns a Redfish-compliant 409 error
func CreateDescription ¶
func CreateDescription(desc string, lgr logger.Interface) *generated.ComputerSystemCollectionComputerSystemCollection_Description
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 ¶
ForbiddenError returns a Redfish-compliant 403 error for insufficient privileges
func InternalServerError ¶
InternalServerError returns a Redfish-compliant 500 error
func MalformedJSONError ¶
MalformedJSONError returns a Redfish-compliant 400 error for malformed JSON
func MethodNotAllowedError ¶
MethodNotAllowedError returns a Redfish-compliant 405 error
func NotFoundError ¶
NotFoundError returns a Redfish-compliant 404 error
func PowerStateConflictError ¶
PowerStateConflictError returns a Redfish-compliant 409 error for power state conflicts
func PropertyMissingError ¶
PropertyMissingError returns a Redfish-compliant 400 error for missing required property
func PropertyValueNotInListError ¶
PropertyValueNotInListError returns a Redfish-compliant 400 error for invalid property value
func ServiceUnavailableError ¶
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 ¶
SessionConflictError returns a Redfish-compliant 409 error for duplicate sessions
func SetRedfishHeaders ¶
SetRedfishHeaders sets Redfish-compliant headers
func SystemTypePtr ¶
func SystemTypePtr(st generated.ComputerSystemSystemType) *generated.ComputerSystemSystemType
SystemTypePtr creates a pointer to a ComputerSystemSystemType value.
func UnauthorizedError ¶
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)