2019-01-08 00:37:16 +00:00
|
|
|
package influxdb
|
2018-08-28 18:01:32 +00:00
|
|
|
|
2021-03-30 18:10:02 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/influxdata/influxdb/v2/kit/platform/errors"
|
|
|
|
)
|
2018-12-28 23:02:19 +00:00
|
|
|
|
2018-08-28 18:01:32 +00:00
|
|
|
// Status defines if a resource is active or inactive.
|
|
|
|
type Status string
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Active status means that the resource can be used.
|
|
|
|
Active Status = "active"
|
|
|
|
// Inactive status means that the resource cannot be used.
|
|
|
|
Inactive Status = "inactive"
|
|
|
|
)
|
2018-12-28 23:02:19 +00:00
|
|
|
|
|
|
|
// Valid determines if a Status value matches the enum.
|
|
|
|
func (s Status) Valid() error {
|
|
|
|
switch s {
|
|
|
|
case Active, Inactive:
|
|
|
|
return nil
|
|
|
|
default:
|
2021-03-30 18:10:02 +00:00
|
|
|
return &errors.Error{
|
|
|
|
Code: errors.EInvalid,
|
2018-12-28 23:02:19 +00:00
|
|
|
Msg: fmt.Sprintf("invalid status: must be %v or %v", Active, Inactive),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-27 19:02:45 +00:00
|
|
|
|
|
|
|
// Ptr returns the pointer of that status.
|
|
|
|
func (s Status) Ptr() *Status {
|
|
|
|
return &s
|
|
|
|
}
|