-
Notifications
You must be signed in to change notification settings - Fork 0
/
metriclimit.go
executable file
·215 lines (181 loc) · 6.72 KB
/
metriclimit.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package polar
import (
"context"
"net/http"
"time"
"github.com/polarsource/polar-go/internal/apijson"
"github.com/polarsource/polar-go/internal/requestconfig"
"github.com/polarsource/polar-go/option"
)
// MetricLimitService contains methods and other services that help with
// interacting with the polar API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewMetricLimitService] method instead.
type MetricLimitService struct {
Options []option.RequestOption
}
// NewMetricLimitService generates a new service that applies the given options to
// each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
func NewMetricLimitService(opts ...option.RequestOption) (r *MetricLimitService) {
r = &MetricLimitService{}
r.Options = opts
return
}
// Get the interval limits for the metrics endpoint.
func (r *MetricLimitService) Get(ctx context.Context, opts ...option.RequestOption) (res *MetricsLimits, err error) {
opts = append(r.Options[:], opts...)
path := "v1/metrics/limits"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// Date limits to get metrics.
type MetricsLimits struct {
// Date interval limits to get metrics for each interval.
Intervals MetricsLimitsIntervals `json:"intervals,required"`
// Minimum date to get metrics.
MinDate time.Time `json:"min_date,required" format:"date"`
JSON metricsLimitsJSON `json:"-"`
}
// metricsLimitsJSON contains the JSON metadata for the struct [MetricsLimits]
type metricsLimitsJSON struct {
Intervals apijson.Field
MinDate apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MetricsLimits) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r metricsLimitsJSON) RawJSON() string {
return r.raw
}
// Date interval limits to get metrics for each interval.
type MetricsLimitsIntervals struct {
// Date interval limit to get metrics for a given interval.
Day MetricsLimitsIntervalsDay `json:"day,required"`
// Date interval limit to get metrics for a given interval.
Hour MetricsLimitsIntervalsHour `json:"hour,required"`
// Date interval limit to get metrics for a given interval.
Month MetricsLimitsIntervalsMonth `json:"month,required"`
// Date interval limit to get metrics for a given interval.
Week MetricsLimitsIntervalsWeek `json:"week,required"`
// Date interval limit to get metrics for a given interval.
Year MetricsLimitsIntervalsYear `json:"year,required"`
JSON metricsLimitsIntervalsJSON `json:"-"`
}
// metricsLimitsIntervalsJSON contains the JSON metadata for the struct
// [MetricsLimitsIntervals]
type metricsLimitsIntervalsJSON struct {
Day apijson.Field
Hour apijson.Field
Month apijson.Field
Week apijson.Field
Year apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MetricsLimitsIntervals) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r metricsLimitsIntervalsJSON) RawJSON() string {
return r.raw
}
// Date interval limit to get metrics for a given interval.
type MetricsLimitsIntervalsDay struct {
// Maximum number of days for this interval.
MaxDays int64 `json:"max_days,required"`
JSON metricsLimitsIntervalsDayJSON `json:"-"`
}
// metricsLimitsIntervalsDayJSON contains the JSON metadata for the struct
// [MetricsLimitsIntervalsDay]
type metricsLimitsIntervalsDayJSON struct {
MaxDays apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MetricsLimitsIntervalsDay) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r metricsLimitsIntervalsDayJSON) RawJSON() string {
return r.raw
}
// Date interval limit to get metrics for a given interval.
type MetricsLimitsIntervalsHour struct {
// Maximum number of days for this interval.
MaxDays int64 `json:"max_days,required"`
JSON metricsLimitsIntervalsHourJSON `json:"-"`
}
// metricsLimitsIntervalsHourJSON contains the JSON metadata for the struct
// [MetricsLimitsIntervalsHour]
type metricsLimitsIntervalsHourJSON struct {
MaxDays apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MetricsLimitsIntervalsHour) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r metricsLimitsIntervalsHourJSON) RawJSON() string {
return r.raw
}
// Date interval limit to get metrics for a given interval.
type MetricsLimitsIntervalsMonth struct {
// Maximum number of days for this interval.
MaxDays int64 `json:"max_days,required"`
JSON metricsLimitsIntervalsMonthJSON `json:"-"`
}
// metricsLimitsIntervalsMonthJSON contains the JSON metadata for the struct
// [MetricsLimitsIntervalsMonth]
type metricsLimitsIntervalsMonthJSON struct {
MaxDays apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MetricsLimitsIntervalsMonth) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r metricsLimitsIntervalsMonthJSON) RawJSON() string {
return r.raw
}
// Date interval limit to get metrics for a given interval.
type MetricsLimitsIntervalsWeek struct {
// Maximum number of days for this interval.
MaxDays int64 `json:"max_days,required"`
JSON metricsLimitsIntervalsWeekJSON `json:"-"`
}
// metricsLimitsIntervalsWeekJSON contains the JSON metadata for the struct
// [MetricsLimitsIntervalsWeek]
type metricsLimitsIntervalsWeekJSON struct {
MaxDays apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MetricsLimitsIntervalsWeek) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r metricsLimitsIntervalsWeekJSON) RawJSON() string {
return r.raw
}
// Date interval limit to get metrics for a given interval.
type MetricsLimitsIntervalsYear struct {
// Maximum number of days for this interval.
MaxDays int64 `json:"max_days,required"`
JSON metricsLimitsIntervalsYearJSON `json:"-"`
}
// metricsLimitsIntervalsYearJSON contains the JSON metadata for the struct
// [MetricsLimitsIntervalsYear]
type metricsLimitsIntervalsYearJSON struct {
MaxDays apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MetricsLimitsIntervalsYear) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r metricsLimitsIntervalsYearJSON) RawJSON() string {
return r.raw
}