-
Notifications
You must be signed in to change notification settings - Fork 0
/
aggregate.go
94 lines (81 loc) · 2.45 KB
/
aggregate.go
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
// This file was auto-generated by Fern from our API Definition.
package api
import (
json "encoding/json"
fmt "fmt"
)
type QueryBatch struct {
Timeframe *QueryBatchTimeframe `json:"timeframe,omitempty" url:"-"`
Queries []*Query `json:"queries,omitempty" url:"-"`
Config *QueryConfig `json:"config,omitempty" url:"-"`
accept string
}
func (q *QueryBatch) Accept() string {
return q.accept
}
func (q *QueryBatch) UnmarshalJSON(data []byte) error {
type unmarshaler QueryBatch
var body unmarshaler
if err := json.Unmarshal(data, &body); err != nil {
return err
}
*q = QueryBatch(body)
q.accept = "*/*"
return nil
}
func (q *QueryBatch) MarshalJSON() ([]byte, error) {
type embed QueryBatch
var marshaler = struct {
embed
Accept string `json:"accept"`
}{
embed: embed(*q),
Accept: "*/*",
}
return json.Marshal(marshaler)
}
type QueryBatchTimeframe struct {
RelativeTimeframe *RelativeTimeframe
Placeholder *Placeholder
}
func NewQueryBatchTimeframeFromRelativeTimeframe(value *RelativeTimeframe) *QueryBatchTimeframe {
return &QueryBatchTimeframe{RelativeTimeframe: value}
}
func NewQueryBatchTimeframeFromPlaceholder(value *Placeholder) *QueryBatchTimeframe {
return &QueryBatchTimeframe{Placeholder: value}
}
func (q *QueryBatchTimeframe) UnmarshalJSON(data []byte) error {
valueRelativeTimeframe := new(RelativeTimeframe)
if err := json.Unmarshal(data, &valueRelativeTimeframe); err == nil {
q.RelativeTimeframe = valueRelativeTimeframe
return nil
}
valuePlaceholder := new(Placeholder)
if err := json.Unmarshal(data, &valuePlaceholder); err == nil {
q.Placeholder = valuePlaceholder
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, q)
}
func (q QueryBatchTimeframe) MarshalJSON() ([]byte, error) {
if q.RelativeTimeframe != nil {
return json.Marshal(q.RelativeTimeframe)
}
if q.Placeholder != nil {
return json.Marshal(q.Placeholder)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", q)
}
type QueryBatchTimeframeVisitor interface {
VisitRelativeTimeframe(*RelativeTimeframe) error
VisitPlaceholder(*Placeholder) error
}
func (q *QueryBatchTimeframe) Accept(visitor QueryBatchTimeframeVisitor) error {
if q.RelativeTimeframe != nil {
return visitor.VisitRelativeTimeframe(q.RelativeTimeframe)
}
if q.Placeholder != nil {
return visitor.VisitPlaceholder(q.Placeholder)
}
return fmt.Errorf("type %T does not include a non-empty union type", q)
}