redfish

package module
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: BSD-3-Clause Imports: 36 Imported by: 3 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

redfish

Go Reference License CI

Part of go-redfish: Go libraries for the Redfish API of a server's BMC. Documentation: https://go-redfish.github.io/docs/.

A small, self-contained Go client for the DMTF Redfish API of a server's BMC, to read what a node consumes: the energy counter of its chassis (EnvironmentMetrics.EnergykWh), else its power. Standard library only (the CLI adds cobra).

c, err := redfish.New(redfish.Config{
    BaseURL:     "https://bmc-01.example.org",
    Credentials: redfish.Static{User: "monitor", Password: pw}, // or your own Credentials
    CAFile:      "/etc/site-ca.pem",
})
if err != nil { ... }
r, err := c.Read(ctx)
if err == nil && r.EnergyKWh != nil {
    fmt.Printf("%s: %.3f kWh since the BMC counted\n", r.Chassis, *r.EnergyKWh)
}

Read discovers the service once (service root, Chassis collection, each chassis' EnvironmentMetrics and Power links) and remembers the links. With Config.MetricsPath it reads that resource and nothing else. Config.Session logs in once and sends X-Auth-Token (Close logs out); otherwise HTTP Basic.

A Redfish client, and a CLI (v0.3.0)

Beyond reading a node's consumption, go-redfish is becoming a complete Redfish client with a CLI to try it: the goal is parity with the Ansible modules redfish_command, redfish_config and redfish_info (community.general) and with DMTF redfishtool, tracked row by row in PARITY.md.

v0.3.0 brings the generic layer and the tools to test it:

  • Client.Do, Get, Patch, Post, Delete: any operation on any path of the service, with If-Match on the entity tag a read returned (412 when it changed), a 202 answer's task monitor (Response.Location, RetryAfter, Client.WaitTask), and every error decoded: a non-2xx answer is a *StatusError carrying the error object's code and message and its @Message.ExtendedInfo messages (ParseError, fuzzed). Paths are /redfish/... only; a header cannot carry another credential; bodies are bounded.
  • Sessions: Login, Session() (the token and the Session resource) and Config.Token/SessionURI to resume one; Close logs out.
  • mockbmc: the DMTF public-rackmount1 mockup (DSP2043, BSD-3-Clause, vendored with its licence) behind an http.Handler that is stateful enough to be driven like a BMC: authentication (Basic or token), sessions, ETags and 412, PATCH, creating and deleting members, ComputerSystem.Reset checked against its AllowableValues, a SimpleUpdate task with its monitor, and Redfish errors with ExtendedInfo.
  • cmd/redfish, a cobra CLI (go install github.com/go-redfish/redfish/cmd/redfish@latest):
redfish mock serve --ca-out /tmp/mock-ca.pem          # prints endpoint, user admin / password "password"
echo -n password > ~/.mock-pw && chmod 600 ~/.mock-pw
redfish --endpoint https://127.0.0.1:PORT --user admin --password-file ~/.mock-pw --ca-file /tmp/mock-ca.pem \
        raw get /redfish/v1/Systems -o table
redfish ... session login      # the token goes to a 0600 file under the config directory, never to the screen
redfish --endpoint ... --ca-file ... --session raw get /redfish/v1/Chassis
redfish ... session login --session-store keychain:redfish/bmc1   # the token goes to the Keychain, not to the file
redfish ... session logout     # DELETE at the BMC, then the entry and the file are removed
redfish ... raw patch /redfish/v1/Systems/1 --data '{"AssetTag":"rack-7"}' --if-match 'W/"..."'

Flags: --endpoint --user --password-file --ca-file --insecure --session --timeout -o json|table. There is no password flag and no environment variable for a secret; the password file must be mode 0600. TLS is verified by default; --insecure is explicit and warns on stderr. raw get|patch|put|post|delete|head cover redfishtool's raw, and root, versions, odata, metadata are raw get of their paths.

Secret references (no plaintext secret on disk). Every --X-file secret option has an --X-from REF sibling (--password-from, --new-password-from, --image-password-from, --key-from, --p12-password-from, --challenge-password-from, --headers-from, redfish mock serve --mock-password-from), exclusive with its -file and -stdin siblings (the old options keep working). A reference holds no secret, so it may sit in argv or a script; the CLI (not the library, which stays standard-library only) resolves it with go-authn/secretsource: systemd-creds:NAME (a systemd credential, read from $CREDENTIALS_DIRECTORY), keychain:SERVICE/ACCOUNT, secretservice:SERVICE/ACCOUNT, keepassxc:URL or file:PATH (mode 0600). The BMC password is fetched each time it is needed and wiped after. A secret over 4096 bytes (secretsource's limit) is refused with a message that names the way out: for a PEM private key larger than that, keep using --key-file or --key-stdin. An error never holds the secret, only the reference. With systemd:

# systemd-creds encrypt --name=bmc-admin - /etc/credstore.encrypted/bmc-admin   (once, secret on stdin)
# unit:  LoadCredentialEncrypted=bmc-admin:/etc/credstore.encrypted/bmc-admin
redfish --endpoint https://bmc.example --user admin --password-from systemd-creds:bmc-admin raw get /redfish/v1/

The session token in a secret manager. session login --session-store REF (keychain:SERVICE/ACCOUNT, secretservice:SERVICE/ACCOUNT or keepassxc:URL; file: and systemd-creds: cannot be written and are refused before the BMC is contacted) stores the token under REF (a new login replaces it) and writes the 0600 session file with the endpoint, the session URI and REF, and no token: it never touches the disk. The commands with --session read it back from the manager (bounded, wiped after use, never printed). session logout ends the BMC session, then deletes the entry and the file; they go even when the BMC call fails, and a failed delete is reported after the file is removed. session clear --session does the same. A KeePassXC delete asks you to confirm and moves the entry to the Recycle Bin. If the store fails after the login, the BMC session is closed and nothing is written. Without the option, the token stays in the 0600 file as before, and old session files still load; a file holding both a token and a reference is refused.

The BMC is not trusted with the terminal. Everything it sends that reaches stdout or stderr (values, property names, error messages, a body that is not JSON, event text, the session location) has its control characters replaced by ? in -o table and the error text, or written as \uXXXX in -o json: C0 (a tab and a newline stay in multi-line text), DEL, C1 (U+0080 to U+009F) and the bidirectional controls (U+202A to U+202E, U+2066 to U+2069, U+200E, U+200F). A session Location with a control character or a . or .. segment is refused by session login (v0.15.1). The session file and the password file are opened once, never through a symlink, and checked on the open descriptor (regular file, mode 0600, bounded size); the session file is written to a random temporary name created exclusively, then renamed.

Systems (v0.4.0)

The Systems commands of the three Ansible modules, ported from community.general's redfish_utils (the oracle, commit 33e521d6) and checked against both mock trees:

  • Library (systems.go): ResolveSystem/ResolveChassis (the one resource, or the one named by id, else ErrAmbiguous); SystemPower/ManagePower (the ResetType the service allows, from its ActionInfo or AllowableValues, nothing sent when the state is already the one asked); SetBootOverride, BootOverrideOf, BootOrder, SetBootOrder, SetDefaultBootOrder; BiosAttributes, SetBiosAttributes (through the @Redfish.Settings object, with an optional ApplyTime), VerifyBiosAttributes, ResetBios, BiosRegistry; SetSecureBoot; PowerRestorePolicy/SetPowerRestorePolicy; SetIndicatorLED, SetAssetTag; SystemInventory, CPUInventory, MemoryInventory, NICInventory, PSUInventory, SystemHealthReport. A change is made with PatchChecked, which compares the payload with the resource first (CheckPayload): an unchanged state is reported as such (Outcome.Changed false), a property the resource lacks is ErrUnsupported. ParseActionInfo, CheckPayload and Pick are fuzzed.
  • CLI: redfish systems [--id ID] ... and redfish chassis [--id ID] led ...:
redfish ... systems list
redfish ... systems power PowerForceOff                 # PowerOn, PowerReboot, PowerCycle, ...
redfish ... systems boot-override set Pxe --once        # or --continuous; boot-override get, disable
redfish ... systems boot-order get                      # boot-order set Boot0002 Boot0001, boot-order default
redfish ... systems bios set --attr ProcTurboMode=Disabled --apply-time OnReset   # bios get, verify, reset, registry
redfish ... systems secure-boot enable                  # or disable
redfish ... systems power-restore-policy set AlwaysOn   # or get
redfish ... systems led blink                           # on, off, blink; chassis led works the same
redfish ... systems asset-tag rack-7
redfish ... systems inventory cpu                       # system, cpu, memory, nic, psu
redfish ... systems health

With several systems and no --id, the command fails and lists them (ErrAmbiguous).

  • Second mock tree: mockbmc.Options{Tree: mockbmc.TreeEmulator} (redfish mock serve --tree emulator-1u) serves the DMTF Redfish-Interface-Emulator 1U mockup beside the default public-rackmount1, so that no command is tuned to one vendor tree; every Systems test runs on both.

Chassis (v0.5.0)

The chassis half of redfish_info (GetChassisInventory, GetFanInventory, GetChassisPower, GetChassisThermals, GetPsuInventory, GetHealthReport, GetHPEThermalConfig, GetHPEFanPercentMin), ported from community.general's redfish_utils and run against both mock trees, plus the resources that replace the deprecated Power and Thermal:

  • Library (chassis.go): ChassisInventory, FanInventory, ChassisPower, ChassisThermals, ChassisHealthReport(s), HPEThermalConfig, HPEFanPercentMin (a chassis list, or every chassis when none is given, as the oracle does); ChassisSensors (the Sensor resources), ChassisPowerSubsystem (capacity, allocation, the power supplies present), ChassisThermalSubsystem (fans and ThermalMetrics) and ChassisEnvironmentMetrics. SetIndicatorLED serves chassis as well as systems. The reads of Meter and Read are unchanged.
  • CLI: redfish chassis [--id ID] ...:
redfish ... chassis list
redfish ... chassis inventory                 # fans, power, thermals, psu, health, hpe thermal-config, hpe fan-percent-min
redfish ... chassis sensors                   # power-subsystem, thermal-subsystem, metrics
redfish ... chassis led blink                 # on, off, blink
redfish ... -o table chassis thermals         # a list is a table: one row per element

The reading commands cover every chassis without --id; led, sensors, power-subsystem, thermal-subsystem and metrics act on one chassis and fail with ErrAmbiguous when there are several and none is named. -o table renders a list of objects as a table (it printed a Go slice in v0.4.0).

Managers (v0.6.0)

Every Manager command of redfish_command, redfish_config and redfish_info, and the VirtualMedia commands that the Systems category shares (VirtualMediaInsert, VirtualMediaEject, GetVirtualMedia), ported from community.general's redfish_utils and run against both mock trees (the rackmount tree keeps its virtual media on the system, the emulator tree on the manager; a mock ClearLog, InsertMedia, EjectMedia and ResetToDefaults act on the resources):

  • Library (managers.go): ManagerURIs, ResolveManager, EachManager, ManagerInventory, ManagerHealthReport, ManagerNICInventory; ManagerPower (GracefulRestart, PowerOn... with the ResetType the service allows) and WaitAvailable; ManagerResetToDefaults; NetworkProtocols, SetNetworkProtocols (NetworkProtocolPayload checks the services, states and ports, as the module does) and SetNTP; ManagerDateTime, SetManagerDateTime; ServiceIdentification, SetServiceIdentification; SetManagerNIC; HostInterfaces, SetHostInterface; Logs and ClearLogs (a manager, a system or a chassis); VirtualMedia, VirtualMediaInsert and VirtualMediaEject (a system or a manager: the action when the slot has it, else a PATCH; the HPE and Supermicro workarounds of the oracle). ParseLogEntries, NetworkProtocolPayload and the manager reads are fuzzed.
  • CLI: redfish managers [--id ID] ...; virtual media and logs wherever the service puts them:
redfish ... managers list
redfish ... managers inventory                  # health, nic get, service-id get, datetime get
redfish ... managers power GracefulRestart --wait   # PowerOn, PowerForceOff, PowerReboot...; --wait blocks until the BMC answers
redfish ... managers reset-to-defaults PreserveNetwork
redfish ... managers network-protocols set --set SSH.ProtocolEnabled=off --set SSH.Port=2222
redfish ... managers ntp set --server 0.pool.ntp.org --enable
redfish ... managers datetime set --time 2026-11-05T17:00:00+01:00 --offset +01:00
redfish ... managers nic set --address 192.0.2.9 --json '{"IPv4StaticAddresses":{"Address":"192.0.2.9"}}'
redfish ... managers host-interface set --interface 1 --set InterfaceEnabled=false
redfish ... managers service-id set rack-7
redfish ... managers logs --max 20              # logs clear; also systems logs and chassis logs
redfish ... managers virtual-media insert --image https://host/os.iso --media-type CD   # get, eject; also systems virtual-media

inventory, health and nic get cover every manager without --id; the others act on one manager and fail with ErrAmbiguous when there are several and none is named. A password for an image is read from --image-password-file (mode 0600), never given on the command line. chassis led is covered by its own tests (TestChassisIndicatorLED, TestChassisLedCommands).

Accounts and sessions (v0.7.0)

The Accounts commands of redfish_command (AddUser, DeleteUser, EnableUser, DisableUser, UpdateUserRole, UpdateUserPassword, UpdateUserName, UpdateUserAccountTypes, UpdateAccountServiceProperties), ListUsers and GetAccountServiceConfig of redfish_info, and the Sessions commands (ClearSessions, SetSessionService, GetSessions), ported from community.general's redfish_utils:

  • Library (accounts.go): ListUsers, AccountServiceConfig, Roles, AddUser, DeleteUser, EnableUser, DisableUser, UpdateUserRole, UpdateUserPassword, UpdateUserName, UpdateUserAccountTypes, UpdateAccountServiceProperties, GetSessions, ClearSessions, SetSessionService, and PasswordChangeURI (the account a Base.1.x.PasswordChangeRequired refusal names). A service with a fixed number of accounts is handled as the oracle does: no POST in the Allow header (or a 405) is an empty slot changed by a PATCH, no DELETE is a PATCH that empties the account. A password is a Secret: it prints as [redacted] with every fmt verb, as JSON and in log/slog, and an error from a service that repeats it is redacted (text and fields).
  • CLI: redfish accounts list|roles|add|delete|enable|disable|password|role|rename|types|config [set] and redfish session list|clear|config:
redfish ... accounts list
redfish ... accounts add bob --role Operator --new-password-file ~/.bob-pw     # or --new-password-stdin
printf '%s\n' "$NEWPW" | redfish ... accounts password bob --new-password-stdin
redfish ... accounts --id 3 rename carol        # an account is a USERNAME, or --id (its Id)
redfish ... accounts config set --set MinPasswordLength=12
redfish ... session list ; redfish ... session clear ; redfish ... session config --set SessionTimeout=600

The password of an account comes from a file of mode 0600 or from the standard input, never from a flag or the environment, and is never printed. session clear ends the session it runs with last.

  • Mock: account create, PATCH (rename, enable, disable, role, password) and delete under the AccountService rules (unique names, a role of the service, MinPasswordLength, a disabled account cannot log in, PasswordChangeRequired answers 403 with the Base message), the Allow header, and Options.FixedSlots / OmitAllow for the services with a fixed number of accounts.
  • Departures from the oracle: the Password of an account is write-only (it reads back null or is absent), so it is never compared with the resource (the oracle's property check would refuse a service that omits it) and a password given is always sent; the Accounts collection is also found under Links.Accounts (the DMTF emulator's older AccountService); an account member that cannot be read is skipped as in the oracle, but an authentication failure is not; the Sessions collection falls back to the default path when the root has no Links.Sessions; ClearSessions reads the members, not Members@odata.count, and ends its own session last.

UpdateService (v0.8.0)

The Update commands of redfish_command (SimpleUpdate, MultipartHTTPPushUpdate, PerformRequestedOperations) and redfish_info (GetFirmwareInventory, GetSoftwareInventory, GetFirmwareUpdateCapabilities, GetUpdateStatus), and redfishtool's -N/--NonBlocking:

  • Library (update.go): SimpleUpdate, MultipartHTTPPushUpdate, UpdateStatus, WaitUpdate, PerformRequestedOperations, FirmwareInventory, SoftwareInventory, FirmwareUpdateCapabilities, and the pure decoders ParseUpdateStatus, ParseUpdateCapabilities, CheckImageURI, MultipartFrame. An update that starts a task returns its monitor (Outcome.Monitor, UpdateStatus.Handle); WaitUpdate follows it.
  • CLI: redfish update simple|push|status|operations|inventory [--software]|capabilities. simple, push and status take --watch (with --poll, --watch-timeout) to follow the task monitor, with the progress on stderr; without it the monitor is returned and not awaited.
redfish ... update capabilities ; redfish ... update inventory ; redfish ... update inventory --software
redfish ... update simple --image https://images.example/bios.bin --protocol HTTPS --image-password-file ~/.img-pw --watch
redfish ... update push --file bmc-fw.bin --apply-time OnReset --max-size 1073741824 --watch
redfish ... update status /redfish/v1/TaskService/Tasks/1 --watch ; redfish ... update operations /redfish/v1/TaskService/Tasks/1
  • Security: push streams the image from the file (a known Content-Length, never read whole), accepts only a regular file of at most --max-size (default 4 GiB; a larger file is ErrImageTooLarge before anything is sent) and bounds the upload by --upload-timeout; the names of extra parts are validated against header injection. The password of the image server is a Secret read from a 0600 file or the standard input, never a flag or the environment, redacted from errors and from the messages of the result; an ImageURI that holds a password, or whose scheme is not one of the service's TransferProtocol values, is refused, and the protocol, targets and apply time are checked against the service's allowable values. The decoders are fuzzed (FuzzOperationResults, FuzzUpdateReads, FuzzCheckImageURI, FuzzMultipartFrame).
  • Mock: MultipartHttpPushUri takes a bounded multipart upload (Options.MaxUpload, 413 above), a task, a firmware and a software inventory, a Targets list for SimpleUpdate, and Options.ResetRequired (a Base.ResetRequired message in the task). The emulator tree has no UpdateService.
  • Departures from the oracle: a 202 whose body is not a Task is New and keeps its handle (the oracle calls it Completed and drops it); a ResetRequired reset is posted to the resource's Reset action when it has one (the oracle posts to the resource itself, which services answer with 405) and only for a resource of the service; a ResetRequired or job message without its arguments is ignored (the oracle raises); the top-level @Message.ExtendedInfo of a success is read as well as the error object's; the oracle's "ret": "False" strings of GetFirmwareUpdateCapabilities are errors; an ImageURI is validated and a custom part gets text/plain when no media type is given (the oracle raises); the oracle's "NSF" in the default protocol list is kept.

Storage (v0.9.0)

The last five rows of PARITY.md: GetStorageControllerInventory, GetDiskInventory and GetVolumeInventory of redfish_info, CreateVolume and DeleteVolumes of redfish_config, and redfishtool's SimpleStorage. Parity: 99/99 rows done (no N/A, no todo; parity_test.go now fails on a todo row).

  • Library (storage.go): StorageControllerInventory, DiskInventory, VolumeInventory, CreateVolume, DeleteVolumes, and the pure ParseController, ParseDrive, ParseVolume, BuildVolumePayload, CheckVolumeRequest. A 202 answer is returned as task monitors (VolumeResult: an Outcome and Monitors, one per request that answered 202).
  • CLI: redfish storage controllers|disks|volumes and redfish storage volume create|delete, with --id for the system. disks reads Storage, else the Devices of SimpleStorage.
redfish ... storage controllers ; redfish ... storage disks ; redfish ... storage volumes
redfish ... storage volume create --storage RAID1 --raid-type RAID1 --drive /redfish/v1/Systems/1/Storage/RAID1/Drives/Disk1 --drive /redfish/v1/Systems/1/Storage/RAID1/Drives/Disk2
redfish ... storage volume delete --storage RAID1 --dry-run Vol1 ; redfish ... storage volume delete --storage RAID1 Vol1
  • Safety: volume delete destroys data. Every volume is named by its Id: there is no delete-all (the oracle has none either); the paths to delete are printed on stderr before the first DELETE, --dry-run deletes nothing, and when one name is not a volume of the subsystem nothing is deleted. --delete-none-volumes of create (the oracle's storage_none_volume_deletion) is never implied and prints what it deletes first. Decoders and validators are fuzzed (FuzzStorageReads, FuzzVolumeRequest); reads are bounded (1024 resources a command); a drive must be a path of the service.
  • Mock: neither mockup has a Storage resource, so both trees get Storage/RAID1 (a Controllers collection with SupportedRAIDTypes RAID0/1/5, four drives, volumes Vol1 and Vol0 of RAIDType None) and Storage/AHCI (the deprecated StorageControllers array, one drive). A POST to a Volumes collection checks the RAID type, that the drives belong to the subsystem and are free, and their number; 201, or 202 with Options.AsyncVolumes. Options.SimpleStorageOnly leaves Storage out.
  • Departures from the oracle: the RAID type and the drives are checked against SupportedRAIDTypes and the subsystem's Drives before the POST (the oracle leaves it to the service); DeleteVolumes with no Id is an error and with an unknown Id deletes nothing (the oracle skips it and reports the volumes "deleted"); an empty storage_subsystem_id is the only subsystem rather than an error; a drive or volume that cannot be read is an error (the oracle raises); a missing Name or Id of a controller gets the oracle's "Controller N" name instead of a KeyError; a system with both Storage and SimpleStorage is read through Storage only, which is what the oracle's code does in effect (it tests the SimpleStorage link on a variable the Storage branch has overwritten).

Events (v0.10.0)

Beyond the Ansible modules, which have no eventing: the EventService, its subscriptions, the test event and the Server-Sent Events stream. There is no Ansible oracle; the reference is the specification (DSP0266 1.23.0 12.1, 12.5 and 13.7; the DSP8010 schemas EventService 1.12.0, EventDestination 1.17.1 and Event 1.14.0; WHATWG HTML 9.2 for the stream format). Each capability is a row of the section "Beyond the Ansible modules" of PARITY.md.

  • Library (events.go, events_stream.go, sse.go): EventService, Subscriptions, Subscription, Subscribe, Unsubscribe, SubmitTestEvent, CheckDestination; Events(ctx, filter) and EventsWith return an EventStream (a channel C of Event, and Err() once it is closed); SSEReader and ParseEvent are the pure parser and decoder. A service without the feature gives ErrUnsupported.
  • CLI: redfish events status|subscriptions|subscribe|unsubscribe|test|listen.
redfish ... events status
redfish ... events subscribe --destination https://receiver.example/events --registry-prefix Base --headers-file ~/.receiver-headers
redfish ... events test --message-id Contoso.1.0.TempAssert --message "hot"
redfish ... events listen --filter "RegistryPrefix eq 'Contoso'" -o json     # Ctrl-C ends it
  • Safety: a subscription Destination must be https, without credentials, query or fragment. The HTTP headers the service sends to the receiver (an Authorization) are credentials: they come from a 0600 file or the standard input, never a flag, and are redacted from errors. The stream is authenticated like any request, over https; a line or an event above 1 MiB (or --max-line, --max-event-bytes) ends it with ErrEventTooLarge, nothing grows. It reconnects with Last-Event-ID only after a broken connection and a bounded number of times, never after a clean end by the service (which closes the connection when its subscription is deleted). The parser, the event decoder, the destination check and the headers file are fuzzed (FuzzSSEReader, FuzzParseEvent, FuzzCheckDestination, FuzzReadHeaders).
  • Mock: the Subscriptions collection (POST 201 with Location, DELETE), SubmitTestEvent, and an SSE endpoint (ServerSentEventUri) with the $filter subset documented in mockbmc/events.go, ids, history and Last-Event-ID. The emulator tree has the old EventService 1.0 (no SSE, no SubmitTestEvent). The mock does not push to destinations.
  • Not implemented: push receivers, non-Redfish protocols, and the other subscription properties (see PARITY.md).

Certificates (v0.11.0)

Beyond the Ansible modules, which do not manage certificates: the CertificateService and the certificate collections it manages. There is no Ansible oracle; the reference is the specification (DSP0266 1.23.0 9.9.13, 13.1.3 and 13.2; the DSP8010 schemas CertificateService 1.2.2, Certificate 1.11.0, CertificateLocations 1.0.4 and CertificateCollection). Each capability is a row of the section "Beyond the Ansible modules" of PARITY.md.

  • Library (certs.go): CertificateService, CertificateLocations, Certificate, Certificates (the PEM string is decoded with crypto/x509: subject, issuer, validity, key, usages, SANs, fingerprint: ParseX509), GenerateCSR (the answer is decoded as PKCS#10: ParseCSR, ParseCSRResponse), InstallCertificate (POST to a collection), ReplaceCertificate, DeleteCertificate, RekeyCertificate and RenewCertificate. The actions are checked against the ActionInfo or the AllowableValues of the service and the formats of the collection against @Redfish.SupportedCertificates. A service without the feature gives ErrUnsupported.
  • CLI: redfish certs status|list|show|csr|replace|install|delete|rekey|renew.
redfish ... certs list
redfish ... certs show /redfish/v1/Managers/BMC/NetworkProtocol/HTTPS/Certificates/1      # + the parsed x509 fields
redfish ... certs csr --collection /redfish/v1/Managers/BMC/NetworkProtocol/HTTPS/Certificates \
        --common-name bmc1.example.org --alt-name bmc1 --country FR --out bmc1.csr
redfish ... certs replace /redfish/v1/Managers/BMC/NetworkProtocol/HTTPS/Certificates/1 --cert-file bmc1.pem
redfish ... certs replace ID --cert-file other.pem --key-file other.key       # a certificate the service has no key for
  • Safety: a private key the schema lets the client send (as part of the certificate string, for a certificate that was not made from a CSR of the service) comes only from a 0600 file (--key-file) or the standard input (--key-stdin), is a Secret, is checked against the certificate before anything is sent (one block, not encrypted, the certificate's public key), is never printed and is redacted from errors; a CSR or certificate answer that carries a key is refused or stripped. Strings are bounded (certificate 64 KiB, key 16 KiB, a chain of 16, 256 certificates). The decoders and the key reader are fuzzed (FuzzParseX509, FuzzParseCSRResponse, FuzzParseCertificateLocations, FuzzParseCertificateResource, FuzzReadKey).
  • Mock: a real self-signed certificate in the HTTPS collection, CertificateLocations kept up to date, POST to a certificate collection (decoded with crypto/x509, key checked, 400 when the service holds no key), DELETE, GenerateCSR, Rekey and Renew that return real PKCS#10 requests and keep the key, and ReplaceCertificate that gives the new certificate its own path. The emulator tree has no CertificateService.
  • Not implemented: decoding PKCS7 and PKCS12, automatic enrollment, ForceAutomaticRenew, SPDM and UEFI properties, encrypted keys (see PARITY.md).

Query parameters (v0.12.0)

Beyond the Ansible modules, which send none: the query parameters of DSP0266 1.23.0 7.3, to cut the number of requests to a BMC. The reference is the specification (7.3.1 overview, 7.3.2 $expand, 7.3.3 $select, 7.3.4 $filter, 9.6.10 count; the ProtocolFeaturesSupported of the ServiceRoot 1.22.0 schema, DSP8010 2025.4). A client may only use a parameter the service advertises there, so the root is read once per client (Client.ProtocolFeatures) and a parameter that is not advertised is refused with ErrUnsupported, naming the feature, and never sent. Each capability is a row of the section "Beyond the Ansible modules" of PARITY.md.

  • Library (query.go, expand.go): ProtocolFeatures, Query{Expand, Select, Top, Skip, Only, Excerpt, Filter}, Query.Encode, Client.GetWith. Values are validated (ErrQuery): $select is names joined by slashes, $filter is parsed with the grammar of 7.3.4 (comparison, and, or, not, parentheses, literals), only is never combined with another parameter, and a value is percent-encoded so that it cannot add a parameter. The read paths that were N+1 now send $expand=. when the root advertises it (CPUInventory, MemoryInventory, NICInventory, ChassisSensors, the power and thermal subsystems, ChassisInventory, FirmwareInventory, SoftwareInventory, ListUsers, Roles, Subscriptions; since v0.13.0 also StorageControllerInventory, DiskInventory, VolumeInventory, HostInterfaces, VirtualMedia, the LogService resources and the entries of Logs, and the collections the health reports walk), and read the members one by one when it does not, when Config.NoExpand is set, or when the expanded answer fails (501, 507, too large): the answers are the same. Against the mock, ChassisSensors takes 2 requests instead of 43, CPUInventory 2 instead of 5, SystemHealthReport 11 instead of 20, VolumeInventory 6 instead of 10.
  • CLI: redfish raw get PATH --expand N [--expand-kind nolinks|links|all] --select A,B --top N --skip N --only --excerpt --filter EXPR, each refused when it is not advertised; the global --no-expand forces the per-member reads of the inventory and listing commands (the default is to expand when advertised).
  • Bounds: an expanded answer may be larger than a plain one, so a request with $expand is bounded by MaxExpandedBody (8 MiB), never unbounded; every other body stays bounded by MaxBody (1 MiB).
  • Mock: the rackmount tree advertises and implements $expand (., ~, *, $levels), $select, $filter, $top, $skip, only and excerpt (the mockups have no Excerpt annotation: the whole resource, as 7.3.1 says); the emulator tree, and NoQueries, advertise nothing and answer 501 to a $ parameter and ignore the others, as 7.3.1 says. Queries() logs the raw query of each request.
  • Fuzzed: FuzzQueryEncode, FuzzParseProtocolFeatures (committed seeds under testdata/fuzz).
  • Not implemented: includeoriginofcondition (it belongs to the event stream), $skiptoken (opaque, followed through the next link), OEM parameters, $top on the log entries (a shorter page need not carry a next link, so the entries read could differ), and $expand where there is no collection to read: the drives of a Storage (an array of links in the resource), the VirtualMedia slots read by insert and eject (each answer's Allow header is needed), the single link of a health report.

Telemetry (v0.14.0)

Beyond the Ansible modules, which have no telemetry: the TelemetryService, its metric definitions, metric report definitions, metric reports and triggers, and the metric reports of the event stream. The reference is the specification as published: DSP0266 1.23.0 (12.1.6 Table 38, 12.5.2 and 12.5.2.2 the metric report SSE stream) and the DSP8010 2025.4 schemas TelemetryService 1.4.1, MetricDefinition 1.3.6, MetricReportDefinition 1.4.7, MetricReport 1.5.2, Triggers 1.4.0 and Schedule 1.2.5. Each capability is a row of the section "Beyond the Ansible modules" of PARITY.md.

  • Library (telemetry.go): TelemetryService (status, SupportedCollectionFunctions, MinCollectionInterval, MaxReports), MetricDefinitions, MetricReportDefinitions (type OnRequest, Periodic or OnChange, schedule, metrics, report actions), MetricReports, MetricReport, Triggers; CreateMetricReportDefinition, DeleteMetricReportDefinition and SubmitTestMetricReport, each write an Outcome and is checked against the schema's enumerations and the service (interval at least MinCollectionInterval, function in SupportedCollectionFunctions, MetricId of a MetricDefinition, MaxReports, the ActionInfo of the action) before anything is sent. A service without the feature gives ErrUnsupported.
  • Metric values: MetricValue.MetricValue is a string in the schema. A value keeps the string the service sent (Raw), a null is Null, and Number is set only when the string is a JSON number that fits a float64 (ParseMetricNumber: no space, plus sign, hexadecimal, NaN, leading zero or overflow). A value that is not a number is never read as 0 (MetricValue.Float returns ErrNotNumeric). MetricReport.TimeSeries groups the numeric values by metric and property and sorts them by timestamp; a value with no number or no RFC 3339 timestamp is returned as skipped, not given the report's time.
  • On demand: a definition of type OnRequest generates its report when the report is read; the schema has no action for it, so MetricReport is it.
  • Stream: a metric report sent over SSE (EventFormatType MetricReport) is decoded by the existing EventStream into the same MetricReport (Event.Report): there is no second parser. MetricReportEvents opens the stream with the filter EventFormatType eq 'MetricReport'.
  • Meter: Read and Meter are unchanged. ReadingsFromSeries is an opt-in adapter that turns an energy series (kWh, Wh or J) and a power series of a report into the Readings a Meter observes; the Meter still decides what a reset or a gap is worth.
  • CLI: redfish telemetry status|definitions|report-definitions|reports|report|triggers|create-definition|delete-definition|test|watch.
redfish ... telemetry status
redfish ... telemetry report-definitions PowerMetrics
redfish ... -o table telemetry report PowerMetrics        # a time series: METRIC PROPERTY TIME VALUE
redfish ... telemetry create-definition --id Temps --type Periodic --interval PT5S --metric CPU1Temp --function Maximum \
  --action LogToMetricReportsCollection --updates AppendWrapsWhenFull --append-limit 16
redfish ... telemetry watch -o table                      # the metric reports of the event stream
  • Bounds and fuzzing: a report document above 1 MiB, or with more than 4096 values, is refused; a text a report keeps is clipped at 4096 bytes; a collection is read for at most 256 members. FuzzParseMetricReport, FuzzParseMetricNumber, FuzzParseRedfishDuration and FuzzParseTelemetryResources run in the CI fuzz matrix, with committed corpora under testdata/fuzz.
  • Mock: both trees get a TelemetryService with three MetricDefinitions, a Periodic definition (PowerMetrics) whose report is regenerated from the sensors' Reading (TickTelemetry; redfish mock serve --telemetry-interval), an OnRequest one generated by the GET, a Trigger, create and delete of a definition, SubmitTestMetricReport, and the metric reports on the existing SSE stream (EventFormatType).
  • Not implemented: see PARITY.md (the other actions of the service, trigger writes, wildcards, push delivery).

Security components, read only (v0.15.0)

Beyond the Ansible modules: the integrity, trust and key resources of a BMC. The reference is the specification as published: the DSP8010 2025.4 schemas ComponentIntegrity 1.5.0, TrustedComponent 1.5.0, SecurityPolicy 1.1.0, KeyService 1.0.1, KeyPolicy 1.0.1 and Key 1.4.1 (DSP0266 1.23.0 has only 12.9.3 and 13.2 on this; DSP0274 SPDM was not opened). There is no write: no revocation, no policy change, no key creation (a wrong write can lock an operator out of the BMC); PARITY.md lists them as "not implemented: writes, by design for this release".

  • Library (security.go): ComponentIntegrities and ComponentIntegrity (the SPDM and TPM identity, the measurements, the sessions, the links), TrustedComponents and TrustedComponent (firmware version, TPM vendor ids, links; CertificatesOf), SecurityPolicy and PolicyCertificates (SPDM and TLS policy, trusted and revoked certificates), KeyService, NVMeoFSecrets and NVMeoFKeyPolicies. Every certificate goes through the certificate reader and ParseX509. A service without the resource gives ErrUnsupported (the emulator tree has none); collections are read with $expand where the service advertises it.
  • Measurements are Base64 with padding in the schema, not hex: each is decoded strictly (DecodeDigest) and given as hex as well; one that is not valid Base64 is kept with its error, never hexed.
  • GetSignedMeasurements runs SPDMGetSignedMeasurements. The schema defines it as the generation of a signed statement over a nonce and measurements (the BMC runs SPDM GET_MEASUREMENTS with the device; no property of the service changes), so it is implemented, with its parameters checked against the ActionInfo or AllowableValues. The signature is not verified: signature_verified is false, verification says "not verified", the CLI repeats it on stderr, and the blob is returned for a verifier that implements DSP0274.
  • Keys: a service may return the key (KeyString; the DMTF mockup does). It is never a field, never printed and in no error; key_present says it was there.
  • CLI: redfish security integrity|integrity-show|measurements|trusted|policy|keys|key-policies, -o json|table.
redfish ... security integrity -o table
redfish ... security integrity-show SS-SPDM-0 --certs -o table   # INDEX/PCR TYPE ALGORITHM IN SUMMARY UPDATED VALUE (hex)
redfish ... security measurements SS-SPDM-0 --index 1,3 --slot 0  # signed, NOT verified
redfish ... security trusted TPM --certs
redfish ... security policy -o table
redfish ... security keys                                        # NQN and protocol; never the key
  • Bounds and fuzzing: 256 members per collection, 1024 measurements per set, 4096 bytes of Base64 per measurement, 256 KiB for a signed statement. FuzzParseComponentIntegrity, FuzzDecodeDigest, FuzzParseSignedMeasurements, FuzzParseSecurityPolicy and FuzzParseKeyResources run in the CI fuzz matrix, with committed corpora under testdata/fuzz.
  • Mock: the DMTF public-rackmount1 resources as they are, plus the SPDMGetSignedMeasurements action on the SPDM ComponentIntegrity resources, answered with a made-up transcript labelled as such (not an SPDM exchange, not signed).

What it follows

Each rule comes from a document opened on 2026-11-05 (see the package documentation for the details): DSP0266 1.19.0 (service root 7.2.3, paged collections 7.2.2, Basic 13.3.3, sessions 13.3.4), Chassis v1.29.0, EnvironmentMetrics v1.3.1, Sensor v1.6.7 and Power v1.7.3. A counter is preferred to a power: the energy between two reads is then exact. The EnvironmentMetrics of a chassis already covers the chassis it contains, so Read returns the first chassis with a reading and never adds chassis up.

Safety

https only; certificates verified (a CA file, else the system roots); TLS 1.2 or later; no redirect followed; every body bounded to 1 MiB (8 MiB for a request with $expand); every request under a timeout; credentials resolved per request through the Credentials interface; no error carries a credential; a reading that is null, negative, not finite or out of range is dropped. Errors are typed (ErrAuth, ErrNotFound, ErrTooLarge, ErrMalformed, ErrNoReading, ErrInsecure, *StatusError). The JSON decoders are fuzzed.

Client.WaitTask (and WaitUpdate) is bounded: when the caller's context has no deadline, Config.TaskTimeout ends the wait (default DefaultTaskTimeout, one hour, as the CLI's --watch-timeout; a negative value leaves only the context). The error then wraps context.DeadlineExceeded; a context with a deadline or a cancellation keeps its own error.

Fuzz targets with a stated property, all in the CI fuzz-smoke matrix with committed seeds under testdata/fuzz: FuzzValidateURL (only https with a host, no credentials, query or fragment), FuzzRetryAfter (never negative, never above an hour), FuzzParseCSR (a request only, never the bytes of a private key block), FuzzServicePath and FuzzSessionPath (a path under /redfish/ or nothing), FuzzLoadSession (CLI saved session: bounded, a token and the right endpoint), the CLI print paths (FuzzExecuteError, FuzzPrintDoc, FuzzPrintEvent, FuzzSessionStatus: no control byte reaches the terminal) and FuzzHandler (the mock BMC: no panic, a valid status, a bounded body, nothing served unauthenticated outside the open resources).

From reads to energy: Meter

Meter turns the successive reads of one BMC into the energy used between them:

  • with an energy counter, the difference of two reads (exact, whatever the gap: a counter is cumulative);
  • with only a power, the trapezoid (P0 + P1) / 2 × dt between two samples, exact for a constant power. Two samples further apart than MaxGap (default 5 minutes) are not joined: the power in between is unknown, the interval is invalid and the caller falls back;
  • a counter that goes down (a BMC reboot) is never reported as a negative energy: the interval is invalid (ReasonReset) and counting restarts from the new value;
  • a change of source between two reads (counter, then only power) is invalid too.

An invalid Interval holds 0 and says why; it is not a measurement of 0.

What it does not do

No polling and no attribution: those belong to the caller (Meter only differences or integrates the reads it is given). Read and Meter never write to a BMC; the Systems commands and the raw CLI do, only when you call them. It does not follow PowerSubsystem (the Power link it reads is deprecated in Chassis v1.29.0 but still the one most BMCs serve).

Status

v0.15.0: the security components, read only (beyond the Ansible parity); v0.14.0: the TelemetryService, metric reports and their stream (beyond the Ansible parity); v0.13.0: $expand in the storage, host interface, virtual media, log and health reads; v0.12.0: the query parameters, $expand in the read paths (beyond the Ansible parity); v0.11.0: the CertificateService and its certificates (beyond the Ansible parity); v0.10.0: the EventService, subscriptions and the SSE stream (beyond the Ansible parity); v0.9.0: the Storage commands (parity 99/99); v0.8.0: the UpdateService commands; v0.7.0: the Accounts and Sessions commands; v0.6.0: the Managers commands, virtual media and logs; v0.5.0: the Chassis commands; v0.4.0: the Systems commands (library, CLI, second mock tree); v0.3.0: the generic client, the mock BMC and the CLI; v0.2.0 and before: the energy reader. Section numbers cited in the code are DSP0266 1.23.0's.

Performance. BenchmarkGet (one resource of the mock over TLS keep-alive, client and mock in one process, Apple M4 Max, one core): 291 allocations per read (exact). Against redfishtool (DMTF's CLI, 1.1.8), one CLI invocation on the same mock, measured 2026-11-06 at load ~4.5 (three rounds, see BENCHMARKS.md): a raw GET of the ComputerSystem takes 4.6–5.3 ms with redfish and 69–75 ms with redfishtool. Most of that gap is the Python interpreter starting on every call. redfishtool also never verifies the BMC's certificate (verify=False); redfish does, at no measurable cost.

Pre-1.0: the API may change in a minor version. Born in go-llmflow/gateway, which bills a node's energy from its BMC.

Documentation

Overview

Package redfish is a small client for the DMTF Redfish API of a server's BMC, to read what a node consumes: the energy counter of its chassis (EnvironmentMetrics.EnergykWh), else its power (EnvironmentMetrics.PowerWatts or Power.PowerControl[].PowerConsumedWatts).

It is self-contained (the standard library only), safe for concurrent use, and does no scheduling: polling, counters over time and attribution belong to the caller.

What it follows

Each rule below comes from a document opened on 2026-11-05.

  • DSP0266 Redfish Specification 1.23.0, the newest found on 2026-11-05 (dmtf.org/sites/default/files/standards/documents/DSP0266_1.23.0.pdf; its table of contents was opened: the section numbers cited in this package are 1.23.0's, and the text of the sections below was read in 1.19.0, whose numbering of 13.3 and 7.2.3 is the same): the service root, by default /redfish/v1/ (section 7.2.3); HTTP Basic authentication (13.3.3: "All requests that use HTTP Basic authentication shall require HTTPS"); login sessions (13.3.4: the Sessions collection is found in the service root's Links.Sessions; a POST of {"UserName", "Password"} "without an authentication header", over HTTPS, answers with an X-Auth-Token header, the token to send on later requests, and a Location header, the Session resource to DELETE to log out; the session ID is not the token).
  • Chassis v1.29.0 (redfish.dmtf.org/schemas/v1/Chassis.v1_29_0.json): the EnvironmentMetrics property links the chassis' EnvironmentMetrics resource, "all containing chassis, and devices contained by any of these chassis instances", with the warning that "care should be taken to ensure any reported values do not overlap or result in double-counting": Read therefore returns the first chassis that has a reading rather than adding chassis up. The Power link is deprecated in favour of PowerSubsystem and is only a fallback here.
  • EnvironmentMetrics v1.3.1 (EnvironmentMetrics.v1_3_1.json): EnergykWh, "the total energy, in kilowatt-hour units, for this resource"; EnergyJoules, its device-level equivalent; PowerWatts. Each is a Sensor excerpt whose Reading is the value (Sensor v1.6.7, SensorEnergykWhExcerpt). A counter is preferred to a power: the energy between two reads is then exact.
  • Power v1.7.3 (Power.v1_7_3.json): PowerControl[].PowerConsumedWatts, "the actual power that the chassis consumes, in watt units" (minimum 0).

Safety

https only, certificates verified (against a CA file when given), TLS 1.2 or later, no redirect followed, every body bounded to MaxBody (MaxExpandedBody for a request with $expand), every request under a timeout, credentials resolved per request through Credentials, and no error carries a credential. A reading that is null, negative, not finite or out of range is dropped by the parsers, which are fuzzed.

Index

Constants

View Source
const (
	// MaxCertificateString bounds a CertificateString read or sent (a chain of a
	// few certificates is a few KiB).
	MaxCertificateString = 64 << 10
	// MaxKeyPEM bounds a private key sent.
	MaxKeyPEM = 16 << 10
	// MaxCSRString bounds a CSRString read.
	MaxCSRString = 16 << 10
	// MaxCertificates bounds the certificates read of a service.
	MaxCertificates = 256
)
View Source
const (
	// ReasonBaseline: the first usable sample; nothing to difference yet.
	ReasonBaseline = "baseline"
	// ReasonReset: the energy counter went down (the BMC rebooted or its counter
	// wrapped): the energy of the interval is unknown, and a negative delta is
	// never reported as consumption.
	ReasonReset = "counter reset"
	// ReasonGap: two power samples are further apart than MaxGap; the power
	// between them is not interpolated.
	ReasonGap = "gap"
	// ReasonSource: the BMC changed what it reports between the two reads (a
	// counter, then only a power, or the reverse).
	ReasonSource = "source changed"
	// ReasonClock: the second read is not after the first.
	ReasonClock = "clock"
	// ReasonNoReading: the read carries no energy and no power.
	ReasonNoReading = "no reading"
)

Why an Interval holds no energy.

View Source
const (
	// MaxBody bounds every answer a BMC gives.
	MaxBody = 1 << 20
	// MaxMembers bounds the members read of a collection.
	MaxMembers = 64
	// DefaultTimeout bounds a request when none is set.
	DefaultTimeout = 10 * time.Second
	// DefaultTaskTimeout bounds WaitTask when the context has no deadline; it is
	// the CLI's --watch-timeout default.
	DefaultTaskTimeout = time.Hour
)

Limits.

View Source
const (
	// MaxSecurityMembers bounds the members read of a security collection.
	MaxSecurityMembers = 256
	// MaxMeasurements bounds the measurements kept of one measurement set.
	MaxMeasurements = 1024
	// MaxDigestText bounds the Base64 text of one measurement or summary (a
	// digest is at most 64 bytes; this leaves room for a longer algorithm).
	MaxDigestText = 4096
	// MaxSignedBlobText bounds the Base64 text of SignedMeasurements.
	MaxSignedBlobText = 256 << 10
	// MaxSignedMeasurementsBytes bounds the answer of SPDMGetSignedMeasurements.
	MaxSignedMeasurementsBytes = 2 * MaxSignedBlobText
)

Bounds of the security reads.

View Source
const (
	// MaxEventBytes bounds the data of one event (DSP0266 12.1.2: 1 MiB).
	MaxEventBytes = 1 << 20
	// MaxSSELine bounds one line of the stream.
	MaxSSELine = 1 << 20
)

Limits of a stream.

View Source
const (
	// MaxTelemetryMembers bounds the members read of a telemetry collection.
	MaxTelemetryMembers = 256
	// MaxMetricValues bounds the MetricValues of one metric report, and the
	// values of a test report.
	MaxMetricValues = 4096
	// MaxMetricReportBytes bounds a metric report document.
	MaxMetricReportBytes = MaxEventBytes
)

Bounds of the telemetry reads.

View Source
const (
	// DefaultMaxImage is the largest image a push sends unless PushOptions.MaxSize
	// says otherwise (4 GiB).
	DefaultMaxImage int64 = 4 << 30
	// DefaultUploadTimeout bounds the upload of an image (a request's own timeout
	// is meant for a small JSON document).
	DefaultUploadTimeout = 30 * time.Minute
)

Limits of the Update area.

View Source
const DefaultMaxGap = 5 * time.Minute

DefaultMaxGap is the MaxGap of a zero Meter.

View Source
const KWhPerJoule = 1.0 / 3_600_000

KWhPerJoule converts joules to kilowatt-hours (1 kWh = 3.6 MJ).

View Source
const MaxDestination = 2048

MaxDestination bounds the length of a Destination.

View Source
const MaxEventRecords = 256

MaxEventRecords bounds the records of one Event.

View Source
const (
	// MaxExpandedBody bounds the answer to a request that carries $expand. An
	// expanded answer holds many resources (DSP0266 7.3.2: "the payload may
	// increase beyond what can be sent in a single response"), so it may exceed
	// MaxBody, but it is bounded all the same: a larger one is ErrTooLarge, and a
	// converted read then falls back to one request per member.
	MaxExpandedBody = 8 << 20
)

Limits of a query.

View Source
const MaxFilter = 1024

MaxFilter bounds a $filter expression.

View Source
const MaxLogEntries = 1024

MaxLogEntries bounds the entries read of a log.

View Source
const MaxSubscriptions = MaxMembers

MaxSubscriptions bounds the subscriptions read of a service.

View Source
const NoProtocolList = "Key TransferProtocol@Redfish.AllowableValues not found"

NoProtocolList is what the oracle reports for an action that lists no TransferProtocol allowable values.

Variables

View Source
var (
	// ErrAuth: the BMC refused the credentials (401 or 403).
	ErrAuth = errors.New("redfish: authentication refused")
	// ErrNotFound: the resource does not exist (404), or the service does not
	// link it.
	ErrNotFound = errors.New("redfish: resource not found")
	// ErrTooLarge: an answer is larger than MaxBody.
	ErrTooLarge = errors.New("redfish: the answer is larger than the limit")
	// ErrMalformed: an answer is not the JSON that was expected.
	ErrMalformed = errors.New("redfish: malformed answer")
	// ErrNoReading: the resource carries no energy and no power reading.
	ErrNoReading = errors.New("redfish: no energy or power reading")
	// ErrInsecure: the URL is not an https URL, or carries credentials.
	ErrInsecure = errors.New("redfish: the URL is not acceptable")
)

Typed errors, for errors.Is and errors.As.

View Source
var (
	// ErrUnsupported: the resource does not have the property or action asked for.
	ErrUnsupported = errors.New("redfish: not supported by the resource")
	// ErrAmbiguous: several resources match and none was named.
	ErrAmbiguous = errors.New("redfish: several resources match: name one")
	// ErrMismatch: values differ from the ones expected.
	ErrMismatch = errors.New("redfish: the values do not match")
)
View Source
var CertificateTypes = []string{"PEM", "PEMchain", "PKCS7", "PKCS12"}

CertificateTypes are the formats of Certificate.CertificateType (Certificate 1.11.0, CertificateType).

View Source
var ErrBadDigest = errors.New("redfish: not a Base64 string with padding")

ErrBadDigest: a measurement or blob is not a Base64 string with padding.

View Source
var ErrCertificateTooLarge = errors.New("redfish: the certificate data is larger than the limit")

ErrCertificateTooLarge: a certificate, key or CSR string is over its limit.

View Source
var ErrEventTooLarge = errors.New("redfish: an event is larger than the limit")

ErrEventTooLarge: a line or an event of the stream is larger than the limit.

View Source
var ErrImageTooLarge = errors.New("redfish: the image is larger than the limit")

ErrImageTooLarge: the image is larger than the limit.

View Source
var ErrNoAccount = errors.New("redfish: no account with the given id or username")

ErrNoAccount: no account has the Id or the UserName asked for (the oracle's no_match).

View Source
var ErrNoCounter = errors.New("redfish: the BMC reports no energy counter")

ErrNoCounter is returned by RequireCounter when a read has no energy counter.

View Source
var ErrNotNumeric = errors.New("redfish: the metric value is not a number")

ErrNotNumeric: a metric value is null, or its string is not a number.

View Source
var ErrQuery = errors.New("redfish: invalid query parameter")

ErrQuery: a query parameter has a value, or a combination, the grammar of DSP0266 7.3 refuses. Nothing was sent.

View Source
var KeyUsageValues = []string{"DigitalSignature", "NonRepudiation", "KeyEncipherment", "DataEncipherment", "KeyAgreement", "KeyCertSign", "CRLSigning",
	"EncipherOnly", "DecipherOnly", "ServerAuthentication", "ClientAuthentication", "CodeSigning", "EmailProtection", "Timestamping", "OCSPSigning"}

KeyUsageValues are the values of KeyUsage (Certificate 1.11.0, KeyUsage).

View Source
var ProtocolServices = []string{"SNMP", "VirtualMedia", "Telnet", "SSDP", "IPMI", "SSH", "KVMIP", "NTP", "HTTP", "HTTPS", "DHCP", "DHCPv6", "RDP", "RFB"}

ProtocolServices are the services of the ManagerNetworkProtocol resource the oracle reads and sets.

View Source
var ResetToDefaultsModes = []string{"ResetAll", "PreserveNetworkAndUsers", "PreserveNetwork"}

ResetToDefaultsModes are the ResetType values of Manager.ResetToDefaults the module accepts.

Functions

func CheckDestination added in v0.10.0

func CheckDestination(dest string) error

CheckDestination applies the rules a subscription Destination must meet before it is sent: an https URL with a host, no credentials in it (userinfo), no query and no fragment (a token in a URL ends up in logs: a receiver that needs authorization takes it from HttpHeaders), and no control character. DSP0266 13.1 requires TLS 1.2 or later of the interface, and 13.7 has the service verify the destination's identity: a plain http destination would send the events in clear, which this client refuses. redfish-sse:// destinations are made by the service for an SSE connection (EventDestination.Destination) and are not created by a client.

func CheckImageURI added in v0.8.0

func CheckImageURI(uri, protocol string, allowed []string) error

CheckImageURI validates the ImageURI of a SimpleUpdate against the transfer protocols the service allows: bounded, no control character or space, no credentials in it, and a scheme that is one of the allowed protocols and matches protocol when it is given. The error never repeats the URI.

func CheckPayload added in v0.4.0

func CheckPayload(req, cur Props) (changes bool, unsupported string)

CheckPayload compares the properties to apply with the ones the resource holds (_check_request_payload): changes is true when one differs; unsupported names the first property the resource does not have (nested objects are compared member by member; arrays and scalars by value).

func CheckPrivateKey added in v0.11.0

func CheckPrivateKey(key Secret, certString string) error

CheckPrivateKey verifies a PEM private key against the certificate it is for: one block, of an accepted type (PKCS#8, PKCS#1 RSA or SEC 1 EC; not encrypted), within MaxKeyPEM, whose public key is the certificate's. The error never holds any of the key.

func CheckVolumeRequest added in v0.9.0

func CheckVolumeRequest(raid string, drives, supported, own []string) error

CheckVolumeRequest checks a volume against what its Storage subsystem says: the RAID type must be one of the controller's SupportedRAIDTypes (when it lists them) and each drive one of the subsystem's Drives (when it lists any). The service has the last word; this refuses what it would refuse, before anything is deleted. The drives are compared as paths.

func MultipartFrame added in v0.8.0

func MultipartFrame(params []byte, filename, customName, customMIME, customContent string) (prefix, suffix []byte, contentType string, err error)

MultipartFrame builds the multipart/form-data body of a push but for the file's bytes: prefix (every part up to the UpdateFile part's headers), suffix (the closing boundary) and the Content-Type; the body is prefix, the file, suffix, so its length is known and the file can be streamed (_prepare_multipart). params is the JSON of the UpdateParameters part.

func ParseActionInfo added in v0.4.0

func ParseActionInfo(data []byte) (map[string][]string, error)

ParseActionInfo decodes an ActionInfo resource (DSP0266 9.9.6) into the allowable values of each named parameter (nil when it lists none).

func ParseCertificateLocations added in v0.11.0

func ParseCertificateLocations(data []byte) ([]string, error)

ParseCertificateLocations decodes a CertificateLocations resource into the paths of the certificates it lists (Links.Certificates, CertificateLocations 1.0.4): at most MaxCertificates, each a path of the service, without duplicates. It never panics.

func ParseMetricNumber added in v0.14.0

func ParseMetricNumber(s string) (float64, error)

ParseMetricNumber reads a metric value string as a number, strictly: the grammar of a JSON number (RFC 8259 6: an optional minus, an integer part without a leading zero, an optional fraction, an optional exponent), at most 64 bytes, and a finite float64. A space, a plus sign, a hexadecimal, "NaN" or "Inf", an empty string, or a number out of range is an error wrapping ErrNotNumeric: nothing is guessed and nothing becomes 0.

func ParsePowerConsumed

func ParsePowerConsumed(doc []byte) (float64, error)

ParsePowerConsumed sums the PowerConsumedWatts of the PowerControl entries of a Power resource (the older way a BMC reports power). ErrNoReading when none is usable.

func ParseRedfishDuration added in v0.14.0

func ParseRedfishDuration(s string) (time.Duration, error)

ParseRedfishDuration reads a Redfish duration, the ISO 8601 form the schemas pattern as ^P(\d+D)?(T(\d+H)?(\d+M)?(\d+(\.\d+)?S)?)?$ (MinCollectionInterval, RecurrenceInterval, SensingInterval...). At least one component is required (the pattern also matches "P" and "PT", which name no duration), each is of at most 9 digits, the seconds may have up to 9 fraction digits, and the total is at most 100 years.

func PasswordChangeURI added in v0.7.0

func PasswordChangeURI(err error) string

PasswordChangeURI is check_password_change_required: when a service answered that the password of the authenticated user must be changed (an extended message Base.1.x.PasswordChangeRequired, in the error object or at the top level), the account it names (its first argument; a path of the service), else "".

func RequireCounter added in v0.2.0

func RequireCounter(r Reading) (float64, error)

RequireCounter returns the counter of a read, ErrNoCounter when it has none: for a caller that bills only a measured counter.

func ResetTypeOf added in v0.4.0

func ResetTypeOf(command string) (string, bool)

ResetTypeOf maps a power command (PowerOn, PowerForceOff, PowerReboot, PowerCycle...) to its ResetType, ok false for an unknown command.

func ValidateURL

func ValidateURL(raw string) error

ValidateURL applies the rules every BMC URL must meet: https, a host, no credentials, no query or fragment.

Types

type AccountSpec added in v0.7.0

type AccountSpec struct {
	ID, Username string // the account: its Id, or its UserName
	Password     Secret // AddUser, UpdateUserPassword
	RoleID       string
	AccountTypes []string
	// OEMAccountTypes is the OEMAccountTypes property.
	OEMAccountTypes []string
	// NewUsername is the name UpdateUserName gives (account_updatename).
	NewUsername string
}

AccountSpec says which account a command acts on and what to set (the module's account_id, account_username, account_password, account_roleid, account_accounttypes, account_oemaccounttypes and account_updatename).

func (AccountSpec) String added in v0.7.0

func (a AccountSpec) String() string

String lists the spec without its password.

type BootOverride added in v0.4.0

type BootOverride struct {
	// Device is the BootSourceOverrideTarget (Pxe, Cd, Hdd, UefiTarget, UefiBootNext...).
	Device string
	// UefiTarget (UefiTarget device) and BootNext (UefiBootNext device).
	UefiTarget, BootNext string
	// Enabled is Once (SetOneTimeBoot), Continuous (EnableContinuousBootOverride)
	// or Disabled (DisableBootOverride).
	Enabled string
	// Mode is Legacy or UEFI, "" to leave it.
	Mode string
}

BootOverride is a boot source override (ComputerSystem Boot).

type CSR added in v0.11.0

type CSR struct {
	// PEM is the CSRString.
	PEM string `json:"pem"`
	// CollectionURI is where the signed certificate is installed (GenerateCSR).
	CollectionURI string `json:"collection_uri,omitempty"`
	// CertificateURI is the certificate the signed request replaces (Rekey, Renew).
	CertificateURI string `json:"certificate_uri,omitempty"`
	// Info is the request decoded by this library; InfoError says why it is absent.
	Info      *CSRInfo `json:"info,omitempty"`
	InfoError string   `json:"info_error,omitempty"`
}

CSR is the answer of a GenerateCSR, Rekey or Renew action: the PEM PKCS#10 request a CA signs. The private key stays in the service ("should not be part of the response"); an answer that carries one is refused.

func ParseCSRResponse added in v0.11.0

func ParseCSRResponse(data []byte) (CSR, error)

ParseCSRResponse decodes the body of the answer to GenerateCSR, Rekey or Renew (GenerateCSRResponse, RekeyResponse, RenewResponse): CSRString is required, as PEM and within MaxCSRString, and carries no private key. It never panics.

type CSRInfo added in v0.11.0

type CSRInfo struct {
	Subject            string   `json:"subject"`
	SignatureAlgorithm string   `json:"signature_algorithm"`
	PublicKeyAlgorithm string   `json:"public_key_algorithm"`
	KeyBits            int      `json:"key_bits,omitempty"`
	KeyCurve           string   `json:"key_curve,omitempty"`
	DNSNames           []string `json:"dns_names,omitempty"`
	IPAddresses        []string `json:"ip_addresses,omitempty"`
	EmailAddresses     []string `json:"email_addresses,omitempty"`
	// SignatureValid is the result of CheckSignature: the request proves possession of the key.
	SignatureValid bool `json:"signature_valid"`
}

CSRInfo is what crypto/x509 reads in a PKCS#10 request (RFC 2986).

func ParseCSR added in v0.11.0

func ParseCSR(csrPEM string) (CSRInfo, error)

ParseCSR decodes a PEM certificate signing request with crypto/x509, bounded by MaxCSRString. It never panics.

type CSRRequest added in v0.11.0

type CSRRequest struct {
	// CertificateCollection is the collection the signed certificate will be
	// installed in (required).
	CertificateCollection string
	CommonName            string
	AlternativeNames      []string
	Organization          string
	OrganizationalUnit    string
	City, State           string
	// Country is the two-letter ISO code.
	Country string
	Email   string
	// GivenName, Surname, Initials, ContactPerson and UnstructuredName are the
	// other subject attributes of the schema.
	GivenName, Surname, Initials, ContactPerson, UnstructuredName string
	// KeyPairAlgorithm is a name of the TCG algorithm registry (TPM_ALG_RSA,
	// TPM_ALG_ECDSA), KeyBitLength and KeyCurveID (TPM_ECC_NIST_P256...) go with it.
	KeyPairAlgorithm string
	KeyBitLength     int
	KeyCurveID       string
	// KeyUsage names are the values of the Certificate schema's KeyUsage.
	KeyUsage []string
	// ChallengePassword is the RFC 2985 challengePassword attribute: a secret, never
	// printed, redacted from errors.
	ChallengePassword Secret
}

CSRRequest is the parameters of CertificateService.GenerateCSR (1.2.2). Only CertificateCollection is required by the schema; a service lists the ones it needs in its ActionInfo.

type Certificate added in v0.11.0

type Certificate struct {
	URI                      string      `json:"uri"`
	ID                       string      `json:"id"`
	Name                     string      `json:"name,omitempty"`
	Type                     string      `json:"type,omitempty"`
	UsageTypes               []string    `json:"usage_types,omitempty"`
	Subject                  *Identifier `json:"subject,omitempty"`
	Issuer                   *Identifier `json:"issuer,omitempty"`
	ValidNotBefore           string      `json:"valid_not_before,omitempty"`
	ValidNotAfter            string      `json:"valid_not_after,omitempty"`
	KeyUsage                 []string    `json:"key_usage,omitempty"`
	SerialNumber             string      `json:"serial_number,omitempty"`
	Fingerprint              string      `json:"fingerprint,omitempty"`
	FingerprintHashAlgorithm string      `json:"fingerprint_hash_algorithm,omitempty"`
	SignatureAlgorithm       string      `json:"signature_algorithm,omitempty"`
	State                    string      `json:"state,omitempty"`
	Health                   string      `json:"health,omitempty"`
	// Rekey and Renew are true when the certificate has the action.
	Rekey bool `json:"rekey"`
	Renew bool `json:"renew"`
	// PEM is the certificate string (certificates only), kept for `certs show --pem`.
	PEM string `json:"-"`
	// X509 is the certificate decoded by this library from the CertificateString:
	// what the certificate really says, which a client can compare with what the
	// service states above. X509Error says why it is absent.
	X509      *X509Info `json:"x509,omitempty"`
	X509Error string    `json:"x509_error,omitempty"`
}

Certificate is a Certificate resource (Certificate 1.11.0). The private key and the Password are never part of it: a CertificateString that carries a private key (the schema has the service remove it) is reduced to its certificates.

func ParseCertificateResource added in v0.11.0

func ParseCertificateResource(uri string, data []byte) (Certificate, error)

ParseCertificateResource decodes a Certificate resource. It never panics, and reads what the CertificateString holds with the bounds of ParseX509.

type CertificateInput added in v0.11.0

type CertificateInput struct {
	// CertificateString is the certificate: PEM, a PEM chain, a PEM PKCS7 or a
	// Base64 PKCS12, as CertificateType says. It must not carry a private key (give
	// PrivateKey), so that the key can be kept out of errors.
	CertificateString string
	// CertificateType is one of CertificateTypes; empty: PEM.
	CertificateType string
	// PrivateKey is the PEM private key of the certificate, for a service that does
	// not know it (a certificate that was not made from a CSR of this service). It
	// is appended to the CertificateString (the schema's rule), is checked to match the
	// certificate, is never printed and is redacted from errors. An encrypted key is
	// refused: the schema has no parameter for its passphrase. Not for PKCS12, which
	// carries its key.
	PrivateKey Secret
	// Password is the password of a PKCS12 bundle (Password of ReplaceCertificate, 1.1.0).
	Password Secret
}

CertificateInput is a certificate to install or to put in place of another.

type CertificateService added in v0.11.0

type CertificateService struct {
	URI string `json:"uri"`
	// LocationsURI is the CertificateLocations resource ("" when the service has none).
	LocationsURI string `json:"locations_uri,omitempty"`
	// EnrollmentCACertificatesURI is the collection of the server certificates of the
	// automatic enrollment servers (1.2.0).
	EnrollmentCACertificatesURI string `json:"enrollment_ca_certificates_uri,omitempty"`
	// GenerateCSR and ReplaceCertificate are true when the service has the action.
	GenerateCSR        bool `json:"generate_csr"`
	ReplaceCertificate bool `json:"replace_certificate"`
	// AutomaticEnrollmentEnabled is nil when the service does not say (1.2.0).
	AutomaticEnrollmentEnabled *bool    `json:"automatic_enrollment_enabled,omitempty"`
	EnrollmentTypes            []string `json:"enrollment_types,omitempty"`
}

CertificateService is the CertificateService resource (CertificateService 1.2.2).

type Client

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

Client reads one BMC. It is safe for concurrent use.

func New

func New(cfg Config) (*Client, error)

New returns a Client; it reads nothing yet.

func (*Client) AccountServiceConfig added in v0.7.0

func (c *Client) AccountServiceConfig(ctx context.Context) (Props, error)

AccountServiceConfig is the AccountService resource (get_accountservice_properties).

func (*Client) ActionValues added in v0.4.0

func (c *Client) ActionValues(ctx context.Context, action Props) map[string][]string

ActionValues is the allowable values of an action's parameters: from its ActionInfo resource when it names one, else from the annotations (_get_all_action_info_values).

func (*Client) AddUser added in v0.7.0

func (c *Client) AddUser(ctx context.Context, a AccountSpec) (Outcome, error)

AddUser creates an account (add_user): nothing is done when the UserName exists. The account is created with a POST to the Accounts collection; when the service does not allow POST (no POST in its Allow header, or a 405 answer), an empty slot, or the account whose Id is given, is changed by a PATCH.

func (*Client) BiosAttributes added in v0.4.0

func (c *Client) BiosAttributes(ctx context.Context, systemURI string) (Props, error)

BiosAttributes are the current BIOS attributes of a system (get_bios_attributes).

func (*Client) BiosRegistry added in v0.4.0

func (c *Client) BiosRegistry(ctx context.Context, systemURI string) (registry Props, uri string, err error)

BiosRegistry is the attribute registry of the system's BIOS: the document named by Bios.AttributeRegistry, found under Registries and read from its English Location (get_bios_registries). uri is where the document was read.

func (*Client) BootOrder added in v0.4.0

func (c *Client) BootOrder(ctx context.Context, systemURI string) ([]Props, error)

BootOrder is the boot order of a system as devices: each BootOption's DisplayName and BootOptionReference when the system has BootOptions, else the reference alone (get_boot_order).

func (*Client) BootOverrideOf added in v0.4.0

func (c *Client) BootOverrideOf(ctx context.Context, systemURI string) (Props, error)

BootOverrideOf is what GetBootOverride reports: the Boot override properties the system has and that are not null; an error when the override is not enabled-able at all (no BootSourceOverrideEnabled).

func (*Client) CPUInventory added in v0.4.0

func (c *Client) CPUInventory(ctx context.Context, systemURI string) ([]Props, error)

CPUInventory lists the processors of a system (get_cpu_inventory).

func (*Client) Certificate added in v0.11.0

func (c *Client) Certificate(ctx context.Context, idOrURI string) (Certificate, error)

Certificate reads one certificate, named by its Id (one of the CertificateLocations) or its path, and decodes its CertificateString with ParseX509.

func (*Client) CertificateLocations added in v0.11.0

func (c *Client) CertificateLocations(ctx context.Context) ([]string, error)

CertificateLocations lists the certificates the service holds, as the CertificateLocations resource of the service gives them (every certificate installed on the service, whatever collection holds it).

func (*Client) CertificateService added in v0.11.0

func (c *Client) CertificateService(ctx context.Context) (CertificateService, error)

CertificateService reads the CertificateService (ErrUnsupported when the service root links none).

func (*Client) Certificates added in v0.11.0

func (c *Client) Certificates(ctx context.Context) ([]Certificate, error)

Certificates reads every certificate the service locates (at most MaxCertificates; more is an error, read them one by one then). One that disappeared since the listing is skipped.

func (*Client) CertificatesOf added in v0.15.0

func (c *Client) CertificatesOf(ctx context.Context, collURI string) ([]Certificate, error)

CertificatesOf reads the certificates of a collection (a TrustedComponent's Certificates, or one of a SecurityPolicy), each decoded with ParseX509: at most MaxSecurityMembers, $expand where advertised. An empty uri gives none.

func (*Client) ChassisEnvironmentMetrics added in v0.5.0

func (c *Client) ChassisEnvironmentMetrics(ctx context.Context, chassisURI string) (Props, error)

ChassisEnvironmentMetrics is the EnvironmentMetrics of a chassis: its power, energy, temperature, humidity and fan speeds, as the service reports them; ErrUnsupported when the chassis has none.

func (*Client) ChassisHealthReport added in v0.5.0

func (c *Client) ChassisHealthReport(ctx context.Context, chassisURI string) (Props, error)

ChassisHealthReport is the health of a chassis and of its power supplies, fans and PCIe devices (get_chassis_health_report).

func (*Client) ChassisHealthReports added in v0.5.0

func (c *Client) ChassisHealthReports(ctx context.Context, uris ...string) ([]Props, error)

ChassisHealthReports is ChassisHealthReport of each chassis, each entry naming its chassis_uri (get_multi_chassis_health_report).

func (*Client) ChassisInventory added in v0.5.0

func (c *Client) ChassisInventory(ctx context.Context, uris ...string) ([]Props, error)

ChassisInventory lists the identity properties of the chassis (get_chassis_inventory).

func (*Client) ChassisPower added in v0.5.0

func (c *Client) ChassisPower(ctx context.Context, uris ...string) ([]Props, error)

ChassisPower is the first PowerControl entry of each chassis' Power resource (get_chassis_power); an error when no chassis has a Power resource.

func (*Client) ChassisPowerSubsystem added in v0.5.0

func (c *Client) ChassisPowerSubsystem(ctx context.Context, chassisURI string) (Props, error)

ChassisPowerSubsystem is the PowerSubsystem of a chassis (the capacity, the allocation, the Status) and its power supplies; ErrUnsupported when the chassis has none.

func (*Client) ChassisSensors added in v0.5.0

func (c *Client) ChassisSensors(ctx context.Context, chassisURI string) ([]Props, error)

ChassisSensors lists the Sensor resources of a chassis (its Sensors collection): what each reads, in which unit and range, and its Status.

func (*Client) ChassisThermalSubsystem added in v0.5.0

func (c *Client) ChassisThermalSubsystem(ctx context.Context, chassisURI string) (Props, error)

ChassisThermalSubsystem is the ThermalSubsystem of a chassis (its Status and fan redundancy), its fans and its ThermalMetrics; ErrUnsupported when the chassis has none.

func (*Client) ChassisThermals added in v0.5.0

func (c *Client) ChassisThermals(ctx context.Context, uris ...string) ([]Props, error)

ChassisThermals lists the Temperatures of the Thermal resources (get_chassis_thermals); a property that is null is left out.

func (*Client) ChassisURIs

func (c *Client) ChassisURIs(ctx context.Context) ([]string, error)

ChassisURIs lists the chassis of the service (at most MaxMembers).

func (*Client) ClearLogs added in v0.6.0

func (c *Client) ClearLogs(ctx context.Context, resURI string) (Outcome, error)

ClearLogs runs the ClearLog action of every log service of a manager that has it (clear_logs), or of a system or a chassis (redfishtool "clearLog").

func (*Client) ClearSessions added in v0.7.0

func (c *Client) ClearSessions(ctx context.Context) (Outcome, error)

ClearSessions ends every active session (clear_sessions). When the client's own session is among them it is ended last (the oracle authenticates by password on each request; a client that holds a token would be refused for the rest).

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

Close ends the session, if one was opened.

func (*Client) ComponentIntegrities added in v0.15.0

func (c *Client) ComponentIntegrities(ctx context.Context) ([]ComponentIntegrity, error)

ComponentIntegrities lists the ComponentIntegrity resources of the service (at most MaxSecurityMembers, $expand where the service advertises it). ErrUnsupported when the service root links none.

func (*Client) ComponentIntegrity added in v0.15.0

func (c *Client) ComponentIntegrity(ctx context.Context, idOrURI string) (ComponentIntegrity, error)

ComponentIntegrity reads one resource, named by its Id or its path.

func (*Client) CreateMetricReportDefinition added in v0.14.0

func (c *Client) CreateMetricReportDefinition(ctx context.Context, in MetricReportDefinitionInput) (MetricReportDefinition, Outcome, error)

CreateMetricReportDefinition creates a metric report definition: a POST to the MetricReportDefinitions collection (the schema says it is insertable). The input is checked first against the schema, and against the service: it must be enabled; a Periodic recurrence must not be shorter than MinCollectionInterval; a CollectionFunction must be in SupportedCollectionFunctions; a MetricId must be the Id of a MetricDefinition; and a definition that records its reports in the collection is refused when the service already holds MaxReports of them. Nothing is sent when a check fails. The service answers 201 with the Location of the new definition.

func (*Client) CreateVolume added in v0.9.0

func (c *Client) CreateVolume(ctx context.Context, systemURI, storageID string, req VolumeRequest) (VolumeResult, error)

CreateVolume creates a volume in a Storage subsystem of a system (create_volume). The subsystem is named by the last segment of its path (the oracle's storage_subsystem_id; with none, the only one). The answer is 201 with the new volume, or 202 with a task monitor in Outcome.Monitor.

func (*Client) Delete added in v0.3.0

func (c *Client) Delete(ctx context.Context, p, ifMatch string) (*Response, error)

Delete removes a resource.

func (*Client) DeleteCertificate added in v0.11.0

func (c *Client) DeleteCertificate(ctx context.Context, idOrURI string) (Outcome, error)

DeleteCertificate deletes a certificate, named by its Id or path (Certificate: deletable). It is read first, so that only a Certificate resource is deleted. A certificate that is already gone (404) is not a change.

func (*Client) DeleteMetricReportDefinition added in v0.14.0

func (c *Client) DeleteMetricReportDefinition(ctx context.Context, idOrURI string) (Outcome, error)

DeleteMetricReportDefinition deletes a metric report definition, named by its Id or its path: the resource is read first so that only a MetricReportDefinition is deleted, then removed with a DELETE. A definition that is already gone (404) is not an error: nothing changed.

func (*Client) DeleteUser added in v0.7.0

func (c *Client) DeleteUser(ctx context.Context, a AccountSpec) (Outcome, error)

DeleteUser removes the account (delete_user); nothing is done when it does not exist. A service that does not allow DELETE (no DELETE in the Allow header of the account, or a 405) gets the account emptied by a PATCH instead: UserName "" and, when it is enabled, Enabled false (delete_user_via_patch).

func (*Client) DeleteVolumes added in v0.9.0

func (c *Client) DeleteVolumes(ctx context.Context, systemURI, storageID string, ids []string, o DeleteVolumesOptions) (VolumeResult, error)

DeleteVolumes deletes the volumes of a Storage subsystem named by their Ids (delete_volumes). The Ids are required and each must be a volume of the subsystem: unlike the oracle, which skips an Id it does not find and says the volumes "were deleted", nothing is deleted when one is unknown.

func (*Client) DisableUser added in v0.7.0

func (c *Client) DisableUser(ctx context.Context, a AccountSpec) (Outcome, error)

DisableUser disables the account (disable_user).

func (*Client) DiskInventory added in v0.9.0

func (c *Client) DiskInventory(ctx context.Context, systemURI string) ([]Props, error)

DiskInventory lists the drives of a system by controller (get_disk_inventory): one entry per Storage subsystem with its Controller name, StorageId and Drives; when the system has no Storage but a SimpleStorage, one entry per SimpleStorage with the properties of its Devices. (The oracle's code tests the SimpleStorage link after the Storage branch has overwritten its variable, so a system that has both is read through Storage only: the same here.)

func (*Client) Do added in v0.3.0

func (c *Client) Do(ctx context.Context, req Request) (*Response, error)

Do sends a request and returns the answer. A non-2xx answer is an error: ErrAuth (401, 403), ErrNotFound (404) or a *StatusError carrying what the service said (412 when If-Match no longer matches, 400 with its ExtendedInfo...).

func (*Client) EachManager added in v0.6.0

func (c *Client) EachManager(ctx context.Context, uris []string, fn func(ctx context.Context, managerURI string) (any, error)) ([]ManagerEntry, error)

EachManager runs a read on the managers uris (every manager of the service when none is given) and collects the answers; the first error stops it.

func (*Client) EnableUser added in v0.7.0

func (c *Client) EnableUser(ctx context.Context, a AccountSpec) (Outcome, error)

EnableUser enables the account (enable_user).

func (*Client) EventService added in v0.10.0

func (c *Client) EventService(ctx context.Context) (EventService, error)

EventService reads the EventService of the service (ErrUnsupported when the service root links none).

func (*Client) Events added in v0.10.0

func (c *Client) Events(ctx context.Context, filter string) (*EventStream, error)

Events opens the SSE stream of the service with a filter ("" for none), and reconnects up to 3 times after a broken connection (EventsWith for the options). The stream runs until ctx is cancelled, the service ends it, or an event is larger than the limit.

func (*Client) EventsWith added in v0.10.0

func (c *Client) EventsWith(ctx context.Context, o EventsOptions) (*EventStream, error)

EventsWith is Events with options. The first connection is opened before it returns: a refusal (401, 403, 400 for a filter the service does not know, anything but 200 text/event-stream) is its error; ErrUnsupported when the EventService has no ServerSentEventUri or is disabled.

func (*Client) FanInventory added in v0.5.0

func (c *Client) FanInventory(ctx context.Context, uris ...string) ([]Props, error)

FanInventory lists the fans of the Thermal resources (get_fan_inventory); a Thermal resource without Fans is an error ("No Fans present").

func (*Client) FirmwareInventory added in v0.8.0

func (c *Client) FirmwareInventory(ctx context.Context) ([]Props, error)

FirmwareInventory lists the members of the UpdateService's FirmwareInventory (GetFirmwareInventory); ErrNotFound when the service has none.

func (*Client) FirmwareUpdateCapabilities added in v0.8.0

func (c *Client) FirmwareUpdateCapabilities(ctx context.Context) (UpdateCapabilities, error)

FirmwareUpdateCapabilities reads what the UpdateService can do (GetFirmwareUpdateCapabilities).

func (*Client) GenerateCSR added in v0.11.0

func (c *Client) GenerateCSR(ctx context.Context, req CSRRequest) (CSR, Outcome, error)

GenerateCSR runs CertificateService.GenerateCSR: the service makes a key pair, keeps the private key for the installation of the signed certificate, and returns the request. Each parameter is checked against the service's ActionInfo (or AllowableValues) and the collection must be a CertificateCollection of the service.

func (*Client) Get added in v0.3.0

func (c *Client) Get(ctx context.Context, p string) (*Response, error)

Get reads a resource.

func (*Client) GetSessions added in v0.7.0

func (c *Client) GetSessions(ctx context.Context) ([]Props, error)

GetSessions lists the active sessions (get_sessions). The Sessions collection is the service root's Links.Sessions, else the default path (the oracle fails when the root has no Links.Sessions).

func (*Client) GetSignedMeasurements added in v0.15.0

func (c *Client) GetSignedMeasurements(ctx context.Context, idOrURI string, req SignedMeasurementsRequest) (SignedMeasurements, error)

GetSignedMeasurements runs the SPDMGetSignedMeasurements action of a ComponentIntegrity (named by Id or path) and returns the signed statement of the service. The action does not change the service; it makes the BMC run SPDM GET_MEASUREMENTS exchanges with the device. The parameters are checked first (indices, nonce, slot) and against the ActionInfo or AllowableValues of the service. The signature is not verified (SignedMeasurements.Verified). ErrUnsupported when the resource has no such action (the schema has it only for type SPDM).

func (*Client) GetWith added in v0.12.0

func (c *Client) GetWith(ctx context.Context, p string, q Query) (*Response, error)

GetWith reads a resource with query parameters. p is a path of the service without a query string. The ProtocolFeaturesSupported of the service root is read first (once per Client); a parameter it does not advertise is refused with ErrUnsupported, a value the grammar forbids with ErrQuery, and nothing is sent. The answer is bounded by MaxBody, or by MaxExpandedBody when the query has $expand.

func (*Client) HPEFanPercentMin added in v0.5.0

func (c *Client) HPEFanPercentMin(ctx context.Context, uris ...string) (any, error)

HPEFanPercentMin is Oem.Hpe.FanPercentMinimum of the first chassis that has it (get_hpe_fan_percent_min); ErrUnsupported when none does.

func (*Client) HPEThermalConfig added in v0.5.0

func (c *Client) HPEThermalConfig(ctx context.Context, uris ...string) (any, error)

HPEThermalConfig is Oem.Hpe.ThermalConfiguration of the first chassis that has it (get_hpe_thermal_config); ErrUnsupported when none does.

func (*Client) HealthReport added in v0.4.0

func (c *Client) HealthReport(ctx context.Context, category, uri string, subsystems []string) (Props, error)

HealthReport is the Status of a resource and of its subsystems (get_health_report): a subsystem is a property ("Memory"), "Links.X" or "Prop.X" (the resource Prop links, then its X). Each entry names the uri of the member and its Status ("Status not available" when it has none).

func (*Client) HostInterfaces added in v0.6.0

func (c *Client) HostInterfaces(ctx context.Context, managerURIs ...string) ([]Props, error)

HostInterfaces lists the host interfaces of the managers (every manager when none is given) with the NICs they use (get_hostinterfaces); an error when the service has none.

func (*Client) InstallCertificate added in v0.11.0

func (c *Client) InstallCertificate(ctx context.Context, collection string, in CertificateInput) (Certificate, Outcome, error)

InstallCertificate adds a certificate to a certificate collection: a POST to the collection with CertificateString and CertificateType (requiredOnCreate of Certificate 1.11.0; DSP0266 9.9.13: the formats the collection supports are checked first). The service shall answer 201 with the Location of the new resource, which is read; a 202 is returned as the Outcome's Monitor.

func (*Client) KeyService added in v0.15.0

func (c *Client) KeyService(ctx context.Context) (KeyService, error)

KeyService reads the KeyService of the service (ErrUnsupported when the service root links none).

func (*Client) LinkedCertificates added in v0.15.0

func (c *Client) LinkedCertificates(ctx context.Context, uris []string) []LinkedCertificate

LinkedCertificates reads the certificates at uris (a path of the service each; at most MaxSecurityMembers). A read that fails is reported in its entry, not as an error of the call: the others are still read.

func (*Client) ListUsers added in v0.7.0

func (c *Client) ListUsers(ctx context.Context) ([]Props, error)

ListUsers lists the accounts (list_users), without the empty slots of a service that has a fixed number of accounts (an empty UserName on a disabled account).

func (*Client) Login added in v0.3.0

func (c *Client) Login(ctx context.Context) error

Login opens the session now (Config.Session); a client does it on first use.

func (*Client) Logs added in v0.6.0

func (c *Client) Logs(ctx context.Context, resURI string, max int) ([]LogEntries, error)

Logs reads the entries of the log services of a manager (get_logs), or of a system or a chassis (redfishtool "Logs"), at most max entries per log (0: 64). The oracle keeps the entries as the collection expands them; an entry the collection lists only by link is read.

func (*Client) ManagePower added in v0.4.0

func (c *Client) ManagePower(ctx context.Context, resURI, actionName, command string) (Outcome, error)

ManagePower runs a power command (PowerOn, PowerForceOff, PowerGracefulShutdown, PowerGracefulRestart, PowerForceRestart, PowerReboot, PowerCycle, PowerFullPowerCycle) through the Reset action actionName of a resource, with the ResetType the service allows (ActionInfo or AllowableValues); nothing is sent when the resource is already in the state asked.

func (*Client) ManagerDateTime added in v0.6.0

func (c *Client) ManagerDateTime(ctx context.Context, managerURI string) (Props, error)

ManagerDateTime is the DateTime and DateTimeLocalOffset of a manager (redfishtool "Managers": no Ansible row).

func (*Client) ManagerHealthReport added in v0.6.0

func (c *Client) ManagerHealthReport(ctx context.Context, managerURI string) (Props, error)

ManagerHealthReport is the health of a manager (get_manager_health_report: a manager has no subsystem).

func (*Client) ManagerInventory added in v0.6.0

func (c *Client) ManagerInventory(ctx context.Context, managerURI string) (Props, error)

ManagerInventory is the inventory properties of a manager (get_manager_inventory).

func (*Client) ManagerNICInventory added in v0.6.0

func (c *Client) ManagerNICInventory(ctx context.Context, managerURI string) ([]Props, error)

ManagerNICInventory lists the EthernetInterfaces of a manager (get_nic_inventory on a manager: GetManagerNicInventory).

func (*Client) ManagerPower added in v0.6.0

func (c *Client) ManagerPower(ctx context.Context, managerURI, command string) (Outcome, error)

ManagerPower runs a power command on a manager (manage_manager_power): PowerOn, PowerForceOff, PowerForceRestart, PowerGracefulRestart, PowerGracefulShutdown, PowerReboot..., and GracefulRestart, which the module maps to PowerGracefulRestart. The ResetType is the one the service allows (ActionInfo or AllowableValues).

func (*Client) ManagerResetToDefaults added in v0.6.0

func (c *Client) ManagerResetToDefaults(ctx context.Context, managerURI, mode string) (Outcome, error)

ManagerResetToDefaults runs the ResetToDefaults action of a manager (manager_reset_to_defaults) with the mode given (ResetAll, PreserveNetworkAndUsers or PreserveNetwork); a mode the service does not allow is refused before anything is sent.

func (*Client) ManagerURIs added in v0.6.0

func (c *Client) ManagerURIs(ctx context.Context) ([]string, error)

ManagerURIs lists the Manager resources (_find_managers_resource).

func (*Client) MemoryInventory added in v0.4.0

func (c *Client) MemoryInventory(ctx context.Context, systemURI string) ([]Props, error)

MemoryInventory lists the memory modules of a system that are present: one whose Status is missing or Absent is left out (get_memory_inventory).

func (*Client) MetricDefinition added in v0.14.0

func (c *Client) MetricDefinition(ctx context.Context, idOrURI string) (MetricDefinition, error)

MetricDefinition reads one metric definition, named by its Id or its path.

func (*Client) MetricDefinitions added in v0.14.0

func (c *Client) MetricDefinitions(ctx context.Context) ([]MetricDefinition, error)

MetricDefinitions lists the MetricDefinitions of the service (at most MaxTelemetryMembers).

func (*Client) MetricReport added in v0.14.0

func (c *Client) MetricReport(ctx context.Context, idOrURI string) (MetricReport, error)

MetricReport reads one metric report, named by its Id or its path. For a definition of type OnRequest this GET is what generates the report (MetricReportDefinitionType OnRequest); no other call is needed.

func (*Client) MetricReportDefinition added in v0.14.0

func (c *Client) MetricReportDefinition(ctx context.Context, idOrURI string) (MetricReportDefinition, error)

MetricReportDefinition reads one metric report definition, named by its Id or its path.

func (*Client) MetricReportDefinitions added in v0.14.0

func (c *Client) MetricReportDefinitions(ctx context.Context) ([]MetricReportDefinition, error)

MetricReportDefinitions lists the MetricReportDefinitions of the service (at most MaxTelemetryMembers).

func (*Client) MetricReportEvents added in v0.14.0

func (c *Client) MetricReportEvents(ctx context.Context, o EventsOptions) (*EventStream, error)

MetricReportEvents opens the SSE stream of the service for metric reports: EventsWith with the filter `EventFormatType eq 'MetricReport'` (DSP0266 12.5.2: "The service sends events of the matching EventFormatType"), joined by `and` with o.Filter when there is one. It is the EventStream of Events, not another reader: each event arrives with Event.Report set to the decoded MetricReport. ErrUnsupported when the EventService lists its EventFormatTypes without MetricReport.

func (*Client) MetricReports added in v0.14.0

func (c *Client) MetricReports(ctx context.Context) ([]MetricReport, error)

MetricReports lists the MetricReports of the service with their values (at most MaxTelemetryMembers reports, each of at most MaxMetricValues values; $expand where the service advertises it). A report that does not decode is an error.

func (*Client) MultipartHTTPPushUpdate added in v0.8.0

func (c *Client) MultipartHTTPPushUpdate(ctx context.Context, o PushOptions) (UpdateResult, error)

MultipartHTTPPushUpdate sends an image to the MultipartHttpPushUri of the UpdateService (multipath_http_push_update): a multipart/form-data upload of an UpdateParameters part (Targets, apply time, Oem) and the UpdateFile part. The file is opened first and must be a regular file within MaxSize; it is streamed with a known Content-Length, never read whole. The answer is usually a task, as for SimpleUpdate.

func (*Client) NICInventory added in v0.4.0

func (c *Client) NICInventory(ctx context.Context, resURI string) ([]Props, error)

NICInventory lists the EthernetInterfaces of a system or a manager that can be read (get_nic_inventory).

func (*Client) NVMeoFKeyPolicies added in v0.15.0

func (c *Client) NVMeoFKeyPolicies(ctx context.Context) ([]KeyPolicy, error)

NVMeoFKeyPolicies lists the NVMe-oF key policies of the KeyService (at most MaxSecurityMembers).

func (*Client) NVMeoFSecrets added in v0.15.0

func (c *Client) NVMeoFSecrets(ctx context.Context) ([]NVMeoFSecret, error)

NVMeoFSecrets lists the NVMe-oF secrets of the KeyService (at most MaxSecurityMembers). Their key material is not returned: see NVMeoFSecret.

func (*Client) NetworkProtocols added in v0.6.0

func (c *Client) NetworkProtocols(ctx context.Context, managerURI string) (Props, error)

NetworkProtocols is the services of a manager's NetworkProtocol resource that it has (get_network_protocols).

func (*Client) PSUInventory added in v0.4.0

func (c *Client) PSUInventory(ctx context.Context) ([]Props, error)

PSUInventory lists the power supplies of the chassis that are present, from each chassis' Power resource (get_psu_inventory); an error when there is none.

func (*Client) Patch added in v0.3.0

func (c *Client) Patch(ctx context.Context, p string, v any, ifMatch string) (*Response, error)

Patch changes properties of a resource. ifMatch, when not empty, is the ETag the resource must still have.

func (*Client) PatchChecked added in v0.4.0

func (c *Client) PatchChecked(ctx context.Context, uri string, payload Props) (Outcome, error)

PatchChecked changes properties the way the modules do (patch_request with check_pyld): the resource is read, the ETag it gave goes back in If-Match, a property it does not have is ErrUnsupported, and nothing is sent when it already holds every value.

func (*Client) PerformRequestedOperations added in v0.8.0

func (c *Client) PerformRequestedOperations(ctx context.Context, handle string) (Outcome, error)

PerformRequestedOperations does what the update asks to continue (perform_requested_update_operations): the resets its task requests. Changed is false when it asks for none. When a reset fails, the Outcome says whether the earlier ones were done.

func (*Client) PolicyCertificates added in v0.15.0

func (c *Client) PolicyCertificates(ctx context.Context, sp SecurityPolicy) ([]PolicyCertificates, error)

PolicyCertificates reads the trusted and revoked certificates the policy lists (SPDM, TLS client, TLS server), each decoded with ParseX509. A collection the policy does not link is left out.

func (*Client) Post added in v0.3.0

func (c *Client) Post(ctx context.Context, p string, v any) (*Response, error)

Post creates a member of a collection or invokes an action (v is its parameters).

func (*Client) PowerRestorePolicy added in v0.4.0

func (c *Client) PowerRestorePolicy(ctx context.Context, systemURI string) (any, error)

PowerRestorePolicy is the policy of a system (get_power_restore_policy).

func (*Client) ProtocolFeatures added in v0.12.0

func (c *Client) ProtocolFeatures(ctx context.Context) (ProtocolFeatures, error)

ProtocolFeatures reads the ProtocolFeaturesSupported of the service root, once: the answer is kept for the life of the Client.

func (*Client) Read

func (c *Client) Read(ctx context.Context) (Reading, error)

Read reads the node's consumption: the EnergykWh counter of the chassis' EnvironmentMetrics, else (no counter) its PowerWatts, else the Power resource's PowerControl PowerConsumedWatts. With Config.MetricsPath only that resource is read; otherwise the service is discovered once and the links are remembered.

func (*Client) RekeyCertificate added in v0.11.0

func (c *Client) RekeyCertificate(ctx context.Context, idOrURI string, o RekeyOptions) (CSR, Outcome, error)

RekeyCertificate runs Certificate.Rekey: the service makes a new key pair for the certificate and returns a CSR for it (the private key stays in the service). ErrUnsupported when the certificate has no such action.

func (*Client) RenewCertificate added in v0.11.0

func (c *Client) RenewCertificate(ctx context.Context, idOrURI string, challenge Secret) (CSR, Outcome, error)

RenewCertificate runs Certificate.Renew: the service returns a CSR made from the existing information and key pair of the certificate. ErrUnsupported when the certificate has no such action.

func (*Client) ReplaceCertificate added in v0.11.0

func (c *Client) ReplaceCertificate(ctx context.Context, certURI string, in CertificateInput) (string, Outcome, error)

ReplaceCertificate runs the CertificateService.ReplaceCertificate action: the certificate at certURI (an Id or a path) is replaced by the one given. The service shall answer with the Location of the new certificate resource, which is returned (the old URI when the service names none). CertificateType is checked against the ActionInfo or AllowableValues. A certificate made from the CSR of this service needs no PrivateKey: the service kept the key.

func (*Client) ResetBios added in v0.4.0

func (c *Client) ResetBios(ctx context.Context, systemURI string) (Outcome, error)

ResetBios runs the Bios.ResetBios action: the BIOS goes back to its default settings (set_bios_default_settings).

func (*Client) ResolveChassis added in v0.4.0

func (c *Client) ResolveChassis(ctx context.Context, id string) (string, error)

ResolveChassis is ResolveSystem for the chassis.

func (*Client) ResolveManager added in v0.6.0

func (c *Client) ResolveManager(ctx context.Context, id string) (string, error)

ResolveManager is the manager named id, the only one when id is empty, else ErrAmbiguous.

func (*Client) ResolveServiceIdentification added in v0.6.0

func (c *Client) ResolveServiceIdentification(ctx context.Context, id string) (string, error)

ResolveServiceIdentification picks the manager get_service_identification reads: the one named id; else the only manager; else, among several, the one manager that has a ServiceIdentification (ErrAmbiguous when none or several).

func (*Client) ResolveSystem added in v0.4.0

func (c *Client) ResolveSystem(ctx context.Context, id string) (string, error)

ResolveSystem is the system named id, the only one when id is empty, else ErrAmbiguous.

func (*Client) Roles added in v0.7.0

func (c *Client) Roles(ctx context.Context) ([]Props, error)

Roles lists the Roles of the AccountService (the redfishtool AccountService Roles operation; the oracle only names a RoleId). The collection is the AccountService's Roles link, else the one under Links.

func (*Client) Root

func (c *Client) Root(ctx context.Context) (ServiceRoot, error)

Root reads the service root.

func (*Client) SecurityPolicy added in v0.15.0

func (c *Client) SecurityPolicy(ctx context.Context, managerID string) (SecurityPolicy, error)

SecurityPolicy reads the SecurityPolicy of a manager (the one named by id, the only one when id is empty). ErrUnsupported when the manager links none.

func (*Client) ServiceIdentification added in v0.6.0

func (c *Client) ServiceIdentification(ctx context.Context, managerURI string) (string, error)

ServiceIdentification is the ServiceIdentification of a manager (get_service_identification); ErrUnsupported when it has none.

func (*Client) Session added in v0.3.0

func (c *Client) Session() (token, uri string)

Session is the token and the Session resource of the open session, to resume it later (Config.Token and SessionURI), or empty. The token is a credential: keep it as one.

func (*Client) SessionServiceURI added in v0.7.0

func (c *Client) SessionServiceURI(ctx context.Context) (string, error)

SessionServiceURI is the SessionService resource.

func (*Client) SetAssetTag added in v0.4.0

func (c *Client) SetAssetTag(ctx context.Context, uri, tag string) (Outcome, error)

SetAssetTag sets the AssetTag of a system or a chassis (redfishtool "setAssetTag"; community.general has no row for it).

func (*Client) SetBiosAttributes added in v0.4.0

func (c *Client) SetBiosAttributes(ctx context.Context, systemURI string, attrs Props, applyTime string) (Outcome, error)

SetBiosAttributes sets BIOS attributes through the Settings object of the Bios resource (@Redfish.Settings, DSP0266 9.10; set_bios_attributes). Attributes the BIOS does not have are left out and named in Outcome.Warning; the ones it already holds are not sent. applyTime, when not empty, is sent as @Redfish.SettingsApplyTime (DSP0266 7.12: Immediate, OnReset, AtMaintenanceWindowStart...); a Dell service gets OnReset when it is empty, as in the oracle. The change takes effect as the service applies it (usually a reset).

func (*Client) SetBootOrder added in v0.4.0

func (c *Client) SetBootOrder(ctx context.Context, systemURI string, order []string) (Outcome, error)

SetBootOrder sets the boot order of a system; each reference must be one of the system's BootOptions when it has them (set_boot_order).

func (*Client) SetBootOverride added in v0.4.0

func (c *Client) SetBootOverride(ctx context.Context, systemURI string, bo BootOverride) (Outcome, error)

SetBootOverride sets the boot source override of a system (set_boot_override: SetOneTimeBoot, EnableContinuousBootOverride, DisableBootOverride). The device must be in BootSourceOverrideTarget@Redfish.AllowableValues when the system lists them. Dell services get the oracle's two workarounds: the Settings object when the system cannot be patched, and no Enabled with UefiTarget.

func (*Client) SetDefaultBootOrder added in v0.4.0

func (c *Client) SetDefaultBootOrder(ctx context.Context, systemURI string) (Outcome, error)

SetDefaultBootOrder runs the system's SetDefaultBootOrder action.

func (*Client) SetHostInterface added in v0.6.0

func (c *Client) SetHostInterface(ctx context.Context, managerURI, id string, config Props) (Outcome, error)

SetHostInterface changes the HostInterface of a manager: the one whose Id is id, else the only one (set_hostinterface_attributes; the module matches id as a substring of the Id, here it is the whole Id).

func (*Client) SetIndicatorLED added in v0.4.0

func (c *Client) SetIndicatorLED(ctx context.Context, uri, command string) (Outcome, error)

SetIndicatorLED sets the IndicatorLED of a system or a chassis (command IndicatorLedOn, IndicatorLedOff or IndicatorLedBlink; manage_indicator_led).

func (*Client) SetManagerDateTime added in v0.6.0

func (c *Client) SetManagerDateTime(ctx context.Context, managerURI, dateTime, offset string) (Outcome, error)

SetManagerDateTime sets the DateTime (an RFC 3339 date-time) and/or the DateTimeLocalOffset (+hh:mm or -hh:mm) of a manager; an empty value is left.

func (*Client) SetManagerNIC added in v0.6.0

func (c *Client) SetManagerNIC(ctx context.Context, managerURI, addr string, config Props) (Outcome, error)

SetManagerNIC changes the EthernetInterface of a manager whose properties contain addr (case-insensitive; empty: the host of the client's URL, as the module does with its root URI); config is a flat view: a property that is an array in the interface and an object in config becomes an array of that one object (set_manager_nic, get_manager_ethernet_uri).

func (*Client) SetNTP added in v0.6.0

func (c *Client) SetNTP(ctx context.Context, managerURI string, servers []string, enabled *bool) (Outcome, error)

SetNTP sets the NTP servers and, when enabled is not nil, whether the manager uses NTP (the NTP service of SetNetworkProtocols; the redfishtool date and time commands have no Ansible row).

func (*Client) SetNetworkProtocols added in v0.6.0

func (c *Client) SetNetworkProtocols(ctx context.Context, managerURI string, services Props) (Outcome, error)

SetNetworkProtocols changes the services of a manager's NetworkProtocol resource (set_network_protocols; PatchChecked: a service the resource does not have is ErrUnsupported).

func (*Client) SetPowerRestorePolicy added in v0.4.0

func (c *Client) SetPowerRestorePolicy(ctx context.Context, systemURI, policy string) (Outcome, error)

SetPowerRestorePolicy sets it (AlwaysOn, AlwaysOff, LastState).

func (*Client) SetSecureBoot added in v0.4.0

func (c *Client) SetSecureBoot(ctx context.Context, systemURI string, enable bool) (Outcome, error)

SetSecureBoot enables or disables UEFI Secure Boot (SecureBootEnable of the system's SecureBoot resource; EnableSecureBoot is SetSecureBoot(true)).

func (*Client) SetServiceIdentification added in v0.6.0

func (c *Client) SetServiceIdentification(ctx context.Context, managerURI, serviceID string) (Outcome, error)

SetServiceIdentification sets the ServiceIdentification of a manager (set_service_identification).

func (*Client) SetSessionService added in v0.7.0

func (c *Client) SetSessionService(ctx context.Context, props Props) (Outcome, error)

SetSessionService changes properties of the SessionService, SessionTimeout for one (set_session_service; PatchChecked).

func (*Client) SimpleUpdate added in v0.8.0

func (c *Client) SimpleUpdate(ctx context.Context, o SimpleUpdateOptions) (UpdateResult, error)

SimpleUpdate asks the service to fetch an image and update with it (simple_update): the UpdateService.SimpleUpdate action, its transfer protocol and targets checked against the allowable values (an ActionInfo resource, else the annotations). The answer is usually a task: Outcome.Monitor and Status.Handle name its monitor (WaitUpdate follows it).

func (*Client) SoftwareInventory added in v0.8.0

func (c *Client) SoftwareInventory(ctx context.Context) ([]Props, error)

SoftwareInventory is FirmwareInventory for the SoftwareInventory collection (GetSoftwareInventory).

func (*Client) StorageControllerInventory added in v0.9.0

func (c *Client) StorageControllerInventory(ctx context.Context, systemURI string) ([]Props, error)

StorageControllerInventory lists the controllers of a system's Storage subsystems: the members of each Controllers collection, else the deprecated StorageControllers array (get_storage_controller_inventory). An error when the system has no Storage or the Storage collection is empty.

func (*Client) SubmitTestEvent added in v0.10.0

func (c *Client) SubmitTestEvent(ctx context.Context, t TestEvent) (Outcome, error)

SubmitTestEvent runs the SubmitTestEvent action. ErrUnsupported when the service has no such action (an EventService 1.0 has SendTestEvent, another action with other semantics, which is not used). Each parameter is checked against the ActionInfo (or AllowableValues annotations) the service gives, and refused before the POST when the service does not list it.

func (*Client) SubmitTestMetricReport added in v0.14.0

func (c *Client) SubmitTestMetricReport(ctx context.Context, name string, values []TestMetricValue) (Outcome, error)

SubmitTestMetricReport runs the TelemetryService.SubmitTestMetricReport action: the service generates a metric report named name from the values and sends it to the appropriate event destinations ("immediately generate the metric report as an alert event"). Both parameters are required by the schema; the values are at most MaxMetricValues, their timestamps RFC 3339 date-times. Each parameter is checked against the ActionInfo (or AllowableValues) the service gives. ErrUnsupported when the service has no such action.

func (*Client) Subscribe added in v0.10.0

func (c *Client) Subscribe(ctx context.Context, o SubscribeOptions) (Subscription, Outcome, error)

Subscribe creates a subscription: a POST to the Subscriptions collection (DSP0266 12.1.2). The service shall answer 201 Created with the Location of the new subscription, and should return its representation; when it does not the Location is read. The Outcome says what was created.

func (*Client) Subscription added in v0.10.0

func (c *Client) Subscription(ctx context.Context, idOrURI string) (Subscription, error)

Subscription reads one subscription, named by its Id or its path.

func (*Client) Subscriptions added in v0.10.0

func (c *Client) Subscriptions(ctx context.Context) ([]Subscription, error)

Subscriptions lists the subscriptions of the service (DSP0266 12.1.2: the EventDestination resources of the Subscriptions collection; at most MaxSubscriptions). Among them are the ones the service made for the SSE connections that are open (12.5.2).

func (*Client) SystemHealthReport added in v0.4.0

func (c *Client) SystemHealthReport(ctx context.Context, systemURI string) (Props, error)

SystemHealthReport is the health of a system and of its processors, memory, storage and network interfaces (get_system_health_report).

func (*Client) SystemInventory added in v0.4.0

func (c *Client) SystemInventory(ctx context.Context, systemURI string) (Props, error)

SystemInventory is the inventory properties of a system (get_system_inventory).

func (*Client) SystemPower added in v0.4.0

func (c *Client) SystemPower(ctx context.Context, systemURI, command string) (Outcome, error)

SystemPower runs a power command on a system (manage_system_power).

func (*Client) SystemURIs added in v0.4.0

func (c *Client) SystemURIs(ctx context.Context) ([]string, error)

SystemURIs lists the ComputerSystem resources (_find_systems_resource).

func (*Client) TelemetryService added in v0.14.0

func (c *Client) TelemetryService(ctx context.Context) (TelemetryService, error)

TelemetryService reads the TelemetryService of the service (ErrUnsupported when the service root links none).

func (*Client) Triggers added in v0.14.0

func (c *Client) Triggers(ctx context.Context) ([]Trigger, error)

Triggers lists the Triggers of the service (at most MaxTelemetryMembers); ErrUnsupported when the TelemetryService links no Triggers collection (the collection is optional).

func (*Client) TrustedComponent added in v0.15.0

func (c *Client) TrustedComponent(ctx context.Context, idOrURI string, chassis ...string) (TrustedComponent, error)

TrustedComponent reads one trusted component, named by its Id (the only one of that Id among the chassis given or all) or its path.

func (*Client) TrustedComponents added in v0.15.0

func (c *Client) TrustedComponents(ctx context.Context, chassis ...string) ([]TrustedComponent, error)

TrustedComponents lists the TrustedComponents of the chassis given by uris (of every chassis when none is given): at most MaxSecurityMembers per chassis. A chassis without a TrustedComponents collection has none. ErrUnsupported when no chassis has the collection.

func (*Client) Unsubscribe added in v0.10.0

func (c *Client) Unsubscribe(ctx context.Context, idOrURI string) (Outcome, error)

Unsubscribe deletes a subscription, named by its Id or its path (DSP0266 12.1.2: an HTTP DELETE of the subscription's URI). A subscription that is already gone (404) is not an error: nothing changed.

func (*Client) UpdateAccountServiceProperties added in v0.7.0

func (c *Client) UpdateAccountServiceProperties(ctx context.Context, props Props) (Outcome, error)

UpdateAccountServiceProperties changes properties of the AccountService (update_accountservice_properties; PatchChecked: a property the resource does not have is ErrUnsupported). props must not be nil.

func (*Client) UpdateStatus added in v0.8.0

func (c *Client) UpdateStatus(ctx context.Context, handle string) (UpdateStatus, error)

UpdateStatus reads the task or job that tracks an update (GetUpdateStatus).

func (*Client) UpdateUserAccountTypes added in v0.7.0

func (c *Client) UpdateUserAccountTypes(ctx context.Context, a AccountSpec) (Outcome, error)

UpdateUserAccountTypes sets AccountTypes and/or OEMAccountTypes (update_user_accounttypes); one of them at least is required (a nil list is "not given").

func (*Client) UpdateUserName added in v0.7.0

func (c *Client) UpdateUserName(ctx context.Context, a AccountSpec) (Outcome, error)

UpdateUserName renames the account to NewUsername (update_user_name).

func (*Client) UpdateUserPassword added in v0.7.0

func (c *Client) UpdateUserPassword(ctx context.Context, a AccountSpec) (Outcome, error)

UpdateUserPassword sets the password of the account (update_user_password). When the service refuses to answer because the password of the user the client authenticates as must be changed (the Base.1.x.PasswordChangeRequired message, whose first argument is the account: PasswordChangeURI), the account is that one, as the module does, and the password can be changed with it.

func (*Client) UpdateUserRole added in v0.7.0

func (c *Client) UpdateUserRole(ctx context.Context, a AccountSpec) (Outcome, error)

UpdateUserRole changes the RoleId of the account (update_user_role).

func (*Client) VerifyBiosAttributes added in v0.4.0

func (c *Client) VerifyBiosAttributes(ctx context.Context, systemURI string, attrs Props) (Outcome, error)

VerifyBiosAttributes checks that the BIOS holds the attributes given: an attribute it does not have, or holds with another value, is an error wrapping ErrUnsupported or ErrMismatch (verify_bios_attributes).

func (*Client) VirtualMedia added in v0.6.0

func (c *Client) VirtualMedia(ctx context.Context, resURI string) ([]Props, error)

VirtualMedia lists the VirtualMedia resources of a system or a manager (get_virtualmedia); ErrUnsupported when it has none.

func (*Client) VirtualMediaEject added in v0.6.0

func (c *Client) VirtualMediaEject(ctx context.Context, resURI, imageURL string) (Outcome, error)

VirtualMediaEject ejects the image from the slot of a system or a manager that holds it (virtual_media_eject): the EjectMedia action when the slot has it, else a PATCH of Inserted and Image; an image already ejected is not an error, an image no slot holds is ErrNotFound.

func (*Client) VirtualMediaInsert added in v0.6.0

func (c *Client) VirtualMediaInsert(ctx context.Context, resURI string, o VirtualMediaOptions) (Outcome, error)

VirtualMediaInsert inserts an image in a free slot of the VirtualMedia of a system or a manager (virtual_media_insert): nothing is done when the image is already inserted; the slot is the first free one that supports one of the media types (else the first free one); the InsertMedia action is used when the slot has it, else a PATCH of Image and Inserted. Older HPE and Supermicro services that refuse Inserted and WriteProtected are asked again without them.

func (*Client) VolumeInventory added in v0.9.0

func (c *Client) VolumeInventory(ctx context.Context, systemURI string) ([]Props, error)

VolumeInventory lists the volumes of a system by controller (get_volume_inventory): one entry per Storage subsystem with its Controller name and its Volumes. A system without Storage is an error (a SimpleStorage has no volumes).

func (*Client) WaitAvailable added in v0.6.0

func (c *Client) WaitAvailable(ctx context.Context, delay, poll, timeout time.Duration) error

WaitAvailable blocks until the service answers (check_service_availability: the service root is read), as manage_power does with wait: it sleeps delay first (a service may answer while it shuts down), then asks every poll until timeout. The oracle's values are 30s, 5s and 120s.

func (*Client) WaitTask added in v0.3.0

func (c *Client) WaitTask(ctx context.Context, monitor string, poll time.Duration, onProgress func(Task)) (*Response, error)

WaitTask follows a task monitor until the task ends: it polls the monitor (Retry-After, else every poll, never faster than 100 ms) while it answers 202, calls onProgress with the Task each time, and returns the final response. The context bounds the wait; when the context has no deadline, Config.TaskTimeout (default DefaultTaskTimeout, one hour; negative = unbounded) does, and the error then wraps context.DeadlineExceeded. A context that has a deadline, or is cancelled, keeps its own error.

func (*Client) WaitUpdate added in v0.8.0

func (c *Client) WaitUpdate(ctx context.Context, handle string, poll time.Duration, onProgress func(Task)) (UpdateStatus, error)

WaitUpdate follows the task monitor of an update until the task ends (see WaitTask) and returns its final status.

type ComponentIntegrity added in v0.15.0

type ComponentIntegrity struct {
	URI  string `json:"uri"`
	ID   string `json:"id"`
	Name string `json:"name,omitempty"`
	// Type is SPDM, TPM, TCM, TPCM or OEM; TypeVersion the version of the technology.
	Type        string `json:"type,omitempty"`
	TypeVersion string `json:"type_version,omitempty"`
	// Enabled is nil when the service does not say.
	Enabled *bool  `json:"enabled,omitempty"`
	State   string `json:"state,omitempty"`
	Health  string `json:"health,omitempty"`
	// LastUpdated is as the service wrote it.
	LastUpdated string `json:"last_updated,omitempty"`
	// TargetComponentURI is the component whose integrity this reports (a
	// TrustedComponent, in the DMTF mockup).
	TargetComponentURI  string    `json:"target_component_uri,omitempty"`
	ComponentsProtected []string  `json:"components_protected,omitempty"`
	SPDM                *SPDMInfo `json:"spdm,omitempty"`
	TPM                 *TPMInfo  `json:"tpm,omitempty"`
	// SPDMGetSignedMeasurements and TPMGetSignedMeasurements are true when the
	// resource has the action.
	SPDMGetSignedMeasurements bool `json:"spdm_get_signed_measurements"`
	TPMGetSignedMeasurements  bool `json:"tpm_get_signed_measurements"`
}

ComponentIntegrity is a ComponentIntegrity resource (1.5.0).

func ParseComponentIntegrity added in v0.15.0

func ParseComponentIntegrity(uri string, data []byte) (ComponentIntegrity, error)

ParseComponentIntegrity decodes a ComponentIntegrity resource read at uri. It never panics; a measurement that is not Base64 is kept with its DecodeError.

func (ComponentIntegrity) CertificateURIs added in v0.15.0

func (ci ComponentIntegrity) CertificateURIs() []string

CertificateURIs are the certificates a ComponentIntegrity links, in the order responder, requester, TPM.

type Config

type Config struct {
	// BaseURL is the BMC's address, https://host[:port]; a path, if any, is
	// the service root (default /redfish/v1).
	BaseURL string
	// MetricsPath, when set, is the path of the EnvironmentMetrics resource to
	// read, skipping discovery (/redfish/v1/Chassis/1/EnvironmentMetrics).
	MetricsPath string
	// Chassis names the chassis to read when the service has several (its Id,
	// the last element of its path); empty: the first that has a reading.
	Chassis string
	// Credentials authenticate every request.
	Credentials Credentials
	// Token resumes a session opened earlier (the X-Auth-Token it returned);
	// SessionURI is its Session resource, for Close. With a Token, Credentials
	// may be nil: nothing but the token is sent.
	Token, SessionURI string
	// Session, when true, logs in once (POST to the SessionService) and sends
	// X-Auth-Token; otherwise HTTP basic authentication.
	Session bool
	// CAFile is a PEM file of the certificate authorities that sign the BMC's
	// certificate; empty: the system roots.
	CAFile string
	// Timeout bounds each request.
	Timeout time.Duration
	// TaskTimeout bounds WaitTask (and WaitUpdate) when the caller's context has
	// no deadline of its own: 0 means DefaultTaskTimeout, a negative value means
	// no bound but the context's cancellation.
	TaskTimeout time.Duration
	// HTTP overrides the transport (tests); its redirects are still refused.
	HTTP *http.Client
	// NoExpand forces the inventory and listing functions that read the members
	// of a collection (CPUInventory, SoftwareInventory, ListUsers...) to read them
	// one by one. By default they send $expand=. (DSP0266 7.3.2) when the service
	// root advertises it in ProtocolFeaturesSupported, and fall back to the
	// per-member reads when it does not or when the expanded answer fails.
	NoExpand bool
}

Config configures a Client.

type Credentials

type Credentials interface {
	Get(ctx context.Context) (user, password string, err error)
}

Credentials gives the user and password to authenticate with, when they are needed: the caller resolves its secret reference there, so a password lives as long as a request.

type DeleteVolumesOptions added in v0.9.0

type DeleteVolumesOptions struct {
	// DryRun resolves the volumes and deletes nothing.
	DryRun bool
	// OnPlan is called with the paths of the volumes to delete, before the first
	// DELETE (and in a dry run).
	OnPlan func(uris []string)
}

DeleteVolumesOptions tune DeleteVolumes.

type Digest added in v0.15.0

type Digest struct {
	Base64 string `json:"base64"`
	// Hex is the decoded value, lower-case hex (for a signed statement, the
	// first 64 bytes only: see Size).
	Hex string `json:"hex"`
	// Size is the decoded length in bytes.
	Size int `json:"size"`
}

Digest is a binary value the schemas send as Base64 (a measurement, a summary, a signed statement): kept as sent, decoded, and given as hex.

func DecodeDigest added in v0.15.0

func DecodeDigest(s string, max int) (Digest, []byte, error)

DecodeDigest decodes a Base64 string with padding (the pattern ^[A-Za-z0-9+/]+={0,2}$ of ComponentIntegrity 1.5.0), strictly: the length is a multiple of 4 and the padding bits are zero. It is bounded by max encoded bytes.

type EnergyUnit added in v0.14.0

type EnergyUnit string

EnergyUnit is the unit of an energy series.

const (
	UnitKWh EnergyUnit = "kWh"
	UnitWh  EnergyUnit = "Wh"
	UnitJ   EnergyUnit = "J"
)

The units ReadingsFromSeries converts to kWh.

type Event added in v0.10.0

type Event struct {
	// ID is the SSE id field of the event (DSP0266 12.5.2: unique in the stream).
	ID string `json:"id"`
	// ODataType is the @odata.type of the payload (#Event.v1_6_0.Event).
	ODataType string `json:"odata_type,omitempty"`
	// EventID is the Id of the payload.
	EventID string `json:"event_id,omitempty"`
	Name    string `json:"name,omitempty"`
	// Context is the context of the subscription: for an SSE stream, a string the
	// service generated.
	Context string        `json:"context,omitempty"`
	Records []EventRecord `json:"records,omitempty"`
	// Report is the decoded MetricReport when the payload is one (IsMetricReport,
	// DSP0266 12.5.2.2): the same type the MetricReports collection is read into
	// (ParseMetricReport), so a stream of metric reports needs no second parser.
	Report *MetricReport `json:"report,omitempty"`
	// Data is the payload as the service sent it (JSON).
	Data []byte `json:"-"`
	// Err is set, with the other fields empty but ID and Data, when the payload
	// could not be decoded: one bad event does not end the stream.
	Err error `json:"-"`
}

Event is the payload of an event: the Event resource of the schema, or a MetricReport (DSP0266 12.5.2.2) whose records are not decoded.

func ParseEvent added in v0.10.0

func ParseEvent(data []byte) (Event, error)

ParseEvent decodes the data of an event of an SSE stream (DSP0266 12.5.2.1: the JSON representation of the Event object; 12.5.2.2: of a MetricReport). It never panics and refuses what is larger than MaxEventBytes or holds more than MaxEventRecords records.

func (Event) IsMetricReport added in v0.10.0

func (e Event) IsMetricReport() bool

IsMetricReport reports whether the payload is a MetricReport and not an Event.

type EventRecord added in v0.10.0

type EventRecord struct {
	MemberID        string   `json:"member_id,omitempty"`
	EventType       string   `json:"event_type,omitempty"`
	EventID         string   `json:"event_id,omitempty"`
	EventGroupID    *int64   `json:"event_group_id,omitempty"`
	EventTimestamp  string   `json:"event_timestamp,omitempty"`
	Severity        string   `json:"severity,omitempty"`
	MessageSeverity string   `json:"message_severity,omitempty"`
	Message         string   `json:"message,omitempty"`
	MessageID       string   `json:"message_id,omitempty"`
	MessageArgs     []string `json:"message_args,omitempty"`
	// OriginOfCondition is the @odata.id of the origin, when the service sends one.
	OriginOfCondition string `json:"origin_of_condition,omitempty"`
	Context           string `json:"context,omitempty"`
}

EventRecord is one entry of the Events array of an Event (Event 1.14.0 EventRecord).

type EventService added in v0.10.0

type EventService struct {
	URI string `json:"uri"`
	// ServiceEnabled is nil when the service does not say. When false, events are no
	// longer published and an SSE connection cannot be opened.
	ServiceEnabled *bool  `json:"service_enabled,omitempty"`
	State          string `json:"state,omitempty"`
	Health         string `json:"health,omitempty"`
	// SubscriptionsURI is the EventDestinationCollection.
	SubscriptionsURI string `json:"subscriptions_uri,omitempty"`
	// ServerSentEventURI is the SSE endpoint (ServerSentEventUri, DSP0266 12.1.3);
	// empty when the service has none.
	ServerSentEventURI string `json:"server_sent_event_uri,omitempty"`
	// EventFormatTypes are the formats a subscription may ask for (Event,
	// MetricReport); empty: Event only (the schema's default).
	EventFormatTypes []string `json:"event_format_types,omitempty"`
	// RegistryPrefixes, ResourceTypes and Severities are the values a subscription
	// may use; empty means the service does not support that kind of filter.
	RegistryPrefixes []string `json:"registry_prefixes,omitempty"`
	ResourceTypes    []string `json:"resource_types,omitempty"`
	Severities       []string `json:"severities,omitempty"`
	// SSEFilterProperties are the properties of SSEFilterPropertiesSupported: which
	// $filter criteria the SSE URI accepts (EventFormatType, MessageId,
	// OriginResource, RegistryPrefix, ResourceType, SubordinateResources...).
	SSEFilterProperties map[string]bool `json:"sse_filter_properties,omitempty"`
	// Capability flags; nil when the service does not say.
	SSEIncludeOriginOfCondition       *bool  `json:"sse_include_origin_of_condition,omitempty"`
	IncludeOriginOfConditionSupported *bool  `json:"include_origin_of_condition_supported,omitempty"`
	SubordinateResourcesSupported     *bool  `json:"subordinate_resources_supported,omitempty"`
	OriginResourcesSupported          *bool  `json:"origin_resources_supported,omitempty"`
	ExcludeMessageID                  *bool  `json:"exclude_message_id,omitempty"`
	ExcludeRegistryPrefix             *bool  `json:"exclude_registry_prefix,omitempty"`
	DeliveryRetryAttempts             *int64 `json:"delivery_retry_attempts,omitempty"`
	DeliveryRetryIntervalSeconds      *int64 `json:"delivery_retry_interval_seconds,omitempty"`
	// SubmitTestEvent is true when the service has the action.
	SubmitTestEvent bool `json:"submit_test_event"`
}

EventService is the EventService resource (EventService 1.12.0), what a client reads to know the control properties a subscription may use (DSP0266 12.1.5: "Clients can read the EventService resource of a service in order to determine what control properties ... are supported").

type EventStream added in v0.10.0

type EventStream struct {
	// C delivers the events; it is closed when the stream ends. Then Err says why.
	C <-chan Event
	// contains filtered or unexported fields
}

EventStream is an open stream of events.

func (*EventStream) Close added in v0.10.0

func (s *EventStream) Close()

Close ends the stream and waits for it.

func (*EventStream) Err added in v0.10.0

func (s *EventStream) Err() error

Err is why the stream ended: nil for a cancelled context, a Close or a clean end by the service. Valid once C is closed.

type EventsOptions added in v0.10.0

type EventsOptions struct {
	// Filter is the $filter expression of the SSE URI (DSP0266 12.5.2), for
	// instance `MessageId eq 'Contoso.1.0.TempAssert'` or
	// `(RegistryPrefix eq 'Resource') or (RegistryPrefix eq 'Task')`. The service
	// applies it; the client only checks that it is a reasonable text and that
	// the properties it names are ones the service says it supports.
	Filter string
	// MaxLine and MaxEvent bound a line and an event (default MaxSSELine and
	// MaxEventBytes): a larger one ends the stream with ErrEventTooLarge.
	MaxLine, MaxEvent int
	// MaxReconnects is how many times a broken connection is reopened with
	// Last-Event-ID (default 0: never).
	MaxReconnects int
	// Buffer is the capacity of the channel (default 16): a reader that does not
	// keep up holds the connection, nothing grows.
	Buffer int
}

EventsOptions tune an event stream.

type Expand added in v0.12.0

type Expand struct {
	// Kind is which hyperlinks to expand; the zero value is the period.
	Kind ExpandKind
	// Levels is $levels; 0 and 1 are the default, one level, and send no $levels.
	Levels int
}

Expand is the $expand parameter (DSP0266 7.3.2).

type ExpandKind added in v0.12.0

type ExpandKind int

ExpandKind is the option of $expand that says which hyperlinks are expanded (DSP0266 7.3.2 Table 8). The zero value is the period.

const (
	// ExpandNoLinks is the period: the hyperlinks that are not in a Links property.
	ExpandNoLinks ExpandKind = iota
	// ExpandLinks is the tilde: the hyperlinks of the Links properties.
	ExpandLinks
	// ExpandAll is the asterisk: every hyperlink.
	ExpandAll
)

The options of $expand.

func (ExpandKind) String added in v0.12.0

func (k ExpandKind) String() string

type Identifier added in v0.11.0

type Identifier struct {
	CommonName         string   `json:"common_name,omitempty"`
	Organization       string   `json:"organization,omitempty"`
	OrganizationalUnit string   `json:"organizational_unit,omitempty"`
	City               string   `json:"city,omitempty"`
	State              string   `json:"state,omitempty"`
	Country            string   `json:"country,omitempty"`
	Email              string   `json:"email,omitempty"`
	DisplayString      string   `json:"display_string,omitempty"`
	AlternativeNames   []string `json:"alternative_names,omitempty"`
}

Identifier is the Issuer or the Subject of a Certificate (Certificate 1.11.0, Identifier), as the service states it.

type Interval added in v0.2.0

type Interval struct {
	Start, End time.Time
	// Valid is true when KWh is the energy of the interval. When false, the
	// energy is unknown, KWh is 0 and Reason says why: the caller should fall
	// back (a calibrated factor, say), never bill 0 as a measurement.
	Valid  bool
	Reason string
	KWh    float64
	Source Source
}

Interval is the energy a node used between two successive reads.

type KeyPolicy added in v0.15.0

type KeyPolicy struct {
	URI       string `json:"uri"`
	ID        string `json:"id"`
	Name      string `json:"name,omitempty"`
	Type      string `json:"type,omitempty"`
	IsDefault *bool  `json:"is_default,omitempty"`
	// The allow lists of the NVMeoF object, as the service wrote them.
	CipherSuites       []string `json:"cipher_suite_allow_list,omitempty"`
	DHGroups           []string `json:"dh_group_allow_list,omitempty"`
	SecureHashes       []string `json:"secure_hash_allow_list,omitempty"`
	SecurityProtocols  []string `json:"security_protocol_allow_list,omitempty"`
	OEMProtocols       []string `json:"oem_security_protocol_allow_list,omitempty"`
	SecurityTransports []string `json:"security_transport_allow_list,omitempty"`
}

KeyPolicy is a KeyPolicy resource (1.0.1), NVMe-oF type.

func ParseKeyPolicy added in v0.15.0

func ParseKeyPolicy(uri string, data []byte) (KeyPolicy, error)

ParseKeyPolicy decodes a KeyPolicy resource read at uri.

type KeyService added in v0.15.0

type KeyService struct {
	URI string `json:"uri"`
	// NVMeoFSecretsURI and NVMeoFKeyPoliciesURI are its two collections.
	NVMeoFSecretsURI     string `json:"nvmeof_secrets_uri,omitempty"`
	NVMeoFKeyPoliciesURI string `json:"nvmeof_key_policies_uri,omitempty"`
}

KeyService is the KeyService resource (1.0.1).

type LinkedCertificate added in v0.15.0

type LinkedCertificate struct {
	URI         string       `json:"uri"`
	Certificate *Certificate `json:"certificate,omitempty"`
	Error       string       `json:"error,omitempty"`
}

LinkedCertificate is a certificate a resource links: the Certificate resource as certs.go reads it (decoded with ParseX509), or why it could not be read.

type LogEntries added in v0.6.0

type LogEntries struct {
	// Service is the LogService resource.
	Service string
	// Description is the one of the Entries collection ("Collection of log
	// entries" when it has none).
	Description string
	Entries     []Props
}

LogEntries is the entries of one LogService.

type ManagerEntry added in v0.6.0

type ManagerEntry struct {
	ManagerURI string `json:"manager_uri"`
	Entries    any    `json:"entries"`
}

ManagerEntry is what a read returned for one manager (the oracle's aggregate_managers: a manager_uri and its entries).

type Measurement added in v0.15.0

type Measurement struct {
	// Index is the SPDM measurement index; PCR the TPM register: one is set.
	Index *int64 `json:"index,omitempty"`
	PCR   *int64 `json:"pcr,omitempty"`
	// Type is the SPDM DMTFmeasurementTypes value as sent (ImmutableROM,
	// MutableFirmware...), empty for a TPM measurement.
	Type          string `json:"type,omitempty"`
	HashAlgorithm string `json:"hash_algorithm,omitempty"`
	// Measurement is the value; nil, with DecodeError, when it is not a valid
	// Base64 string.
	Measurement *Digest `json:"measurement,omitempty"`
	DecodeError string  `json:"decode_error,omitempty"`
	// SizeMatches is whether the value has the length of HashAlgorithm; nil when
	// the algorithm is not one this client knows.
	SizeMatches *bool `json:"size_matches_algorithm,omitempty"`
	// PartOfSummary is PartofSummaryHash (SPDM).
	PartOfSummary *bool `json:"part_of_summary,omitempty"`
	// SecurityVersionNumber is an 8-byte hex string, only for a
	// MutableFirmwareSecurityVersionNumber measurement (SPDM).
	SecurityVersionNumber string `json:"security_version_number,omitempty"`
	LastUpdated           string `json:"last_updated,omitempty"`
}

Measurement is one measurement of a set, SPDM (Index, Type...) or TPM (PCR).

type Message added in v0.3.0

type Message struct {
	MessageID         string   `json:"MessageId"`
	Message           string   `json:"Message"`
	Severity          string   `json:"Severity"`
	Resolution        string   `json:"Resolution"`
	MessageArgs       []string `json:"MessageArgs"`
	RelatedProperties []string `json:"RelatedProperties"`
}

Message is one Message object (Message.v1_x, DSP8010): an entry of @Message.ExtendedInfo.

func ParseError added in v0.3.0

func ParseError(data []byte) (code, message string, info []Message)

ParseError decodes the error object of an answer (and the top-level @Message.ExtendedInfo of a success): the code, the message and the extended information, bounded. A body that is not that JSON gives empty values.

type Meter added in v0.2.0

type Meter struct {
	// MaxGap is the longest time between two power samples that is integrated;
	// 0 means 5 minutes. It does not apply to a counter.
	MaxGap time.Duration
	// contains filtered or unexported fields
}

Meter turns the successive Readings of one BMC into intervals. It is not safe for concurrent use.

With an energy counter the interval is the counter's difference: a counter is cumulative, so a missed read loses nothing. With only a power, the energy is the trapezoid (P0 + P1) / 2 × dt between two samples; samples further apart than MaxGap are not joined, since the power in between is unknown.

func (*Meter) Observe added in v0.2.0

func (m *Meter) Observe(r Reading) (iv Interval, ok bool)

Observe records a read and returns the interval since the previous one. ok is false for the first read (the baseline). A read that cannot be used returns an invalid Interval, and becomes the new baseline when it carries a sample, so the next interval starts there.

type MetricDefinition added in v0.14.0

type MetricDefinition struct {
	URI  string `json:"uri"`
	ID   string `json:"id"`
	Name string `json:"name,omitempty"`
	// MetricType is Numeric, Discrete, Gauge, Counter, Countdown or String;
	// MetricDataType Boolean, DateTime, Decimal, Integer, String or Enumeration;
	// Implementation PhysicalSensor, Calculated, Synthesized or DigitalMeter.
	MetricType     string `json:"metric_type,omitempty"`
	MetricDataType string `json:"metric_data_type,omitempty"`
	Implementation string `json:"implementation,omitempty"`
	// Units follow the Unified Code for Units of Measure (MetricDefinition.Units).
	Units            string     `json:"units,omitempty"`
	PhysicalContext  string     `json:"physical_context,omitempty"`
	MetricProperties []string   `json:"metric_properties,omitempty"`
	Wildcards        []Wildcard `json:"wildcards,omitempty"`
	SensingInterval  string     `json:"sensing_interval,omitempty"`
	DiscreteValues   []string   `json:"discrete_values,omitempty"`
	MinReadingRange  *float64   `json:"min_reading_range,omitempty"`
	MaxReadingRange  *float64   `json:"max_reading_range,omitempty"`
	// CalculationAlgorithm is set for a Calculated or Synthesized metric.
	CalculationAlgorithm string `json:"calculation_algorithm,omitempty"`
}

MetricDefinition is a MetricDefinition resource (MetricDefinition 1.3.6): the metadata of a metric.

func ParseMetricDefinition added in v0.14.0

func ParseMetricDefinition(uri string, data []byte) (MetricDefinition, error)

ParseMetricDefinition decodes a MetricDefinition resource read at uri.

type MetricReport added in v0.14.0

type MetricReport struct {
	// URI is the @odata.id of the report; ID, Name and ODataType are its Id, Name
	// and @odata.type.
	URI       string `json:"uri,omitempty"`
	ID        string `json:"id,omitempty"`
	Name      string `json:"name,omitempty"`
	ODataType string `json:"odata_type,omitempty"`
	// Timestamp is when the report was generated (MetricReport.Timestamp, 1.1),
	// nil when absent or not a date-time; TimestampRaw is the text as sent.
	Timestamp    *time.Time `json:"timestamp,omitempty"`
	TimestampRaw string     `json:"timestamp_raw,omitempty"`
	// DefinitionURI is the MetricReportDefinition of the report.
	DefinitionURI string `json:"definition_uri,omitempty"`
	// Context is the context the subscriber gave (present in an event, 1.4).
	Context string        `json:"context,omitempty"`
	Values  []MetricValue `json:"values,omitempty"`
}

MetricReport is a MetricReport (MetricReport 1.5.2): a set of collected metrics, read from the MetricReports collection or received over SSE (DSP0266 12.5.2.2).

func ParseMetricReport added in v0.14.0

func ParseMetricReport(data []byte) (MetricReport, error)

ParseMetricReport decodes a MetricReport document: a resource of the collection, or the data field of a metric report SSE event. It never panics, and refuses a document larger than MaxMetricReportBytes, one with more than MaxMetricValues values, and a value that is not an object. A value that is a string, a number, a boolean or null is read as MetricValue says; a timestamp that is not an RFC 3339 date-time is kept as text and has no Timestamp.

func (MetricReport) TimeSeries added in v0.14.0

func (r MetricReport) TimeSeries() (series []Series, skipped []MetricValue)

TimeSeries turns the values of a report into time series, one per (MetricID, MetricProperty) in the order they first appear, each sorted by timestamp (the way MetricValue.Timestamp says a time series is established; equal timestamps keep the report's order). A value with no timestamp or no number is not in a series: it is returned in skipped, never made into a 0 or given the report's time.

type MetricReportDefinition added in v0.14.0

type MetricReportDefinition struct {
	URI  string `json:"uri"`
	ID   string `json:"id"`
	Name string `json:"name,omitempty"`
	// Type is Periodic, OnChange or OnRequest (MetricReportDefinitionType); a
	// Periodic definition has a Schedule.
	Type string `json:"type,omitempty"`
	// Enabled is nil when the service does not say (MetricReportDefinition 1.2).
	Enabled  *bool           `json:"enabled,omitempty"`
	State    string          `json:"state,omitempty"`
	Health   string          `json:"health,omitempty"`
	Schedule *ReportSchedule `json:"schedule,omitempty"`
	// Interval is the Schedule's RecurrenceInterval as a duration, nil when there
	// is none or it is not a duration.
	Interval *time.Duration `json:"-"`
	Metrics  []MetricSpec   `json:"metrics,omitempty"`
	// MetricProperties and Wildcards are the definition-level properties of the
	// schema, alongside Metrics.
	MetricProperties []string   `json:"metric_properties,omitempty"`
	Wildcards        []Wildcard `json:"wildcards,omitempty"`
	// ReportActions are LogToMetricReportsCollection and RedfishEvent: what is done
	// with a report when it is generated.
	ReportActions []string `json:"report_actions,omitempty"`
	// ReportUpdates is Overwrite, AppendWrapsWhenFull, AppendStopsWhenFull or
	// NewReport; AppendLimit is the entries an appended report holds.
	ReportUpdates               string `json:"report_updates,omitempty"`
	AppendLimit                 *int64 `json:"append_limit,omitempty"`
	ReportTimespan              string `json:"report_timespan,omitempty"`
	SuppressRepeatedMetricValue *bool  `json:"suppress_repeated_metric_value,omitempty"`
	HeartbeatInterval           string `json:"heartbeat_interval,omitempty"`
	// MetricReportURI is the most recent report the definition produced.
	MetricReportURI string `json:"metric_report_uri,omitempty"`
	// TriggerURIs are Links.Triggers.
	TriggerURIs []string `json:"trigger_uris,omitempty"`
}

MetricReportDefinition is a MetricReportDefinition resource (MetricReportDefinition 1.4.7): which metrics are collected into a report, and when.

func ParseMetricReportDefinition added in v0.14.0

func ParseMetricReportDefinition(uri string, data []byte) (MetricReportDefinition, error)

ParseMetricReportDefinition decodes a MetricReportDefinition resource read at uri.

type MetricReportDefinitionInput added in v0.14.0

type MetricReportDefinitionInput struct {
	// ID is the Id the definition asks for (the service may assign another); Name
	// defaults to the ID.
	ID, Name string
	// Type is Periodic, OnChange or OnRequest (required). A Periodic definition
	// needs Schedule.RecurrenceInterval ("If the value is Periodic, the Schedule
	// property shall be present").
	Type     string
	Schedule *ReportSchedule
	// Metrics is what the report holds (required); each entry names a MetricID that
	// a MetricDefinition of the service has, or MetricProperties, and may apply a
	// CollectionFunction the service supports.
	Metrics []MetricSpec
	// ReportActions are LogToMetricReportsCollection and RedfishEvent.
	ReportActions []string
	// ReportUpdates is Overwrite, AppendWrapsWhenFull, AppendStopsWhenFull or
	// NewReport; AppendLimit is required for the two Append values.
	ReportUpdates               string
	AppendLimit                 *int64
	ReportTimespan              string
	SuppressRepeatedMetricValue *bool
	// Enabled is MetricReportDefinitionEnabled; nil: not sent.
	Enabled *bool
}

MetricReportDefinitionInput describes a metric report definition to create (MetricReportDefinition 1.4.7). CreateMetricReportDefinition checks it against the schema's enumerations and against the TelemetryService before anything is sent.

type MetricSpec added in v0.14.0

type MetricSpec struct {
	MetricID         string   `json:"metric_id,omitempty"`
	MetricProperties []string `json:"metric_properties,omitempty"`
	// CollectionFunction is Average, Maximum, Minimum or Summation; empty: no
	// calculation. CollectionTimeScope is Point, Interval or StartupInterval and
	// CollectionDuration the duration the function covers.
	CollectionFunction  string `json:"collection_function,omitempty"`
	CollectionTimeScope string `json:"collection_time_scope,omitempty"`
	CollectionDuration  string `json:"collection_duration,omitempty"`
}

MetricSpec is one entry of the Metrics of a metric report definition (MetricReportDefinition 1.4.7 Metric): the metrics of a MetricDefinition (MetricID) or properties named by URI (MetricProperties), the one or the other ("should not be present" with the other), and the calculation applied.

type MetricValue added in v0.14.0

type MetricValue struct {
	// MetricID is the Id of the MetricDefinition that describes the metric;
	// MetricProperty the URI, in JSON pointer notation, of the property it comes
	// from (MetricReport 1.5.2 MetricProperty: "may contain additional
	// calculations performed on the property").
	MetricID       string `json:"metric_id,omitempty"`
	MetricProperty string `json:"metric_property,omitempty"`
	// Raw is the value as the service sent it: the schema has a string (a number
	// converted to its string, a boolean as true or false, an array as a JSON
	// string); a JSON number or boolean where a string was expected is kept as its
	// text. Empty when Null.
	Raw string `json:"raw"`
	// Null: the service sent null, or no value.
	Null bool `json:"null,omitempty"`
	// Number is set only when Raw is a number (ParseMetricNumber); nil otherwise:
	// a value that is not a number is not 0.
	Number *float64 `json:"number,omitempty"`
	// Timestamp is when the metric was obtained, nil when the service sent none or
	// not an RFC 3339 date-time; TimestampRaw is the text as sent.
	Timestamp    *time.Time `json:"timestamp,omitempty"`
	TimestampRaw string     `json:"timestamp_raw,omitempty"`
}

MetricValue is one entry of MetricValues (MetricReport 1.5.2 MetricValue).

func (MetricValue) Float added in v0.14.0

func (v MetricValue) Float() (float64, error)

Float is the value as a number; an error wrapping ErrNotNumeric when it is null or not a number.

type Metrics

type Metrics struct {
	EnergyKWh  *float64
	PowerWatts *float64
}

Metrics is what a document says of a node's consumption.

func ParseEnvironmentMetrics

func ParseEnvironmentMetrics(doc []byte) (Metrics, error)

ParseEnvironmentMetrics reads an EnvironmentMetrics document (also the shape of a Chassis that embeds the same properties): EnergykWh.Reading, else EnergyJoules.Reading converted to kWh, and PowerWatts.Reading. A reading that is null, negative, not finite or out of range is dropped; a document that is not a JSON object is ErrMalformed. Nothing is invented: a document without any usable reading yields an empty Metrics and no error.

type NVMeoFSecret added in v0.15.0

type NVMeoFSecret struct {
	URI             string `json:"uri"`
	ID              string `json:"id"`
	Name            string `json:"name,omitempty"`
	KeyType         string `json:"key_type,omitempty"`
	UserDescription string `json:"user_description,omitempty"`
	// KeyPresent is true when the service returned KeyString (the schema has no
	// way to withhold it; the key is not kept).
	KeyPresent bool `json:"key_present"`
	// NQN is the NVMe Qualified Name of the host or target subsystem.
	NQN                  string   `json:"nqn,omitempty"`
	HostKeyID            string   `json:"host_key_id,omitempty"`
	SecurityProtocolType string   `json:"security_protocol_type,omitempty"`
	OEMSecurityProtocol  string   `json:"oem_security_protocol_type,omitempty"`
	SecureHashAllowList  []string `json:"secure_hash_allow_list,omitempty"`
}

NVMeoFSecret is a Key (1.4.1) of KeyService.NVMeoFSecrets, WITHOUT its key: KeyString is the key material. It is read from the answer to know it is there (KeyPresent) and then dropped: it is not a field, is never printed and is not in any error.

func ParseNVMeoFSecret added in v0.15.0

func ParseNVMeoFSecret(uri string, data []byte) (NVMeoFSecret, error)

ParseNVMeoFSecret decodes a Key resource read at uri.

type Outcome added in v0.4.0

type Outcome struct {
	// Changed is false when the resource already had the requested state.
	Changed bool
	Message string
	// Warning is a non-fatal remark (attributes the BIOS does not have).
	Warning string
	// Monitor is the task monitor when the service answered 202 (see WaitTask).
	Monitor string
}

Outcome is what a command that changes something did.

type ParameterSet added in v0.15.0

type ParameterSet struct {
	Versions            []string `json:"versions,omitempty"`
	AEAD                []string `json:"aead,omitempty"`
	BaseAsym            []string `json:"base_asym,omitempty"`
	BaseHash            []string `json:"base_hash,omitempty"`
	CipherSuites        []string `json:"cipher_suites,omitempty"`
	SignatureAlgorithms []string `json:"signature_algorithms,omitempty"`
}

ParameterSet is an allowed or denied set of an SPDM or TLS policy: versions and algorithms, as the service wrote them (SPDM: AEAD, BaseAsym, BaseHash; TLS: CipherSuites, SignatureAlgorithms).

type Point added in v0.14.0

type Point struct {
	At    time.Time `json:"at"`
	Value float64   `json:"value"`
}

Point is one sample of a Series.

type PolicyCertificates added in v0.15.0

type PolicyCertificates struct {
	// Collection names it: spdm.trusted, spdm.revoked, tls_client.trusted...
	Collection   string        `json:"collection"`
	URI          string        `json:"uri"`
	Certificates []Certificate `json:"certificates"`
}

PolicyCertificates are the certificates a SecurityPolicy lists, by collection.

type Props added in v0.4.0

type Props = map[string]any

Props is the properties of a resource.

func BuildVolumePayload added in v0.9.0

func BuildVolumePayload(details Props, drives []string) (Props, error)

BuildVolumePayload is the POST body of a volume: the details with Drives moved to Links.Drives as @odata.id objects (create_volume). RAIDType and at least one drive are required; a drive must be a path of the service.

func NetworkProtocolPayload added in v0.6.0

func NetworkProtocolPayload(services Props) (Props, error)

NetworkProtocolPayload checks the services to set and builds the payload (set_network_protocols): a service must be one of ProtocolServices; ProtocolEnabled (or protocolenabled) takes true/false, "true"/"false", "True"/"False", "on"/"off" or 1/0; Port (or port) an integer or a string of digits (the module also lets a boolean through as an integer: refused here); any other property goes as it is.

func ParseController added in v0.9.0

func ParseController(data []byte) (Props, error)

ParseController keeps the inventory properties of a storage controller (a StorageController resource or an element of Storage.StorageControllers).

func ParseDrive added in v0.9.0

func ParseDrive(data []byte, uri string) (Props, error)

ParseDrive decodes a Drive: its inventory properties, RedfishURI (its @odata.id, else uri) and, from Links.Volumes, the Volumes it belongs to (get_disk_inventory).

func ParseLogEntries added in v0.6.0

func ParseLogEntries(data []byte) (description string, members []Props, next string, err error)

ParseLogEntries decodes one page of a LogEntry collection: its Description, its members (as they are) and the link to the next page.

func ParseVolume added in v0.9.0

func ParseVolume(data []byte) (Props, error)

ParseVolume decodes a Volume: its inventory properties and, from Links.Drives, Linked_drives, the Ids of the drives it uses (get_volume_inventory).

func Pick added in v0.4.0

func Pick(data []byte, keys ...string) (Props, error)

Pick decodes a resource and keeps the named properties it has (the inventory commands' "does not fail if not found" lists).

type ProtocolFeatures added in v0.12.0

type ProtocolFeatures struct {
	// Advertised: the root has a ProtocolFeaturesSupported object.
	Advertised bool
	// ExpandQuery: ExpandAll is the asterisk, ExpandLinks the tilde, ExpandNoLinks
	// the period, ExpandLevels $levels (to MaxLevels, 0 when the root gives none).
	ExpandAll, ExpandLevels, ExpandLinks, ExpandNoLinks bool
	MaxLevels                                           int
	// ExcerptQuery, FilterQuery, OnlyMemberQuery, SelectQuery and TopSkipQuery
	// (both $top and $skip) are the booleans of the same names.
	Excerpt, Filter, Only, Select, TopSkip bool
	// FilterComparison and FilterCompound are FilterQueryComparisonOperations and
	// FilterQueryCompoundOperations; nil when the root does not say (a service
	// older than ServiceRoot 1.17.0), in which case FilterQuery alone decides.
	FilterComparison, FilterCompound *bool
}

ProtocolFeatures is what the service root says it implements (the ProtocolFeaturesSupported object, DSP0266 7.3.1; ServiceRoot 1.22.0). The zero value is a service that advertises nothing: no parameter is then sent.

func ParseProtocolFeatures added in v0.12.0

func ParseProtocolFeatures(root []byte) (ProtocolFeatures, error)

ParseProtocolFeatures reads ProtocolFeaturesSupported out of a service root. A root without one is not an error: nothing is advertised. A property of another type than the schema's is taken as not advertised.

type PushOptions added in v0.8.0

type PushOptions struct {
	// ImageFile is the image to send (required): a regular file, streamed, never
	// held whole in memory.
	ImageFile string
	Targets   []string
	ApplyTime string
	// OEMParams is the Oem object of UpdateParameters.
	OEMParams Props
	// CustomHeader names an extra part of the upload (a form-data name of letters,
	// digits, dot, underscore and hyphen, not UpdateParameters or UpdateFile) that
	// holds CustomParams, of media type CustomMIMEType (default text/plain).
	CustomHeader, CustomMIMEType, CustomParams string
	// MaxSize is the largest image accepted, in bytes (default DefaultMaxImage);
	// a larger file is ErrImageTooLarge, and nothing is sent.
	MaxSize int64
	// Timeout bounds the whole upload (default DefaultUploadTimeout).
	Timeout time.Duration
}

PushOptions are the options of MultipartHTTPPushUpdate (the module's update_image_file, update_targets, update_apply_time, update_oem_params and update_custom_oem_*).

type Query added in v0.12.0

type Query struct {
	// Expand is $expand.
	Expand *Expand
	// Select is $select: property names, or paths joined by a slash.
	Select []string
	// Top and Skip are $top and $skip, on a resource collection; both are one
	// feature, TopSkipQuery.
	Top, Skip *int
	// Only is only: a collection of exactly one member answers with that member.
	// It cannot be combined with another parameter (DSP0266 7.3.1 Table 7).
	Only bool
	// Excerpt is excerpt: the properties the schema's Excerpt annotation names.
	Excerpt bool
	// Filter is $filter, on a resource collection; the grammar of 7.3.4 is
	// checked before anything is sent.
	Filter string
}

Query is the set of query parameters of a read (DSP0266 7.3). Each is sent only when the service advertises it in ProtocolFeaturesSupported; otherwise the read is refused with ErrUnsupported and nothing is sent. The zero value sends none.

func (Query) Encode added in v0.12.0

func (q Query) Encode(f ProtocolFeatures) (string, error)

Encode validates the query against what the service advertises and returns the query string (without the question mark), "" for the zero Query. The parameters come in the order the service processes them (DSP0266 7.3.1: $filter, $skip, $top, $expand, excerpt, $select). The names keep their dollar sign and the values are percent-encoded so that nothing but the intended parameters can appear (a value cannot hold an ampersand, a hash or a space); url.Values would send %24expand and a plus for each space, which services are not required to decode.

func (Query) IsZero added in v0.12.0

func (q Query) IsZero() bool

IsZero reports whether the query sends nothing.

type Reading

type Reading struct {
	Chassis string
	At      time.Time
	// EnergyKWh is the chassis' energy counter (EnvironmentMetrics.EnergykWh,
	// or EnergyJoules converted), nil when the BMC has none.
	EnergyKWh *float64
	// PowerWatts is the power consumed, nil when the BMC reports none; read
	// only when there is no energy counter.
	PowerWatts *float64
}

Reading is one read of a node's consumption: the energy counter when the BMC has one, else a power. Chassis is the resource it came from.

func ReadingsFromSeries added in v0.14.0

func ReadingsFromSeries(chassis string, energy *Series, unit EnergyUnit, power *Series) ([]Reading, error)

ReadingsFromSeries turns series of a MetricReport into the Readings a Meter observes, for a caller that wants to feed one: it is opt-in, and changes neither Read nor the Meter. The caller says which series is an energy counter (and its unit: the metric definition's Units says which) and which is a power in watts; either may be nil. Points of the two series at the same instant make one Reading; the result is sorted by time. The Meter decides what a Reading is worth (a reset, a gap, a counter that went down): this only converts and orders, and refuses a value that is negative, not finite or a unit it does not know.

type RekeyOptions added in v0.11.0

type RekeyOptions struct {
	KeyPairAlgorithm  string
	KeyBitLength      int
	KeyCurveID        string
	ChallengePassword Secret
}

RekeyOptions are the parameters of Certificate.Rekey (1.11.0).

type ReportSchedule added in v0.14.0

type ReportSchedule struct {
	// RecurrenceInterval is the duration between two reports (PT10S).
	RecurrenceInterval string `json:"recurrence_interval,omitempty"`
	InitialStartTime   string `json:"initial_start_time,omitempty"`
	MaxOccurrences     *int64 `json:"max_occurrences,omitempty"`
	Lifetime           string `json:"lifetime,omitempty"`
	Name               string `json:"name,omitempty"`
}

ReportSchedule is the Schedule of a metric report definition (Schedule 1.2.5).

type Request added in v0.3.0

type Request struct {
	Method string // GET, PATCH, PUT, POST, DELETE, HEAD
	// Path is a path of the service, /redfish/... (a next link or a Location
	// header's path); never a URL.
	Path string
	Body []byte // a JSON document, sent as is
	// IfMatch is the ETag the resource must still have (PATCH, PUT, DELETE).
	IfMatch string
	// Header adds headers. Authorization, X-Auth-Token, Host and
	// Content-Length are refused: the client alone authenticates.
	Header map[string]string
}

Request is one operation.

type ResetRequest added in v0.8.0

type ResetRequest struct {
	URI  string `json:"uri"`
	Type string `json:"type"`
}

ResetRequest is a reset a Base.ResetRequired message asks for.

type Response added in v0.3.0

type Response struct {
	Status int
	Header http.Header
	Body   []byte
}

Response is an answer with a 2xx status.

func (*Response) ETag added in v0.3.0

func (r *Response) ETag() string

ETag is the entity tag of the resource the answer describes ("" if none).

func (*Response) Info added in v0.3.0

func (r *Response) Info() []Message

Info is the @Message.ExtendedInfo of the answer.

func (*Response) IsTask added in v0.3.0

func (r *Response) IsTask() bool

IsTask reports whether the operation continues as a task (202).

func (*Response) JSON added in v0.3.0

func (r *Response) JSON(v any) error

JSON decodes the body.

func (*Response) Location added in v0.3.0

func (r *Response) Location() string

Location is the Location header: the new resource of a 201, or the task monitor of a 202 (a path of the service, "" if it is anything else).

func (*Response) RetryAfter added in v0.3.0

func (r *Response) RetryAfter() time.Duration

RetryAfter is the delay the service asked for (seconds or an HTTP date), 0 when it asked for none; bounded to an hour.

type SPDMInfo added in v0.15.0

type SPDMInfo struct {
	// RequesterURI is the component that reports the integrity.
	RequesterURI             string `json:"requester_uri,omitempty"`
	MeasurementSpecification string `json:"measurement_specification,omitempty"`
	// Summary is the measurement summary; SummaryType TCB or All.
	Summary              *Digest       `json:"measurement_summary,omitempty"`
	SummaryError         string        `json:"measurement_summary_error,omitempty"`
	SummaryHashAlgorithm string        `json:"measurement_summary_hash_algorithm,omitempty"`
	SummaryType          string        `json:"measurement_summary_type,omitempty"`
	Measurements         []Measurement `json:"measurements,omitempty"`
	// The certificate links of the identity authentication, and the status of
	// the verification of the responder's identity (Success or Failed).
	ResponderCertificateURI string    `json:"responder_certificate_uri,omitempty"`
	ResponderVerification   string    `json:"responder_verification_status,omitempty"`
	RequesterCertificateURI string    `json:"requester_certificate_uri,omitempty"`
	Sessions                []Session `json:"sessions,omitempty"`
}

SPDMInfo is the SPDM object of a ComponentIntegrity: what the SPDM Requester reports of the SPDM Responder.

type SPDMPolicy added in v0.15.0

type SPDMPolicy struct {
	Enabled                 *bool         `json:"enabled,omitempty"`
	SecureSessionEnabled    *bool         `json:"secure_session_enabled,omitempty"`
	VerifyCertificate       *bool         `json:"verify_certificate,omitempty"`
	AllowExtendedAlgorithms *bool         `json:"allow_extended_algorithms,omitempty"`
	Allowed                 *ParameterSet `json:"allowed,omitempty"`
	Denied                  *ParameterSet `json:"denied,omitempty"`
	TrustedCertificatesURI  string        `json:"trusted_certificates_uri,omitempty"`
	RevokedCertificatesURI  string        `json:"revoked_certificates_uri,omitempty"`
}

SPDMPolicy is the SPDM object of a SecurityPolicy.

type SSEMessage added in v0.10.0

type SSEMessage struct {
	// ID is the last event ID of the stream when the event was dispatched (the
	// id field: HTML 9.2.6 keeps it from an event to the next).
	ID string
	// Type is the event field, "message" when the event has none.
	Type string
	// Data is the data field, its lines joined by LF.
	Data []byte
}

SSEMessage is one dispatched event of a stream.

type SSEReader added in v0.10.0

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

SSEReader parses an event stream.

func NewSSEReader added in v0.10.0

func NewSSEReader(r io.Reader, maxLine, maxEvent int) *SSEReader

NewSSEReader reads the events of r. A limit that is not above 0 is the default (MaxSSELine, MaxEventBytes).

func (*SSEReader) LastID added in v0.10.0

func (s *SSEReader) LastID() string

LastID is the last event ID seen: what a reconnection sends in Last-Event-ID.

func (*SSEReader) Next added in v0.10.0

func (s *SSEReader) Next() (SSEMessage, error)

Next returns the next event. At the end of the stream it returns io.EOF (an event that a blank line did not complete is dropped); a read error is returned as it is.

func (*SSEReader) Retry added in v0.10.0

func (s *SSEReader) Retry() time.Duration

Retry is the reconnection time the stream asked for (the retry field), 0 if it asked for none.

type Secret added in v0.7.0

type Secret string

Secret is a password: it never shows itself.

func (Secret) Format added in v0.7.0

func (s Secret) Format(f fmt.State, _ rune)

Format prints "[redacted]" for every verb.

func (Secret) GoString added in v0.7.0

func (s Secret) GoString() string

GoString is "[redacted]" too (%#v).

func (Secret) LogValue added in v0.7.0

func (s Secret) LogValue() slog.Value

LogValue keeps a password out of a log/slog record.

func (Secret) MarshalJSON added in v0.7.0

func (s Secret) MarshalJSON() ([]byte, error)

MarshalJSON is "[redacted]": the payload sent to a service is built from Reveal.

func (Secret) MarshalText added in v0.7.0

func (s Secret) MarshalText() ([]byte, error)

MarshalText is "[redacted]" (encoding.TextMarshaler, used by log encoders).

func (Secret) Reveal added in v0.7.0

func (s Secret) Reveal() string

Reveal is the secret's value, for the one place that sends it.

func (Secret) String added in v0.7.0

func (s Secret) String() string

String is "[redacted]".

type SecurityPolicy added in v0.15.0

type SecurityPolicy struct {
	URI                   string `json:"uri"`
	ManagerURI            string `json:"manager_uri,omitempty"`
	Name                  string `json:"name,omitempty"`
	State                 string `json:"state,omitempty"`
	Health                string `json:"health,omitempty"`
	OverrideParentManager *bool  `json:"override_parent_manager,omitempty"`
	// SPDM is nil when the policy has no SPDM object; TLSClient and TLSServer
	// are the manager acting as a TLS client or server.
	SPDM      *SPDMPolicy `json:"spdm,omitempty"`
	TLSClient *TLSPolicy  `json:"tls_client,omitempty"`
	TLSServer *TLSPolicy  `json:"tls_server,omitempty"`
}

SecurityPolicy is the SecurityPolicy resource of a manager (1.1.0).

func ParseSecurityPolicy added in v0.15.0

func ParseSecurityPolicy(uri string, data []byte) (SecurityPolicy, error)

ParseSecurityPolicy decodes a SecurityPolicy resource read at uri.

type Series added in v0.14.0

type Series struct {
	MetricID       string  `json:"metric_id,omitempty"`
	MetricProperty string  `json:"metric_property,omitempty"`
	Points         []Point `json:"points"`
}

Series is the samples of one metric property of a report, sorted by time.

type ServiceRoot

type ServiceRoot struct {
	RedfishVersion string
	Chassis        string
	SessionService string
}

ServiceRoot is what discovery reads of /redfish/v1/.

type Session added in v0.15.0

type Session struct {
	ID        *int64 `json:"id,omitempty"`
	Type      string `json:"type,omitempty"`
	Algorithm string `json:"algorithm,omitempty"`
}

Session is a SingleSessionInfo.

type SignedMeasurements added in v0.15.0

type SignedMeasurements struct {
	ComponentIntegrityURI string `json:"component_integrity_uri"`
	// Nonce is the nonce sent (given or generated).
	Nonce string `json:"nonce"`
	// Version is the SPDM version used; SigningAlgorithm, HashingAlgorithm and
	// AdditionalSigningAlgorithms are the names the service gives.
	Version                     string   `json:"version,omitempty"`
	SigningAlgorithm            string   `json:"signing_algorithm,omitempty"`
	HashingAlgorithm            string   `json:"hashing_algorithm,omitempty"`
	AdditionalSigningAlgorithms []string `json:"additional_signing_algorithms,omitempty"`
	// CertificateURI is the certificate of the slot that can validate the
	// signature; PublicKeyPEM the public key, when the service gives it instead
	// (slot 15).
	CertificateURI string `json:"certificate_uri,omitempty"`
	PublicKeyPEM   string `json:"public_key_pem,omitempty"`
	// Blob is SignedMeasurements: the transcript of the SPDM exchange whose last
	// response carries the signature; Hex shows its first 64 bytes.
	Blob Digest `json:"signed_measurements"`
	// NonceInBlob is whether the nonce bytes occur in the blob (the schema has
	// the Requester send it in the last GET_MEASUREMENTS request): a substring
	// test, not an SPDM parse.
	NonceInBlob bool `json:"nonce_in_blob"`
	// Verified is always false: this client does not verify the signature.
	Verified     bool   `json:"signature_verified"`
	Verification string `json:"verification"`
}

SignedMeasurements is the answer of SPDMGetSignedMeasurements. The signature is NOT verified: Verified is false, and Verification says so.

func ParseSignedMeasurements added in v0.15.0

func ParseSignedMeasurements(data []byte) (SignedMeasurements, error)

ParseSignedMeasurements decodes the answer of SPDMGetSignedMeasurements (SPDMGetSignedMeasurementsResponse). The blob must be Base64 with padding and is bounded by MaxSignedBlobText. The signature is not verified.

type SignedMeasurementsRequest added in v0.15.0

type SignedMeasurementsRequest struct {
	// Indices are the measurement blocks to sign: one or more unique values
	// 0..254, or the single value 255 (all); empty: the service assumes [255].
	Indices []int
	// Nonce is 32 bytes as 64 hex digits; empty: this client generates one
	// (crypto/rand), so the answer is fresh whatever the service does.
	Nonce string
	// SlotID is the SPDM slot of the certificate that signs; nil: the service
	// assumes 0.
	SlotID *int
	// RawBitstream asks for raw bitstreams (SPDM 1.2 and later; ignored by
	// older versions).
	RawBitstream bool
}

SignedMeasurementsRequest are the parameters of SPDMGetSignedMeasurements (ComponentIntegrity 1.5.0).

type SimpleUpdateOptions added in v0.8.0

type SimpleUpdateOptions struct {
	// ImageURI is where the service fetches the image from (required): an absolute
	// URI whose scheme is one of the transfer protocols the service allows, and
	// that holds no credentials (Username and Password carry them).
	ImageURI string
	// Protocol is the TransferProtocol; empty: not sent.
	Protocol string
	// Targets are the resources to update; empty: the service decides.
	Targets []string
	// Username and Password give access to the image server. The password is a
	// Secret: it is sent, and never printed, returned in an error or kept in a
	// message of the result.
	Username  string
	Password  Secret
	ApplyTime string
}

SimpleUpdateOptions are the options of SimpleUpdate (the module's update_image_uri, update_protocol, update_targets, update_creds and update_apply_time).

type Source added in v0.2.0

type Source string

Source says where an Interval's energy comes from.

const (
	// SourceCounter: the difference of two reads of an energy counter
	// (EnergykWh): exact.
	SourceCounter Source = "counter"
	// SourcePower: the integral of the polled power (PowerWatts or
	// PowerConsumedWatts) by the trapezoid rule: an estimate between samples,
	// exact for a constant power.
	SourcePower Source = "power"
)

type Static

type Static struct{ User, Password string }

Static is Credentials held in memory.

func (Static) Get

func (s Static) Get(context.Context) (string, string, error)

type StatusError

type StatusError struct {
	Method, Path string
	Code         int
	// ErrorCode and Message are the error object's "code" and "message".
	ErrorCode, Message string
	// Info is the @Message.ExtendedInfo of the error, in order.
	Info []Message
}

StatusError is an answer with another status than 200, 201, 202 or 204. It carries what the service said: the error object's code and message and its @Message.ExtendedInfo (DSP0266 9.5), decoded.

func (*StatusError) Error

func (e *StatusError) Error() string

type SubscribeOptions added in v0.10.0

type SubscribeOptions struct {
	// Destination is where the service posts the events (required; CheckDestination).
	Destination string
	// Context is a client-supplied string the service stores and returns in every
	// event for this subscription. It is not a secret: it is echoed.
	Context string
	// EventFormatType is Event or MetricReport; empty: omitted, the service
	// assumes Event.
	EventFormatType string
	// The filters of Table 37. Each is checked against what the EventService
	// supports before anything is sent.
	RegistryPrefixes        []string
	ResourceTypes           []string
	MessageIDs              []string
	ExcludeMessageIDs       []string
	ExcludeRegistryPrefixes []string
	OriginResources         []string
	SubordinateResources    *bool
	// HTTPHeaders are the headers the service sends with every event (an
	// Authorization for the receiver, for instance): credentials, so Secrets. They
	// are sent, never printed and never returned: an error that carries one is
	// redacted.
	HTTPHeaders map[string]Secret
}

SubscribeOptions describe a subscription (EventDestination, DSP0266 12.1.2 and Table 37 in 12.1.5). Only the Redfish protocol and the RedfishEvent subscription type are created.

type Subscription added in v0.10.0

type Subscription struct {
	URI                     string   `json:"uri"`
	ID                      string   `json:"id"`
	Destination             string   `json:"destination"`
	Protocol                string   `json:"protocol,omitempty"`
	SubscriptionType        string   `json:"subscription_type,omitempty"`
	EventFormatType         string   `json:"event_format_type,omitempty"`
	Context                 string   `json:"context"`
	State                   string   `json:"state,omitempty"`
	Health                  string   `json:"health,omitempty"`
	RegistryPrefixes        []string `json:"registry_prefixes,omitempty"`
	ResourceTypes           []string `json:"resource_types,omitempty"`
	MessageIDs              []string `json:"message_ids,omitempty"`
	ExcludeMessageIDs       []string `json:"exclude_message_ids,omitempty"`
	ExcludeRegistryPrefixes []string `json:"exclude_registry_prefixes,omitempty"`
	Severities              []string `json:"severities,omitempty"`
	OriginResources         []string `json:"origin_resources,omitempty"`
	SubordinateResources    *bool    `json:"subordinate_resources,omitempty"`
}

Subscription is an EventDestination resource (EventDestination 1.17.1). The HttpHeaders of a subscription are never read back: the schema has the service answer null or an empty array, as they hold credentials.

type TLSPolicy added in v0.15.0

type TLSPolicy struct {
	VerifyCertificate      *bool         `json:"verify_certificate,omitempty"`
	Allowed                *ParameterSet `json:"allowed,omitempty"`
	Denied                 *ParameterSet `json:"denied,omitempty"`
	TrustedCertificatesURI string        `json:"trusted_certificates_uri,omitempty"`
	RevokedCertificatesURI string        `json:"revoked_certificates_uri,omitempty"`
}

TLSPolicy is one side (Client or Server) of the TLS policy.

type TPMInfo added in v0.15.0

type TPMInfo struct {
	// NonceSizeBytesMaximum is the longest Nonce of TPMGetSignedMeasurements.
	NonceSizeBytesMaximum *int64        `json:"nonce_size_bytes_maximum,omitempty"`
	Measurements          []Measurement `json:"measurements,omitempty"`
	CertificateURI        string        `json:"certificate_uri,omitempty"`
	VerificationStatus    string        `json:"verification_status,omitempty"`
	Sessions              []Session     `json:"sessions,omitempty"`
}

TPMInfo is the TPM object of a ComponentIntegrity.

type Task added in v0.3.0

type Task struct {
	ID, Name        string
	State, Status   string // TaskState, TaskStatus
	PercentComplete *float64
	StartTime       string
	EndTime         string
	Messages        []Message
}

Task is what a Task resource says (Task.v1_x, DSP8010).

func ParseTask added in v0.3.0

func ParseTask(data []byte) (Task, error)

ParseTask decodes a Task resource.

type TelemetryService added in v0.14.0

type TelemetryService struct {
	URI string `json:"uri"`
	// ServiceEnabled is nil when the service does not say (TelemetryService 1.2).
	ServiceEnabled *bool  `json:"service_enabled,omitempty"`
	State          string `json:"state,omitempty"`
	Health         string `json:"health,omitempty"`
	// SupportedCollectionFunctions are the functions a metric of a report
	// definition may apply (Average, Maximum, Minimum, Summation).
	SupportedCollectionFunctions []string `json:"supported_collection_functions,omitempty"`
	// MinCollectionInterval is the shortest interval between two gatherings the
	// service allows, as the service wrote it; MinInterval is it as a duration, nil
	// when absent or not a duration.
	MinCollectionInterval string         `json:"min_collection_interval,omitempty"`
	MinInterval           *time.Duration `json:"-"`
	// MaxReports is the number of metric reports the service supports.
	MaxReports *int64 `json:"max_reports,omitempty"`
	// The collections and the log service the resource links; empty when absent.
	MetricDefinitionsURI       string `json:"metric_definitions_uri,omitempty"`
	MetricReportDefinitionsURI string `json:"metric_report_definitions_uri,omitempty"`
	MetricReportsURI           string `json:"metric_reports_uri,omitempty"`
	TriggersURI                string `json:"triggers_uri,omitempty"`
	LogServiceURI              string `json:"log_service_uri,omitempty"`
	// SubmitTestMetricReport is true when the service has the action.
	SubmitTestMetricReport bool `json:"submit_test_metric_report"`
}

TelemetryService is the TelemetryService resource (TelemetryService 1.4.1).

func ParseTelemetryService added in v0.14.0

func ParseTelemetryService(uri string, data []byte) (TelemetryService, error)

ParseTelemetryService decodes a TelemetryService resource read at uri.

type TestEvent added in v0.10.0

type TestEvent struct {
	// MessageID is required, of the form Registry.Major.Minor.Key
	// (^\w+\.\d+\.\d+\.\w+$).
	MessageID         string
	Message           string
	MessageArgs       []string
	MessageSeverity   string
	Severity          string
	OriginOfCondition string
	EventID           string
	EventGroupID      *int64
	EventTimestamp    string
	// EventType is deprecated since EventService 1.3 (subscriptions are based on
	// RegistryPrefix and ResourceType); sent only when set.
	EventType string
}

TestEvent is the parameters of the EventService.SubmitTestEvent action (EventService 1.12.0). Only MessageId is required; what is not set is not sent and the service omits it from the event.

type TestMetricValue added in v0.14.0

type TestMetricValue struct {
	MetricID       string
	MetricProperty string
	MetricValue    string
	// Timestamp is an RFC 3339 date-time; empty: not sent.
	Timestamp string
}

TestMetricValue is one entry of GeneratedMetricReportValues of the SubmitTestMetricReport action (TelemetryService 1.4.1 MetricValue): the value is a string, as in a report.

type Threshold added in v0.14.0

type Threshold struct {
	// Activation is Increasing, Decreasing, Either or Disabled.
	Activation string   `json:"activation,omitempty"`
	DwellTime  string   `json:"dwell_time,omitempty"`
	Reading    *float64 `json:"reading,omitempty"`
}

Threshold is a numeric threshold of a trigger (Triggers 1.4.0 Threshold).

type Trigger added in v0.14.0

type Trigger struct {
	URI              string   `json:"uri"`
	ID               string   `json:"id"`
	Name             string   `json:"name,omitempty"`
	MetricType       string   `json:"metric_type,omitempty"`
	MetricIDs        []string `json:"metric_ids,omitempty"`
	MetricProperties []string `json:"metric_properties,omitempty"`
	// NumericThresholds by name: LowerCritical, LowerWarning, UpperCritical,
	// UpperWarning.
	NumericThresholds map[string]Threshold `json:"numeric_thresholds,omitempty"`
	// DiscreteTriggerCondition and the number of DiscreteTriggers.
	DiscreteTriggerCondition string   `json:"discrete_trigger_condition,omitempty"`
	DiscreteTriggers         int      `json:"discrete_triggers,omitempty"`
	EventTriggers            []string `json:"event_triggers,omitempty"`
	// TriggerActions are LogToLogService, RedfishEvent and RedfishMetricReport.
	TriggerActions []string `json:"trigger_actions,omitempty"`
	TriggerEnabled *bool    `json:"trigger_enabled,omitempty"`
	State          string   `json:"state,omitempty"`
	Health         string   `json:"health,omitempty"`
}

Trigger is a Triggers resource (Triggers 1.4.0): a condition that applies to metrics. It is read, not written.

func ParseTrigger added in v0.14.0

func ParseTrigger(uri string, data []byte) (Trigger, error)

ParseTrigger decodes a Triggers resource read at uri.

type TrustedComponent added in v0.15.0

type TrustedComponent struct {
	URI        string `json:"uri"`
	ID         string `json:"id"`
	ChassisURI string `json:"chassis_uri,omitempty"`
	Name       string `json:"name,omitempty"`
	// Type is Discrete or Integrated.
	Type            string `json:"type,omitempty"`
	FirmwareVersion string `json:"firmware_version,omitempty"`
	Manufacturer    string `json:"manufacturer,omitempty"`
	Model           string `json:"model,omitempty"`
	PartNumber      string `json:"part_number,omitempty"`
	SKU             string `json:"sku,omitempty"`
	SerialNumber    string `json:"serial_number,omitempty"`
	UUID            string `json:"uuid,omitempty"`
	State           string `json:"state,omitempty"`
	Health          string `json:"health,omitempty"`
	// TPM vendor identifiers, when the component is a TPM.
	TPMCapabilitiesVendorID      string `json:"tpm_capabilities_vendor_id,omitempty"`
	TPMHardwareInterfaceVendorID string `json:"tpm_hardware_interface_vendor_id,omitempty"`
	CertificatesURI              string `json:"certificates_uri,omitempty"`
	// Links: the ComponentIntegrity resources it is responsible for, the
	// components it protects, its active image, owner and host.
	ComponentIntegrity  []string `json:"component_integrity,omitempty"`
	ComponentsProtected []string `json:"components_protected,omitempty"`
	ActiveSoftwareImage string   `json:"active_software_image,omitempty"`
	IntegratedInto      string   `json:"integrated_into,omitempty"`
	Owner               string   `json:"owner,omitempty"`
	// TPMClear and TPMGetEventLog are true when the component has the action
	// (neither is run by this client).
	TPMClear       bool `json:"tpm_clear"`
	TPMGetEventLog bool `json:"tpm_get_event_log"`
}

TrustedComponent is a TrustedComponent resource (1.5.0) of a chassis.

func ParseTrustedComponent added in v0.15.0

func ParseTrustedComponent(uri string, data []byte) (TrustedComponent, error)

ParseTrustedComponent decodes a TrustedComponent resource read at uri.

type UpdateCapabilities added in v0.8.0

type UpdateCapabilities struct {
	// MultipartSupported: the UpdateService has MultipartHttpPushUri.
	MultipartSupported bool `json:"multipart_supported"`
	// Entries maps each action (its title, else its key) to the transfer protocols
	// it allows.
	Entries map[string][]string `json:"entries"`
}

UpdateCapabilities is what GetFirmwareUpdateCapabilities reports.

func ParseUpdateCapabilities added in v0.8.0

func ParseUpdateCapabilities(data []byte) (UpdateCapabilities, error)

ParseUpdateCapabilities decodes an UpdateService resource (get_firmware_update_capabilities): ErrUnsupported when it has no Actions or an empty one.

type UpdateResult added in v0.8.0

type UpdateResult struct {
	Outcome
	Status UpdateStatus
}

UpdateResult is an update that was requested: what was done, and the status of the operation.

type UpdateStatus added in v0.8.0

type UpdateStatus struct {
	// Status is the TaskState (or JobState) of the task, or the one the status
	// code implies: Completed, New, Exception.
	Status   string    `json:"status"`
	Messages []Message `json:"messages"`
	// Handle is the task monitor to follow; empty once the operation is complete.
	Handle string `json:"handle,omitempty"`
	// ResetsRequested are the resets the update needs to continue.
	ResetsRequested []ResetRequest `json:"resets_requested"`
}

UpdateStatus is the status of an update operation (_operation_results).

func ParseUpdateStatus added in v0.8.0

func ParseUpdateStatus(code int, location string, body []byte, handle string) UpdateStatus

ParseUpdateStatus builds the status of an operation from the answer to it: its status code, its Location header, its body, and the handle the caller last used (_operation_results). The task monitor, the status and the messages come from the body when it is a Task or a Job, else from the error object's extended information; an OperationTransitionedToJob message moves the handle to the job, and a ResetRequired message adds a reset to ResetsRequested (only when it names a resource of the service).

type VirtualMediaOptions added in v0.6.0

type VirtualMediaOptions struct {
	// ImageURL is the image to insert (required).
	ImageURL string
	// MediaTypes selects a slot that supports one of them (CD, DVD, Floppy,
	// USBStick...); empty: any slot.
	MediaTypes []string
	// Inserted and WriteProtected are sent when not nil (the module's defaults
	// are both true).
	Inserted, WriteProtected *bool
	// Username and Password give access to the image; TransferProtocolType and
	// TransferMethod say how to fetch it.
	Username, Password, TransferProtocolType, TransferMethod string
}

VirtualMediaOptions are the options of VirtualMediaInsert (the module's virtual_media dict).

type VolumeRequest added in v0.9.0

type VolumeRequest struct {
	// Details are the properties of the new Volume: RAIDType is required; Name,
	// CapacityBytes and others are sent as given.
	Details Props
	// Drives are the paths of the drives it uses (Links.Drives): required.
	Drives []string
	// DeleteNoneVolumes first deletes the volumes of RAIDType None of the
	// subsystem (storage_none_volume_deletion). It destroys data.
	DeleteNoneVolumes bool
	// OnDelete, when set, is called with the paths about to be deleted by
	// DeleteNoneVolumes, before the first DELETE.
	OnDelete func(uris []string)
}

VolumeRequest is a volume to create (create_volume's volume_details).

type VolumeResult added in v0.9.0

type VolumeResult struct {
	Outcome
	Monitors []string
}

VolumeResult is what CreateVolume and DeleteVolumes did: Monitors are the task monitors of every request that answered 202 (Monitor is the first of them).

type Wildcard added in v0.14.0

type Wildcard struct {
	Name   string   `json:"name"`
	Values []string `json:"values,omitempty"`
}

Wildcard is a wildcard of a MetricProperties URI and the values that replace it (`*` stands for all the possible values).

type X509Info added in v0.11.0

type X509Info struct {
	Version            int       `json:"version"`
	SerialNumber       string    `json:"serial_number"`
	Subject            string    `json:"subject"`
	Issuer             string    `json:"issuer"`
	NotBefore          time.Time `json:"not_before"`
	NotAfter           time.Time `json:"not_after"`
	SignatureAlgorithm string    `json:"signature_algorithm"`
	PublicKeyAlgorithm string    `json:"public_key_algorithm"`
	KeyBits            int       `json:"key_bits,omitempty"`
	KeyCurve           string    `json:"key_curve,omitempty"`
	// KeyUsage names the usages as the Certificate schema's KeyUsage enumeration does:
	// the Key Usage bits and the Extended Key Usage values of RFC 5280 4.2.1.3, 4.2.1.12.
	KeyUsage       []string `json:"key_usage,omitempty"`
	DNSNames       []string `json:"dns_names,omitempty"`
	IPAddresses    []string `json:"ip_addresses,omitempty"`
	EmailAddresses []string `json:"email_addresses,omitempty"`
	IsCA           bool     `json:"is_ca"`
	SelfSigned     bool     `json:"self_signed"`
	// SHA256Fingerprint is the SHA-256 of the DER, colon-separated hex.
	SHA256Fingerprint string `json:"sha256_fingerprint"`
	// ChainLength is the number of certificates in the string.
	ChainLength int `json:"chain_length"`
	// PrivateKeyPresent is true when the string carries a private key block, which
	// the schema has a service remove from its responses; the key is not read.
	PrivateKeyPresent bool `json:"private_key_present,omitempty"`
}

X509Info is what crypto/x509 reads in a certificate (RFC 5280): the first certificate of the string is the leaf, the others make the chain.

func ParseX509 added in v0.11.0

func ParseX509(certString string) (X509Info, error)

ParseX509 decodes the PEM string of a Certificate (type PEM or PEMchain, RFC 5280 structures) with crypto/x509. It is read-only and bounded: a string over MaxCertificateString or with more than 16 certificates is refused, and private key blocks are skipped without being parsed. It never panics.

Directories

Path Synopsis
cmd
redfish command
redfish is a command-line client for the DMTF Redfish API of a BMC, built on github.com/go-redfish/redfish, and a mock BMC to try it against.
redfish is a command-line client for the DMTF Redfish API of a BMC, built on github.com/go-redfish/redfish, and a mock BMC to try it against.
internal
fuzzmatrix command
Command fuzzmatrix prints the GitHub Actions matrix of every fuzz target in the module, found by parsing the *_test.go files, so a new Fuzz function is scheduled by fuzz-long.yml without anyone listing it by hand.
Command fuzzmatrix prints the GitHub Actions matrix of every fuzz target in the module, found by parsing the *_test.go files, so a new Fuzz function is scheduled by fuzz-long.yml without anyone listing it by hand.
Package mockbmc is a Redfish service for tests and for `redfish mock serve`: the DMTF "public-rackmount1" mockup (DSP2043, BSD-3-Clause, vendored under testdata with its licence) served by an http.Handler that is stateful enough to be driven the way a real BMC is.
Package mockbmc is a Redfish service for tests and for `redfish mock serve`: the DMTF "public-rackmount1" mockup (DSP2043, BSD-3-Clause, vendored under testdata with its licence) served by an http.Handler that is stateful enough to be driven the way a real BMC is.

Jump to

Keyboard shortcuts

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