mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Separate graphql API from rest of the system (#2503)
* Move graphql generated files to api * Refactor identify options * Remove models.StashBoxes * Move ScraperSource to scraper package * Rename field strategy enums * Rename identify.TaskOptions to Options
This commit is contained in:
50
pkg/models/import.go
Normal file
50
pkg/models/import.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type ImportMissingRefEnum string
|
||||
|
||||
const (
|
||||
ImportMissingRefEnumIgnore ImportMissingRefEnum = "IGNORE"
|
||||
ImportMissingRefEnumFail ImportMissingRefEnum = "FAIL"
|
||||
ImportMissingRefEnumCreate ImportMissingRefEnum = "CREATE"
|
||||
)
|
||||
|
||||
var AllImportMissingRefEnum = []ImportMissingRefEnum{
|
||||
ImportMissingRefEnumIgnore,
|
||||
ImportMissingRefEnumFail,
|
||||
ImportMissingRefEnumCreate,
|
||||
}
|
||||
|
||||
func (e ImportMissingRefEnum) IsValid() bool {
|
||||
switch e {
|
||||
case ImportMissingRefEnumIgnore, ImportMissingRefEnumFail, ImportMissingRefEnumCreate:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e ImportMissingRefEnum) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e *ImportMissingRefEnum) UnmarshalGQL(v interface{}) error {
|
||||
str, ok := v.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("enums must be strings")
|
||||
}
|
||||
|
||||
*e = ImportMissingRefEnum(str)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid ImportMissingRefEnum", str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e ImportMissingRefEnum) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
Reference in New Issue
Block a user