-
Notifications
You must be signed in to change notification settings - Fork 541
/
rankingdomain.go
226 lines (192 loc) · 7.95 KB
/
rankingdomain.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
216
217
218
219
220
221
222
223
224
225
226
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package radar
import (
"context"
"fmt"
"net/http"
"net/url"
"github.com/cloudflare/cloudflare-go/v2/internal/apijson"
"github.com/cloudflare/cloudflare-go/v2/internal/apiquery"
"github.com/cloudflare/cloudflare-go/v2/internal/param"
"github.com/cloudflare/cloudflare-go/v2/internal/requestconfig"
"github.com/cloudflare/cloudflare-go/v2/option"
)
// RankingDomainService contains methods and other services that help with
// interacting with the cloudflare 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 [NewRankingDomainService] method
// instead.
type RankingDomainService struct {
Options []option.RequestOption
}
// NewRankingDomainService 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 NewRankingDomainService(opts ...option.RequestOption) (r *RankingDomainService) {
r = &RankingDomainService{}
r.Options = opts
return
}
// Gets Domains Rank details. Cloudflare provides an ordered rank for the top 100
// domains, but for the remainder it only provides ranking buckets like top 200
// thousand, top one million, etc.. These are available through Radar datasets
// endpoints.
func (r *RankingDomainService) Get(ctx context.Context, domain string, query RankingDomainGetParams, opts ...option.RequestOption) (res *RankingDomainGetResponse, err error) {
opts = append(r.Options[:], opts...)
var env RankingDomainGetResponseEnvelope
path := fmt.Sprintf("radar/ranking/domain/%s", domain)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
type RankingDomainGetResponse struct {
Details0 RankingDomainGetResponseDetails0 `json:"details_0,required"`
JSON rankingDomainGetResponseJSON `json:"-"`
}
// rankingDomainGetResponseJSON contains the JSON metadata for the struct
// [RankingDomainGetResponse]
type rankingDomainGetResponseJSON struct {
Details0 apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RankingDomainGetResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rankingDomainGetResponseJSON) RawJSON() string {
return r.raw
}
type RankingDomainGetResponseDetails0 struct {
Categories []RankingDomainGetResponseDetails0Category `json:"categories,required"`
TopLocations []RankingDomainGetResponseDetails0TopLocation `json:"top_locations,required"`
// Only available in POPULAR ranking for the most recent ranking.
Bucket string `json:"bucket"`
Rank int64 `json:"rank"`
JSON rankingDomainGetResponseDetails0JSON `json:"-"`
}
// rankingDomainGetResponseDetails0JSON contains the JSON metadata for the struct
// [RankingDomainGetResponseDetails0]
type rankingDomainGetResponseDetails0JSON struct {
Categories apijson.Field
TopLocations apijson.Field
Bucket apijson.Field
Rank apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RankingDomainGetResponseDetails0) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rankingDomainGetResponseDetails0JSON) RawJSON() string {
return r.raw
}
type RankingDomainGetResponseDetails0Category struct {
ID float64 `json:"id,required"`
Name string `json:"name,required"`
SuperCategoryID float64 `json:"superCategoryId,required"`
JSON rankingDomainGetResponseDetails0CategoryJSON `json:"-"`
}
// rankingDomainGetResponseDetails0CategoryJSON contains the JSON metadata for the
// struct [RankingDomainGetResponseDetails0Category]
type rankingDomainGetResponseDetails0CategoryJSON struct {
ID apijson.Field
Name apijson.Field
SuperCategoryID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RankingDomainGetResponseDetails0Category) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rankingDomainGetResponseDetails0CategoryJSON) RawJSON() string {
return r.raw
}
type RankingDomainGetResponseDetails0TopLocation struct {
LocationCode string `json:"locationCode,required"`
LocationName string `json:"locationName,required"`
Rank int64 `json:"rank,required"`
JSON rankingDomainGetResponseDetails0TopLocationJSON `json:"-"`
}
// rankingDomainGetResponseDetails0TopLocationJSON contains the JSON metadata for
// the struct [RankingDomainGetResponseDetails0TopLocation]
type rankingDomainGetResponseDetails0TopLocationJSON struct {
LocationCode apijson.Field
LocationName apijson.Field
Rank apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RankingDomainGetResponseDetails0TopLocation) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rankingDomainGetResponseDetails0TopLocationJSON) RawJSON() string {
return r.raw
}
type RankingDomainGetParams struct {
// Array of dates to filter the ranking.
Date param.Field[[]string] `query:"date"`
// Format results are returned in.
Format param.Field[RankingDomainGetParamsFormat] `query:"format"`
// Limit the number of objects in the response.
Limit param.Field[int64] `query:"limit"`
// Array of names that will be used to name the series in responses.
Name param.Field[[]string] `query:"name"`
// The ranking type.
RankingType param.Field[RankingDomainGetParamsRankingType] `query:"rankingType"`
}
// URLQuery serializes [RankingDomainGetParams]'s query parameters as `url.Values`.
func (r RankingDomainGetParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// Format results are returned in.
type RankingDomainGetParamsFormat string
const (
RankingDomainGetParamsFormatJson RankingDomainGetParamsFormat = "JSON"
RankingDomainGetParamsFormatCsv RankingDomainGetParamsFormat = "CSV"
)
func (r RankingDomainGetParamsFormat) IsKnown() bool {
switch r {
case RankingDomainGetParamsFormatJson, RankingDomainGetParamsFormatCsv:
return true
}
return false
}
// The ranking type.
type RankingDomainGetParamsRankingType string
const (
RankingDomainGetParamsRankingTypePopular RankingDomainGetParamsRankingType = "POPULAR"
RankingDomainGetParamsRankingTypeTrendingRise RankingDomainGetParamsRankingType = "TRENDING_RISE"
RankingDomainGetParamsRankingTypeTrendingSteady RankingDomainGetParamsRankingType = "TRENDING_STEADY"
)
func (r RankingDomainGetParamsRankingType) IsKnown() bool {
switch r {
case RankingDomainGetParamsRankingTypePopular, RankingDomainGetParamsRankingTypeTrendingRise, RankingDomainGetParamsRankingTypeTrendingSteady:
return true
}
return false
}
type RankingDomainGetResponseEnvelope struct {
Result RankingDomainGetResponse `json:"result,required"`
Success bool `json:"success,required"`
JSON rankingDomainGetResponseEnvelopeJSON `json:"-"`
}
// rankingDomainGetResponseEnvelopeJSON contains the JSON metadata for the struct
// [RankingDomainGetResponseEnvelope]
type rankingDomainGetResponseEnvelopeJSON struct {
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RankingDomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rankingDomainGetResponseEnvelopeJSON) RawJSON() string {
return r.raw
}