-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlobalApiComponents.php
More file actions
348 lines (345 loc) · 12.7 KB
/
GlobalApiComponents.php
File metadata and controls
348 lines (345 loc) · 12.7 KB
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\OpenApiDocs\Annotations;
/**
* Global components for generating OpenAPI specs for the Matomo Reporting API.
*
* @OA\OpenApi(
* openapi="3.1.0",
* security={{"MatomoToken": {}}},
* @OA\ExternalDocumentation(
* description="Matomo Reporting API developer page",
* url="https://developer.matomo.org/api-reference/reporting-api/"
* )
* )
*
* @OA\Info(
* title="Matomo Reporting API",
* version="1.0.0"
* )
*
* @OA\Tag(
* name="matomo",
* description="Matomo API"
* )
*
* @OA\SecurityScheme(
* securityScheme="MatomoToken",
* type="apiKey",
* in="query",
* name="token_auth",
* description="Matomo API token passed as the 'token_auth' query parameter."
* )
*
* @OA\Server(
* url=LOCAL_MATOMO_SERVER_URL,
* description="Current Matomo instance"
* )
*
* @OA\Server(
* url="https://demo.matomo.cloud/",
* description="Matomo demo server"
* )
*
* Generic Error object
* @OA\Schema(
* schema="Error",
* type="object",
* description="Generic Matomo error payload.",
* required={"result","message"},
* additionalProperties=true,
* @OA\Property(property="result", type="string", enum={"error"}, example="error"),
* @OA\Property(property="message", type="string", example="You can't access this resource"),
* @OA\Property(property="code", type="integer", nullable=true, example=401)
* )
*
* Common responses which should be used by each API endpoint
* @OA\Response(
* response="BadRequest",
* description="Bad request (validation or missing parameters).",
* @OA\JsonContent(ref="#/components/schemas/Error"),
* @OA\XmlContent(ref="#/components/schemas/Error"),
* @OA\MediaType(mediaType="text/plain", @OA\Schema(type="string")),
* @OA\MediaType(mediaType="text/html", @OA\Schema(type="string"))
* )
*
* @OA\Response(
* response="Unauthorized",
* description="Authentication failed or missing token.",
* @OA\JsonContent(ref="#/components/schemas/Error"),
* @OA\XmlContent(ref="#/components/schemas/Error"),
* @OA\MediaType(mediaType="text/plain", @OA\Schema(type="string")),
* @OA\MediaType(mediaType="text/html", @OA\Schema(type="string"))
* )
*
* @OA\Response(
* response="Forbidden",
* description="Authenticated but not allowed to access the resource.",
* @OA\JsonContent(ref="#/components/schemas/Error"),
* @OA\XmlContent(ref="#/components/schemas/Error"),
* @OA\MediaType(mediaType="text/plain", @OA\Schema(type="string")),
* @OA\MediaType(mediaType="text/html", @OA\Schema(type="string"))
* )
*
* @OA\Response(
* response="NotFound",
* description="Resource not found.",
* @OA\JsonContent(ref="#/components/schemas/Error"),
* @OA\XmlContent(ref="#/components/schemas/Error"),
* @OA\MediaType(mediaType="text/plain", @OA\Schema(type="string")),
* @OA\MediaType(mediaType="text/html", @OA\Schema(type="string"))
* )
*
* @OA\Response(
* response="ServerError",
* description="Unexpected server error.",
* @OA\JsonContent(ref="#/components/schemas/Error"),
* @OA\XmlContent(ref="#/components/schemas/Error"),
* @OA\MediaType(mediaType="text/plain", @OA\Schema(type="string")),
* @OA\MediaType(mediaType="text/html", @OA\Schema(type="string"))
* )
*
* @OA\Response(
* response="DefaultError",
* description="Default error response (any non-2xx).",
* @OA\JsonContent(ref="#/components/schemas/Error"),
* @OA\XmlContent(ref="#/components/schemas/Error"),
* @OA\MediaType(mediaType="text/plain", @OA\Schema(type="string")),
* @OA\MediaType(mediaType="text/html", @OA\Schema(type="string"))
* )
*
* Generic responses which can be used by endpoints
* @OA\Response(
* response="GenericSuccess",
* description="Generic 200 response with no body"
* )
*
* @OA\Response(
* response="GenericBoolean",
* description="Generic 200 response with only true or false as the body",
* @OA\JsonContent(type="boolean"),
* @OA\XmlContent(type="boolean"),
* @OA\MediaType(mediaType="text/plain", @OA\Schema(type="boolean")),
* @OA\MediaType(mediaType="text/html", @OA\Schema(type="boolean"))
* )
*
* @OA\Response(
* response="GenericInteger",
* description="Generic 200 response with only an integer as the body",
* @OA\JsonContent(type="integer"),
* @OA\XmlContent(type="integer"),
* @OA\MediaType(mediaType="text/plain", @OA\Schema(type="integer")),
* @OA\MediaType(mediaType="text/html", @OA\Schema(type="integer"))
* )
*
* @OA\Response(
* response="GenericArray",
* description="Generic 200 response with array body",
* @OA\JsonContent(type="array", @OA\Items({})),
* @OA\XmlContent(type="array", @OA\Items({})),
* @OA\MediaType(mediaType="text/plain", @OA\Schema(type="string")),
* @OA\MediaType(mediaType="text/html", @OA\Schema(type="string"))
* )
*
* Global parameters which apply to pretty much every API endpoint. If there are parameters not required by every
* endpoint, it will be declared as both required and optional so that each endpoint can specify the correct one.
* @OA\Parameter(
* parameter="moduleRequired",
* name="module",
* in="query",
* description="Always `API` for Reporting API requests.",
* required=true,
* @OA\Schema(type="string", default="API", example="API")
* )
*
* @OA\Parameter(
* parameter="methodRequired",
* name="method",
* in="query",
* description="API method, e.g. `VisitsSummary.get` or `CustomAlerts.getAlert`.",
* required=true,
* @OA\Schema(type="string"),
* example="CustomAlerts.getAlert"
* )
*
* @OA\Parameter(
* parameter="formatRequired",
* name="format",
* in="query",
* description="Response format such as `xml` or `json`. Use `original` to get the original PHP data structure.",
* required=true,
* @OA\Schema(
* type="string",
* enum={"xml","json","csv","tsv","html","rss","original"},
* default="xml"
* ),
* example="xml"
* )
*
* @OA\Parameter(
* parameter="formatOptional",
* name="format",
* in="query",
* description="Response format. Defaults to `xml`. Use `original` to get the original PHP data structure.",
* required=false,
* @OA\Schema(
* type="string",
* enum={"xml","json","csv","tsv","html","rss","original"},
* default="xml"
* ),
* example="xml"
* )
*
* Commonly used parameters. If there are parameters not required by every endpoint, it will be declared as both
* required and optional so that each endpoint can specify the correct one.
* @OA\Parameter(
* parameter="idSiteRequired",
* name="idSite",
* in="query",
* description="Matomo site ID.",
* required=true,
* @OA\Schema(type="integer"),
* example=1
* )
*
* @OA\Parameter(
* parameter="idSiteOptional",
* name="idSite",
* in="query",
* description="Matomo site ID.",
* required=false,
* @OA\Schema(type="integer"),
* example=1
* )
*
* @OA\Parameter(
* parameter="periodRequired",
* name="period",
* in="query",
* description="Reporting period.",
* required=true,
* @OA\Schema(type="string", enum={"day","week","month","year","range"}),
* example="day"
* )
*
* @OA\Parameter(
* parameter="periodOptional",
* name="period",
* in="query",
* description="Reporting period.",
* required=false,
* @OA\Schema(type="string", enum={"day","week","month","year","range"}),
* example="day"
* )
*
* @OA\Parameter(
* parameter="dateRequired",
* name="date",
* in="query",
* description="Date or range (e.g. `2025-08-01`, `yesterday`, `last30`, or `2025-08-01,2025-08-11`).",
* required=true,
* @OA\Schema(type="string"),
* example="yesterday"
* )
*
* @OA\Parameter(
* parameter="dateOptional",
* name="date",
* in="query",
* description="Date or range (e.g. `2025-08-01`, `yesterday`, `last30`, or `2025-08-01,2025-08-11`).",
* required=false,
* @OA\Schema(type="string"),
* example="yesterday"
* )
*
* @OA\Parameter(
* parameter="segmentRequired",
* name="segment",
* in="query",
* description="Segment expression; see `API.getSegmentDimensionMetadata`.",
* required=true,
* @OA\Schema(type="string")
* )
*
* @OA\Parameter(
* parameter="segmentOptional",
* name="segment",
* in="query",
* description="Segment expression; see `API.getSegmentDimensionMetadata`.",
* required=false,
* @OA\Schema(type="string")
* )
*
* Parameters specific to DataTables and Views
* @OA\Parameter(parameter="flatOptional", name="flat", in="query",
* description="Flatten subtables into the parent table.", required=false,
* @OA\Schema(type="integer", enum={0,1}), example=0)
*
* @OA\Parameter(parameter="filter_patternOptional", name="filter_pattern", in="query",
* description="Regex to keep matching rows.", required=false, @OA\Schema(type="string"))
*
* @OA\Parameter(parameter="filter_columnOptional", name="filter_column", in="query",
* description="Column to apply the regex to (e.g., `label`).", required=false,
* @OA\Schema(type="string"), example="label")
*
* @OA\Parameter(parameter="filter_pattern_recursiveOptional", name="filter_pattern_recursive", in="query",
* description="Recursive regex filter.", required=false, @OA\Schema(type="string"))
*
* @OA\Parameter(parameter="filter_column_recursiveOptional", name="filter_column_recursive", in="query",
* description="Column for the recursive regex filter.", required=false, @OA\Schema(type="string"))
*
* @OA\Parameter(parameter="filter_excludelowpopOptional", name="filter_excludelowpop", in="query",
* description="Column to threshold and exclude low values.", required=false, @OA\Schema(type="string"))
*
* @OA\Parameter(parameter="filter_excludelowpop_valueOptional", name="filter_excludelowpop_value", in="query",
* description="Minimum value threshold for `filter_excludelowpop`.", required=false,
* @OA\Schema(type="number"), example=0)
*
* @OA\Parameter(parameter="filter_sort_columnOptional", name="filter_sort_column", in="query",
* description="Column to sort by.", required=false, @OA\Schema(type="string"))
*
* @OA\Parameter(parameter="filter_sort_orderOptional", name="filter_sort_order", in="query",
* description="Sort direction.", required=false,
* @OA\Schema(type="string", enum={"asc","desc"}), example="desc")
*
* @OA\Parameter(parameter="filter_truncateOptional", name="filter_truncate", in="query",
* description="Row index after which rows are removed.", required=false, @OA\Schema(type="integer"))
*
* @OA\Parameter(parameter="filter_limitOptional", name="filter_limit", in="query",
* description="Maximum rows to return.", required=false, @OA\Schema(type="integer"))
*
* @OA\Parameter(parameter="filter_offsetOptional", name="filter_offset", in="query",
* description="Row offset.", required=false, @OA\Schema(type="integer"))
*
* @OA\Parameter(parameter="keep_summary_rowOptional", name="keep_summary_row", in="query",
* description="Keep the summary row.", required=false,
* @OA\Schema(type="integer", enum={0,1}), example=1)
*
* @OA\Parameter(parameter="disable_generic_filtersOptional", name="disable_generic_filters", in="query",
* description="Disable generic filters (those above).", required=false,
* @OA\Schema(type="integer", enum={0,1}), example=0)
*
* @OA\Parameter(parameter="disable_queued_filtersOptional", name="disable_queued_filters", in="query",
* description="Skip queued filters.", required=false,
* @OA\Schema(type="integer", enum={0,1}), example=0)
*
* @OA\Parameter(parameter="hideColumnsOptional", name="hideColumns", in="query",
* description="Comma-separated list of columns to hide.", required=false, @OA\Schema(type="string"))
*
* @OA\Parameter(parameter="showColumnsOptional", name="showColumns", in="query",
* description="Comma-separated list of columns to include.", required=false, @OA\Schema(type="string"))
*
* @OA\Parameter(parameter="labelOptional", name="label", in="query",
* description="Keep only rows with these label(s). Supports path via '>' and arrays.", required=false, @OA\Schema(type="string"))
*
* @OA\Parameter(parameter="idGoalOptional", name="idGoal", in="query",
* description="Goal ID or special values (overview/minimal/full table).", required=false, @OA\Schema(type="string"))
*/
class GlobalApiComponents
{
}