1// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
3package bsky
4
5// schema: app.bsky.labeler.service
6
7import (
8 "bytes"
9 "encoding/json"
10 "fmt"
11 "io"
12
13 comatprototypes "github.com/bluesky-social/indigo/api/atproto"
14 "github.com/bluesky-social/indigo/lex/util"
15 cbg "github.com/whyrusleeping/cbor-gen"
16)
17
18func init() {
19 util.RegisterType("app.bsky.labeler.service", &LabelerService{})
20} //
21// RECORDTYPE: LabelerService
22type LabelerService struct {
23 LexiconTypeID string `json:"$type,const=app.bsky.labeler.service" cborgen:"$type,const=app.bsky.labeler.service"`
24 CreatedAt string `json:"createdAt" cborgen:"createdAt"`
25 Labels *LabelerService_Labels `json:"labels,omitempty" cborgen:"labels,omitempty"`
26 Policies *LabelerDefs_LabelerPolicies `json:"policies" cborgen:"policies"`
27 // reasonTypes: The set of report reason 'codes' which are in-scope for this service to review and action. These usually align to policy categories. If not defined (distinct from empty array), all reason types are allowed.
28 ReasonTypes []*string `json:"reasonTypes,omitempty" cborgen:"reasonTypes,omitempty"`
29 // subjectCollections: Set of record types (collection NSIDs) which can be reported to this service. If not defined (distinct from empty array), default is any record type.
30 SubjectCollections []string `json:"subjectCollections,omitempty" cborgen:"subjectCollections,omitempty"`
31 // subjectTypes: The set of subject types (account, record, etc) this service accepts reports on.
32 SubjectTypes []*string `json:"subjectTypes,omitempty" cborgen:"subjectTypes,omitempty"`
33}
34
35type LabelerService_Labels struct {
36 LabelDefs_SelfLabels *comatprototypes.LabelDefs_SelfLabels
37}
38
39func (t *LabelerService_Labels) MarshalJSON() ([]byte, error) {
40 if t.LabelDefs_SelfLabels != nil {
41 t.LabelDefs_SelfLabels.LexiconTypeID = "com.atproto.label.defs#selfLabels"
42 return json.Marshal(t.LabelDefs_SelfLabels)
43 }
44 return nil, fmt.Errorf("cannot marshal empty enum")
45}
46func (t *LabelerService_Labels) UnmarshalJSON(b []byte) error {
47 typ, err := util.TypeExtract(b)
48 if err != nil {
49 return err
50 }
51
52 switch typ {
53 case "com.atproto.label.defs#selfLabels":
54 t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
55 return json.Unmarshal(b, t.LabelDefs_SelfLabels)
56
57 default:
58 return nil
59 }
60}
61
62func (t *LabelerService_Labels) MarshalCBOR(w io.Writer) error {
63
64 if t == nil {
65 _, err := w.Write(cbg.CborNull)
66 return err
67 }
68 if t.LabelDefs_SelfLabels != nil {
69 return t.LabelDefs_SelfLabels.MarshalCBOR(w)
70 }
71 return fmt.Errorf("cannot cbor marshal empty enum")
72}
73func (t *LabelerService_Labels) UnmarshalCBOR(r io.Reader) error {
74 typ, b, err := util.CborTypeExtractReader(r)
75 if err != nil {
76 return err
77 }
78
79 switch typ {
80 case "com.atproto.label.defs#selfLabels":
81 t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
82 return t.LabelDefs_SelfLabels.UnmarshalCBOR(bytes.NewReader(b))
83
84 default:
85 return nil
86 }
87}