~bigbes/sr-ht-spec

ref: 2928bf9d79d9ae999a27c74ee5811693489a3a4e sr-ht-spec/graph/model/models_gen.go -rw-r--r-- 2.1 KiB
2928bf9d — bigbes feat(cmd): specsrht space create/list 27 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.

package model

import (
	"fmt"
	"io"
	"strconv"
)

// How a merge was authorized. Auto-merged is not human-approved, and readers must
// be able to tell: a bot asking for the approved text of a spec should be able to
// require human approval and get a different answer than for a firehose note.
type Approval string

const (
	ApprovalHuman  Approval = "HUMAN"
	ApprovalPolicy Approval = "POLICY"
)

var AllApproval = []Approval{
	ApprovalHuman,
	ApprovalPolicy,
}

func (e Approval) IsValid() bool {
	switch e {
	case ApprovalHuman, ApprovalPolicy:
		return true
	}
	return false
}

func (e Approval) String() string {
	return string(e)
}

func (e *Approval) UnmarshalGQL(v interface{}) error {
	str, ok := v.(string)
	if !ok {
		return fmt.Errorf("enums must be strings")
	}

	*e = Approval(str)
	if !e.IsValid() {
		return fmt.Errorf("%s is not a valid Approval", str)
	}
	return nil
}

func (e Approval) MarshalGQL(w io.Writer) {
	fmt.Fprint(w, strconv.Quote(e.String()))
}

// The lifecycle of a proposal. Collapsed from the usual five states because there
// is exactly one reviewer: "approve" is "merge now", and a proposal you dislike is
// rejected rather than sent back for changes.
type ProposalState string

const (
	ProposalStateOpen     ProposalState = "OPEN"
	ProposalStateMerged   ProposalState = "MERGED"
	ProposalStateRejected ProposalState = "REJECTED"
)

var AllProposalState = []ProposalState{
	ProposalStateOpen,
	ProposalStateMerged,
	ProposalStateRejected,
}

func (e ProposalState) IsValid() bool {
	switch e {
	case ProposalStateOpen, ProposalStateMerged, ProposalStateRejected:
		return true
	}
	return false
}

func (e ProposalState) String() string {
	return string(e)
}

func (e *ProposalState) UnmarshalGQL(v interface{}) error {
	str, ok := v.(string)
	if !ok {
		return fmt.Errorf("enums must be strings")
	}

	*e = ProposalState(str)
	if !e.IsValid() {
		return fmt.Errorf("%s is not a valid ProposalState", str)
	}
	return nil
}

func (e ProposalState) MarshalGQL(w io.Writer) {
	fmt.Fprint(w, strconv.Quote(e.String()))
}