Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions bmc/certificate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package bmc

import "context"

// CSRRequest describes a certificate-signing-request to generate.
type CSRRequest struct {
// CommonName is the fully-qualified domain name of the entity (required).
CommonName string
// Country, State, City, Organization, OrganizationalUnit and Email are the
// optional distinguished-name fields.
Country string
State string
City string
Organization string
OrganizationalUnit string
Email string
// CertificateCollection is the target certificate collection @odata.id. When
// empty the provider uses its default (the BMC HTTPS certificate collection).
CertificateCollection string
}

// CertificateInfo describes an installed certificate.
type CertificateInfo struct {
// ID is the Redfish Certificate Id.
ID string
// SubjectCommonName is the certificate subject common name.
SubjectCommonName string
// IssuerCommonName is the certificate issuer common name.
IssuerCommonName string
// ValidNotBefore / ValidNotAfter are the validity bounds.
ValidNotBefore string
ValidNotAfter string
}

// CertificateManager is implemented by providers that can manage BMC
// certificates.
type CertificateManager interface {
// CertificateLocations returns the @odata.id locations of installed
// certificates.
CertificateLocations(ctx context.Context) ([]string, error)
// Certificate returns a certificate's properties by its @odata.id location.
Certificate(ctx context.Context, location string) (CertificateInfo, error)
// GenerateCSR generates a certificate-signing-request and returns the PEM CSR.
GenerateCSR(ctx context.Context, req *CSRRequest) (csr string, err error)
// ReplaceCertificate replaces the certificate at targetURI with the given PEM
// certificate.
ReplaceCertificate(ctx context.Context, certificatePEM, targetURI string) error
// RekeyCertificate generates a new key pair and CSR for the certificate at
// certURI.
RekeyCertificate(ctx context.Context, certURI string) error
// RenewCertificate generates a CSR using the existing key for the certificate
// at certURI.
RenewCertificate(ctx context.Context, certURI string) error
}
56 changes: 56 additions & 0 deletions bmc/event_subscription.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package bmc

import "context"

// EventServiceInfo describes the Redfish EventService configuration.
type EventServiceInfo struct {
// ServiceEnabled reports whether the event service is enabled.
ServiceEnabled bool
// DeliveryRetryAttempts is the number of delivery retry attempts.
DeliveryRetryAttempts int
// DeliveryRetryIntervalSeconds is the delivery retry interval.
DeliveryRetryIntervalSeconds int
// SSEFilterURI is the Server-Sent-Events stream URI, when supported.
SSEFilterURI string
}

// EventSubscription describes an event destination (subscription).
type EventSubscription struct {
// ID is the Redfish subscription Id.
ID string
// Destination is the subscription delivery URL.
Destination string
// Protocol is the subscription protocol (e.g. "Redfish").
Protocol string
// Context is the opaque client context echoed in events.
Context string
}

// EventSubscriptionRequest describes a subscription to create.
type EventSubscriptionRequest struct {
// Destination is the delivery URL (required).
Destination string
// Protocol is the subscription protocol (defaults to "Redfish" when empty).
Protocol string
// Context is an opaque client context.
Context string
// RegistryPrefixes optionally filters the message-registry prefixes.
RegistryPrefixes []string
}

// EventSubscriber is implemented by providers that can read the event service
// and manage event subscriptions.
type EventSubscriber interface {
// EventService returns the event-service configuration.
EventService(ctx context.Context) (EventServiceInfo, error)
// EventSubscriptions lists the event subscriptions.
EventSubscriptions(ctx context.Context) ([]EventSubscription, error)
// EventSubscriptionCreate creates a subscription and returns its Id.
EventSubscriptionCreate(ctx context.Context, req EventSubscriptionRequest) (id string, err error)
// EventSubscriptionDelete deletes a subscription by Id.
EventSubscriptionDelete(ctx context.Context, id string) error
// SubmitTestEvent submits a test event (optionally for a specific MessageId).
SubmitTestEvent(ctx context.Context, messageID string) error
// SetEventService PATCHes event-service properties.
SetEventService(ctx context.Context, attrs map[string]any) error
}
Loading
Loading