github.com/influxdata/influxdb/v2@v2.7.6/status.go (about)

     1  package influxdb
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/influxdata/influxdb/v2/kit/platform/errors"
     7  )
     8  
     9  // Status defines if a resource is active or inactive.
    10  type Status string
    11  
    12  const (
    13  	// Active status means that the resource can be used.
    14  	Active Status = "active"
    15  	// Inactive status means that the resource cannot be used.
    16  	Inactive Status = "inactive"
    17  )
    18  
    19  // Valid determines if a Status value matches the enum.
    20  func (s Status) Valid() error {
    21  	switch s {
    22  	case Active, Inactive:
    23  		return nil
    24  	default:
    25  		return &errors.Error{
    26  			Code: errors.EInvalid,
    27  			Msg:  fmt.Sprintf("invalid status: must be %v or %v", Active, Inactive),
    28  		}
    29  	}
    30  }
    31  
    32  // Ptr returns the pointer of that status.
    33  func (s Status) Ptr() *Status {
    34  	return &s
    35  }