GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

51 lines
1.2 KiB

package models
import (
"fmt"
"io"
"strconv"
)
// LogImporter describes a model related log importing.
type LogImporter string
const (
// LogImporterMircLike is a value of LogImporter
LogImporterMircLike LogImporter = "MircLike"
// LogImporterForumLog is a value of LogImporter
LogImporterForumLog LogImporter = "ForumLog"
// LogImporterForumLog is a value of LogImporter
LogImporterIrcCloud LogImporter = "IrcCloud"
)
// IsValid returns true if the underlying string is one of the correct values.
func (e LogImporter) IsValid() bool {
switch e {
case LogImporterForumLog, LogImporterMircLike, LogImporterIrcCloud:
return true
}
return false
}
func (e LogImporter) String() string {
return string(e)
}
// UnmarshalGQL unmarshals the underlying graphql value.
func (e *LogImporter) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*e = LogImporter(str)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid LogImporter", str)
}
return nil
}
// MarshalGQL marshals the underlying graphql value.
func (e LogImporter) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(e.String()))
}