mirror of
https://github.com/inexio/thola.git
synced 2026-10-24 03:08:55 +03:00
30 lines
902 B
Go
30 lines
902 B
Go
package request
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/inexio/go-monitoringplugin"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// CheckHighAvailabilityRequest
|
|
//
|
|
// CheckHighAvailabilityRequest is the request struct for the check high-availability request.
|
|
//
|
|
// swagger:model
|
|
type CheckHighAvailabilityRequest struct {
|
|
CheckDeviceRequest
|
|
Role *string `yaml:"role" json:"role" xml:"role"`
|
|
NodesThresholds monitoringplugin.Thresholds `yaml:"nodes_thresholds" json:"nodes_thresholds" xml:"nodes_thresholds"`
|
|
}
|
|
|
|
func (r *CheckHighAvailabilityRequest) validate(ctx context.Context) error {
|
|
if r.Role != nil && *r.Role != "master" && *r.Role != "slave" {
|
|
return fmt.Errorf("invalid high-availability role '%s'", *r.Role)
|
|
}
|
|
if err := r.NodesThresholds.Validate(); err != nil {
|
|
return errors.Wrap(err, "nodes thresholds are invalid")
|
|
}
|
|
return r.CheckDeviceRequest.validate(ctx)
|
|
}
|