1package apimanagement
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"github.com/Azure/go-autorest/autorest"
23	"github.com/Azure/go-autorest/autorest/azure"
24	"github.com/Azure/go-autorest/autorest/validation"
25	"net/http"
26)
27
28// ReportsClient is the client for the Reports methods of the Apimanagement service.
29type ReportsClient struct {
30	BaseClient
31}
32
33// NewReportsClient creates an instance of the ReportsClient client.
34func NewReportsClient() ReportsClient {
35	return ReportsClient{New()}
36}
37
38// ListByAPI lists report records by API.
39// Parameters:
40// apimBaseURL - the management endpoint of the API Management service, for example
41// https://myapimservice.management.azure-api.net.
42// filter - the filter to apply on the operation.
43// top - number of records to return.
44// skip - number of records to skip.
45func (client ReportsClient) ListByAPI(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) {
46	if err := validation.Validate([]validation.Validation{
47		{TargetValue: top,
48			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
49				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
50		{TargetValue: skip,
51			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
52				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil {
53		return result, validation.NewError("apimanagement.ReportsClient", "ListByAPI", err.Error())
54	}
55
56	result.fn = client.listByAPINextResults
57	req, err := client.ListByAPIPreparer(ctx, apimBaseURL, filter, top, skip)
58	if err != nil {
59		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByAPI", nil, "Failure preparing request")
60		return
61	}
62
63	resp, err := client.ListByAPISender(req)
64	if err != nil {
65		result.rc.Response = autorest.Response{Response: resp}
66		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByAPI", resp, "Failure sending request")
67		return
68	}
69
70	result.rc, err = client.ListByAPIResponder(resp)
71	if err != nil {
72		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByAPI", resp, "Failure responding to request")
73	}
74
75	return
76}
77
78// ListByAPIPreparer prepares the ListByAPI request.
79func (client ReportsClient) ListByAPIPreparer(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (*http.Request, error) {
80	urlParameters := map[string]interface{}{
81		"apimBaseUrl": apimBaseURL,
82	}
83
84	const APIVersion = "2017-03-01"
85	queryParameters := map[string]interface{}{
86		"$filter":     autorest.Encode("query", filter),
87		"api-version": APIVersion,
88	}
89	if top != nil {
90		queryParameters["$top"] = autorest.Encode("query", *top)
91	}
92	if skip != nil {
93		queryParameters["$skip"] = autorest.Encode("query", *skip)
94	}
95
96	preparer := autorest.CreatePreparer(
97		autorest.AsGet(),
98		autorest.WithCustomBaseURL("{apimBaseUrl}", urlParameters),
99		autorest.WithPath("/reports/byApi"),
100		autorest.WithQueryParameters(queryParameters))
101	return preparer.Prepare((&http.Request{}).WithContext(ctx))
102}
103
104// ListByAPISender sends the ListByAPI request. The method will close the
105// http.Response Body if it receives an error.
106func (client ReportsClient) ListByAPISender(req *http.Request) (*http.Response, error) {
107	return autorest.SendWithSender(client, req,
108		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
109}
110
111// ListByAPIResponder handles the response to the ListByAPI request. The method always
112// closes the http.Response Body.
113func (client ReportsClient) ListByAPIResponder(resp *http.Response) (result ReportCollection, err error) {
114	err = autorest.Respond(
115		resp,
116		client.ByInspecting(),
117		azure.WithErrorUnlessStatusCode(http.StatusOK),
118		autorest.ByUnmarshallingJSON(&result),
119		autorest.ByClosing())
120	result.Response = autorest.Response{Response: resp}
121	return
122}
123
124// listByAPINextResults retrieves the next set of results, if any.
125func (client ReportsClient) listByAPINextResults(lastResults ReportCollection) (result ReportCollection, err error) {
126	req, err := lastResults.reportCollectionPreparer()
127	if err != nil {
128		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByAPINextResults", nil, "Failure preparing next results request")
129	}
130	if req == nil {
131		return
132	}
133	resp, err := client.ListByAPISender(req)
134	if err != nil {
135		result.Response = autorest.Response{Response: resp}
136		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByAPINextResults", resp, "Failure sending next results request")
137	}
138	result, err = client.ListByAPIResponder(resp)
139	if err != nil {
140		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByAPINextResults", resp, "Failure responding to next results request")
141	}
142	return
143}
144
145// ListByAPIComplete enumerates all values, automatically crossing page boundaries as required.
146func (client ReportsClient) ListByAPIComplete(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) {
147	result.page, err = client.ListByAPI(ctx, apimBaseURL, filter, top, skip)
148	return
149}
150
151// ListByGeo lists report records by GeoGraphy.
152// Parameters:
153// apimBaseURL - the management endpoint of the API Management service, for example
154// https://myapimservice.management.azure-api.net.
155// filter - the filter to apply on the operation.
156// top - number of records to return.
157// skip - number of records to skip.
158func (client ReportsClient) ListByGeo(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) {
159	if err := validation.Validate([]validation.Validation{
160		{TargetValue: top,
161			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
162				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
163		{TargetValue: skip,
164			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
165				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil {
166		return result, validation.NewError("apimanagement.ReportsClient", "ListByGeo", err.Error())
167	}
168
169	result.fn = client.listByGeoNextResults
170	req, err := client.ListByGeoPreparer(ctx, apimBaseURL, filter, top, skip)
171	if err != nil {
172		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByGeo", nil, "Failure preparing request")
173		return
174	}
175
176	resp, err := client.ListByGeoSender(req)
177	if err != nil {
178		result.rc.Response = autorest.Response{Response: resp}
179		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByGeo", resp, "Failure sending request")
180		return
181	}
182
183	result.rc, err = client.ListByGeoResponder(resp)
184	if err != nil {
185		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByGeo", resp, "Failure responding to request")
186	}
187
188	return
189}
190
191// ListByGeoPreparer prepares the ListByGeo request.
192func (client ReportsClient) ListByGeoPreparer(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (*http.Request, error) {
193	urlParameters := map[string]interface{}{
194		"apimBaseUrl": apimBaseURL,
195	}
196
197	const APIVersion = "2017-03-01"
198	queryParameters := map[string]interface{}{
199		"api-version": APIVersion,
200	}
201	if len(filter) > 0 {
202		queryParameters["$filter"] = autorest.Encode("query", filter)
203	}
204	if top != nil {
205		queryParameters["$top"] = autorest.Encode("query", *top)
206	}
207	if skip != nil {
208		queryParameters["$skip"] = autorest.Encode("query", *skip)
209	}
210
211	preparer := autorest.CreatePreparer(
212		autorest.AsGet(),
213		autorest.WithCustomBaseURL("{apimBaseUrl}", urlParameters),
214		autorest.WithPath("/reports/byGeo"),
215		autorest.WithQueryParameters(queryParameters))
216	return preparer.Prepare((&http.Request{}).WithContext(ctx))
217}
218
219// ListByGeoSender sends the ListByGeo request. The method will close the
220// http.Response Body if it receives an error.
221func (client ReportsClient) ListByGeoSender(req *http.Request) (*http.Response, error) {
222	return autorest.SendWithSender(client, req,
223		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
224}
225
226// ListByGeoResponder handles the response to the ListByGeo request. The method always
227// closes the http.Response Body.
228func (client ReportsClient) ListByGeoResponder(resp *http.Response) (result ReportCollection, err error) {
229	err = autorest.Respond(
230		resp,
231		client.ByInspecting(),
232		azure.WithErrorUnlessStatusCode(http.StatusOK),
233		autorest.ByUnmarshallingJSON(&result),
234		autorest.ByClosing())
235	result.Response = autorest.Response{Response: resp}
236	return
237}
238
239// listByGeoNextResults retrieves the next set of results, if any.
240func (client ReportsClient) listByGeoNextResults(lastResults ReportCollection) (result ReportCollection, err error) {
241	req, err := lastResults.reportCollectionPreparer()
242	if err != nil {
243		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByGeoNextResults", nil, "Failure preparing next results request")
244	}
245	if req == nil {
246		return
247	}
248	resp, err := client.ListByGeoSender(req)
249	if err != nil {
250		result.Response = autorest.Response{Response: resp}
251		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByGeoNextResults", resp, "Failure sending next results request")
252	}
253	result, err = client.ListByGeoResponder(resp)
254	if err != nil {
255		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByGeoNextResults", resp, "Failure responding to next results request")
256	}
257	return
258}
259
260// ListByGeoComplete enumerates all values, automatically crossing page boundaries as required.
261func (client ReportsClient) ListByGeoComplete(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) {
262	result.page, err = client.ListByGeo(ctx, apimBaseURL, filter, top, skip)
263	return
264}
265
266// ListByOperation lists report records by API Operations.
267// Parameters:
268// apimBaseURL - the management endpoint of the API Management service, for example
269// https://myapimservice.management.azure-api.net.
270// filter - the filter to apply on the operation.
271// top - number of records to return.
272// skip - number of records to skip.
273func (client ReportsClient) ListByOperation(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) {
274	if err := validation.Validate([]validation.Validation{
275		{TargetValue: top,
276			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
277				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
278		{TargetValue: skip,
279			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
280				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil {
281		return result, validation.NewError("apimanagement.ReportsClient", "ListByOperation", err.Error())
282	}
283
284	result.fn = client.listByOperationNextResults
285	req, err := client.ListByOperationPreparer(ctx, apimBaseURL, filter, top, skip)
286	if err != nil {
287		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByOperation", nil, "Failure preparing request")
288		return
289	}
290
291	resp, err := client.ListByOperationSender(req)
292	if err != nil {
293		result.rc.Response = autorest.Response{Response: resp}
294		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByOperation", resp, "Failure sending request")
295		return
296	}
297
298	result.rc, err = client.ListByOperationResponder(resp)
299	if err != nil {
300		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByOperation", resp, "Failure responding to request")
301	}
302
303	return
304}
305
306// ListByOperationPreparer prepares the ListByOperation request.
307func (client ReportsClient) ListByOperationPreparer(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (*http.Request, error) {
308	urlParameters := map[string]interface{}{
309		"apimBaseUrl": apimBaseURL,
310	}
311
312	const APIVersion = "2017-03-01"
313	queryParameters := map[string]interface{}{
314		"$filter":     autorest.Encode("query", filter),
315		"api-version": APIVersion,
316	}
317	if top != nil {
318		queryParameters["$top"] = autorest.Encode("query", *top)
319	}
320	if skip != nil {
321		queryParameters["$skip"] = autorest.Encode("query", *skip)
322	}
323
324	preparer := autorest.CreatePreparer(
325		autorest.AsGet(),
326		autorest.WithCustomBaseURL("{apimBaseUrl}", urlParameters),
327		autorest.WithPath("/reports/byOperation"),
328		autorest.WithQueryParameters(queryParameters))
329	return preparer.Prepare((&http.Request{}).WithContext(ctx))
330}
331
332// ListByOperationSender sends the ListByOperation request. The method will close the
333// http.Response Body if it receives an error.
334func (client ReportsClient) ListByOperationSender(req *http.Request) (*http.Response, error) {
335	return autorest.SendWithSender(client, req,
336		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
337}
338
339// ListByOperationResponder handles the response to the ListByOperation request. The method always
340// closes the http.Response Body.
341func (client ReportsClient) ListByOperationResponder(resp *http.Response) (result ReportCollection, err error) {
342	err = autorest.Respond(
343		resp,
344		client.ByInspecting(),
345		azure.WithErrorUnlessStatusCode(http.StatusOK),
346		autorest.ByUnmarshallingJSON(&result),
347		autorest.ByClosing())
348	result.Response = autorest.Response{Response: resp}
349	return
350}
351
352// listByOperationNextResults retrieves the next set of results, if any.
353func (client ReportsClient) listByOperationNextResults(lastResults ReportCollection) (result ReportCollection, err error) {
354	req, err := lastResults.reportCollectionPreparer()
355	if err != nil {
356		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByOperationNextResults", nil, "Failure preparing next results request")
357	}
358	if req == nil {
359		return
360	}
361	resp, err := client.ListByOperationSender(req)
362	if err != nil {
363		result.Response = autorest.Response{Response: resp}
364		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByOperationNextResults", resp, "Failure sending next results request")
365	}
366	result, err = client.ListByOperationResponder(resp)
367	if err != nil {
368		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByOperationNextResults", resp, "Failure responding to next results request")
369	}
370	return
371}
372
373// ListByOperationComplete enumerates all values, automatically crossing page boundaries as required.
374func (client ReportsClient) ListByOperationComplete(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) {
375	result.page, err = client.ListByOperation(ctx, apimBaseURL, filter, top, skip)
376	return
377}
378
379// ListByProduct lists report records by Product.
380// Parameters:
381// apimBaseURL - the management endpoint of the API Management service, for example
382// https://myapimservice.management.azure-api.net.
383// filter - the filter to apply on the operation.
384// top - number of records to return.
385// skip - number of records to skip.
386func (client ReportsClient) ListByProduct(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) {
387	if err := validation.Validate([]validation.Validation{
388		{TargetValue: top,
389			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
390				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
391		{TargetValue: skip,
392			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
393				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil {
394		return result, validation.NewError("apimanagement.ReportsClient", "ListByProduct", err.Error())
395	}
396
397	result.fn = client.listByProductNextResults
398	req, err := client.ListByProductPreparer(ctx, apimBaseURL, filter, top, skip)
399	if err != nil {
400		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByProduct", nil, "Failure preparing request")
401		return
402	}
403
404	resp, err := client.ListByProductSender(req)
405	if err != nil {
406		result.rc.Response = autorest.Response{Response: resp}
407		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByProduct", resp, "Failure sending request")
408		return
409	}
410
411	result.rc, err = client.ListByProductResponder(resp)
412	if err != nil {
413		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByProduct", resp, "Failure responding to request")
414	}
415
416	return
417}
418
419// ListByProductPreparer prepares the ListByProduct request.
420func (client ReportsClient) ListByProductPreparer(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (*http.Request, error) {
421	urlParameters := map[string]interface{}{
422		"apimBaseUrl": apimBaseURL,
423	}
424
425	const APIVersion = "2017-03-01"
426	queryParameters := map[string]interface{}{
427		"$filter":     autorest.Encode("query", filter),
428		"api-version": APIVersion,
429	}
430	if top != nil {
431		queryParameters["$top"] = autorest.Encode("query", *top)
432	}
433	if skip != nil {
434		queryParameters["$skip"] = autorest.Encode("query", *skip)
435	}
436
437	preparer := autorest.CreatePreparer(
438		autorest.AsGet(),
439		autorest.WithCustomBaseURL("{apimBaseUrl}", urlParameters),
440		autorest.WithPath("/reports/byProduct"),
441		autorest.WithQueryParameters(queryParameters))
442	return preparer.Prepare((&http.Request{}).WithContext(ctx))
443}
444
445// ListByProductSender sends the ListByProduct request. The method will close the
446// http.Response Body if it receives an error.
447func (client ReportsClient) ListByProductSender(req *http.Request) (*http.Response, error) {
448	return autorest.SendWithSender(client, req,
449		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
450}
451
452// ListByProductResponder handles the response to the ListByProduct request. The method always
453// closes the http.Response Body.
454func (client ReportsClient) ListByProductResponder(resp *http.Response) (result ReportCollection, err error) {
455	err = autorest.Respond(
456		resp,
457		client.ByInspecting(),
458		azure.WithErrorUnlessStatusCode(http.StatusOK),
459		autorest.ByUnmarshallingJSON(&result),
460		autorest.ByClosing())
461	result.Response = autorest.Response{Response: resp}
462	return
463}
464
465// listByProductNextResults retrieves the next set of results, if any.
466func (client ReportsClient) listByProductNextResults(lastResults ReportCollection) (result ReportCollection, err error) {
467	req, err := lastResults.reportCollectionPreparer()
468	if err != nil {
469		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByProductNextResults", nil, "Failure preparing next results request")
470	}
471	if req == nil {
472		return
473	}
474	resp, err := client.ListByProductSender(req)
475	if err != nil {
476		result.Response = autorest.Response{Response: resp}
477		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByProductNextResults", resp, "Failure sending next results request")
478	}
479	result, err = client.ListByProductResponder(resp)
480	if err != nil {
481		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByProductNextResults", resp, "Failure responding to next results request")
482	}
483	return
484}
485
486// ListByProductComplete enumerates all values, automatically crossing page boundaries as required.
487func (client ReportsClient) ListByProductComplete(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) {
488	result.page, err = client.ListByProduct(ctx, apimBaseURL, filter, top, skip)
489	return
490}
491
492// ListByRequest lists report records by Request.
493// Parameters:
494// apimBaseURL - the management endpoint of the API Management service, for example
495// https://myapimservice.management.azure-api.net.
496// filter - the filter to apply on the operation.
497// top - number of records to return.
498// skip - number of records to skip.
499func (client ReportsClient) ListByRequest(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (result RequestReportCollection, err error) {
500	if err := validation.Validate([]validation.Validation{
501		{TargetValue: top,
502			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
503				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
504		{TargetValue: skip,
505			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
506				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil {
507		return result, validation.NewError("apimanagement.ReportsClient", "ListByRequest", err.Error())
508	}
509
510	req, err := client.ListByRequestPreparer(ctx, apimBaseURL, filter, top, skip)
511	if err != nil {
512		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByRequest", nil, "Failure preparing request")
513		return
514	}
515
516	resp, err := client.ListByRequestSender(req)
517	if err != nil {
518		result.Response = autorest.Response{Response: resp}
519		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByRequest", resp, "Failure sending request")
520		return
521	}
522
523	result, err = client.ListByRequestResponder(resp)
524	if err != nil {
525		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByRequest", resp, "Failure responding to request")
526	}
527
528	return
529}
530
531// ListByRequestPreparer prepares the ListByRequest request.
532func (client ReportsClient) ListByRequestPreparer(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (*http.Request, error) {
533	urlParameters := map[string]interface{}{
534		"apimBaseUrl": apimBaseURL,
535	}
536
537	const APIVersion = "2017-03-01"
538	queryParameters := map[string]interface{}{
539		"$filter":     autorest.Encode("query", filter),
540		"api-version": APIVersion,
541	}
542	if top != nil {
543		queryParameters["$top"] = autorest.Encode("query", *top)
544	}
545	if skip != nil {
546		queryParameters["$skip"] = autorest.Encode("query", *skip)
547	}
548
549	preparer := autorest.CreatePreparer(
550		autorest.AsGet(),
551		autorest.WithCustomBaseURL("{apimBaseUrl}", urlParameters),
552		autorest.WithPath("/reports/byRequest"),
553		autorest.WithQueryParameters(queryParameters))
554	return preparer.Prepare((&http.Request{}).WithContext(ctx))
555}
556
557// ListByRequestSender sends the ListByRequest request. The method will close the
558// http.Response Body if it receives an error.
559func (client ReportsClient) ListByRequestSender(req *http.Request) (*http.Response, error) {
560	return autorest.SendWithSender(client, req,
561		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
562}
563
564// ListByRequestResponder handles the response to the ListByRequest request. The method always
565// closes the http.Response Body.
566func (client ReportsClient) ListByRequestResponder(resp *http.Response) (result RequestReportCollection, err error) {
567	err = autorest.Respond(
568		resp,
569		client.ByInspecting(),
570		azure.WithErrorUnlessStatusCode(http.StatusOK),
571		autorest.ByUnmarshallingJSON(&result),
572		autorest.ByClosing())
573	result.Response = autorest.Response{Response: resp}
574	return
575}
576
577// ListBySubscription lists report records by subscription.
578// Parameters:
579// apimBaseURL - the management endpoint of the API Management service, for example
580// https://myapimservice.management.azure-api.net.
581// filter - the filter to apply on the operation.
582// top - number of records to return.
583// skip - number of records to skip.
584func (client ReportsClient) ListBySubscription(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) {
585	if err := validation.Validate([]validation.Validation{
586		{TargetValue: top,
587			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
588				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
589		{TargetValue: skip,
590			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
591				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil {
592		return result, validation.NewError("apimanagement.ReportsClient", "ListBySubscription", err.Error())
593	}
594
595	result.fn = client.listBySubscriptionNextResults
596	req, err := client.ListBySubscriptionPreparer(ctx, apimBaseURL, filter, top, skip)
597	if err != nil {
598		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListBySubscription", nil, "Failure preparing request")
599		return
600	}
601
602	resp, err := client.ListBySubscriptionSender(req)
603	if err != nil {
604		result.rc.Response = autorest.Response{Response: resp}
605		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListBySubscription", resp, "Failure sending request")
606		return
607	}
608
609	result.rc, err = client.ListBySubscriptionResponder(resp)
610	if err != nil {
611		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListBySubscription", resp, "Failure responding to request")
612	}
613
614	return
615}
616
617// ListBySubscriptionPreparer prepares the ListBySubscription request.
618func (client ReportsClient) ListBySubscriptionPreparer(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (*http.Request, error) {
619	urlParameters := map[string]interface{}{
620		"apimBaseUrl": apimBaseURL,
621	}
622
623	const APIVersion = "2017-03-01"
624	queryParameters := map[string]interface{}{
625		"api-version": APIVersion,
626	}
627	if len(filter) > 0 {
628		queryParameters["$filter"] = autorest.Encode("query", filter)
629	}
630	if top != nil {
631		queryParameters["$top"] = autorest.Encode("query", *top)
632	}
633	if skip != nil {
634		queryParameters["$skip"] = autorest.Encode("query", *skip)
635	}
636
637	preparer := autorest.CreatePreparer(
638		autorest.AsGet(),
639		autorest.WithCustomBaseURL("{apimBaseUrl}", urlParameters),
640		autorest.WithPath("/reports/bySubscription"),
641		autorest.WithQueryParameters(queryParameters))
642	return preparer.Prepare((&http.Request{}).WithContext(ctx))
643}
644
645// ListBySubscriptionSender sends the ListBySubscription request. The method will close the
646// http.Response Body if it receives an error.
647func (client ReportsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
648	return autorest.SendWithSender(client, req,
649		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
650}
651
652// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
653// closes the http.Response Body.
654func (client ReportsClient) ListBySubscriptionResponder(resp *http.Response) (result ReportCollection, err error) {
655	err = autorest.Respond(
656		resp,
657		client.ByInspecting(),
658		azure.WithErrorUnlessStatusCode(http.StatusOK),
659		autorest.ByUnmarshallingJSON(&result),
660		autorest.ByClosing())
661	result.Response = autorest.Response{Response: resp}
662	return
663}
664
665// listBySubscriptionNextResults retrieves the next set of results, if any.
666func (client ReportsClient) listBySubscriptionNextResults(lastResults ReportCollection) (result ReportCollection, err error) {
667	req, err := lastResults.reportCollectionPreparer()
668	if err != nil {
669		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
670	}
671	if req == nil {
672		return
673	}
674	resp, err := client.ListBySubscriptionSender(req)
675	if err != nil {
676		result.Response = autorest.Response{Response: resp}
677		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
678	}
679	result, err = client.ListBySubscriptionResponder(resp)
680	if err != nil {
681		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
682	}
683	return
684}
685
686// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
687func (client ReportsClient) ListBySubscriptionComplete(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) {
688	result.page, err = client.ListBySubscription(ctx, apimBaseURL, filter, top, skip)
689	return
690}
691
692// ListByTime lists report records by Time.
693// Parameters:
694// apimBaseURL - the management endpoint of the API Management service, for example
695// https://myapimservice.management.azure-api.net.
696// interval - by time interval. Interval must be multiple of 15 minutes and may not be zero. The value should
697// be in ISO  8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert
698// TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, secconds))
699// filter - the filter to apply on the operation.
700// top - number of records to return.
701// skip - number of records to skip.
702func (client ReportsClient) ListByTime(ctx context.Context, apimBaseURL string, interval string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) {
703	if err := validation.Validate([]validation.Validation{
704		{TargetValue: top,
705			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
706				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
707		{TargetValue: skip,
708			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
709				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil {
710		return result, validation.NewError("apimanagement.ReportsClient", "ListByTime", err.Error())
711	}
712
713	result.fn = client.listByTimeNextResults
714	req, err := client.ListByTimePreparer(ctx, apimBaseURL, interval, filter, top, skip)
715	if err != nil {
716		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByTime", nil, "Failure preparing request")
717		return
718	}
719
720	resp, err := client.ListByTimeSender(req)
721	if err != nil {
722		result.rc.Response = autorest.Response{Response: resp}
723		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByTime", resp, "Failure sending request")
724		return
725	}
726
727	result.rc, err = client.ListByTimeResponder(resp)
728	if err != nil {
729		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByTime", resp, "Failure responding to request")
730	}
731
732	return
733}
734
735// ListByTimePreparer prepares the ListByTime request.
736func (client ReportsClient) ListByTimePreparer(ctx context.Context, apimBaseURL string, interval string, filter string, top *int32, skip *int32) (*http.Request, error) {
737	urlParameters := map[string]interface{}{
738		"apimBaseUrl": apimBaseURL,
739	}
740
741	const APIVersion = "2017-03-01"
742	queryParameters := map[string]interface{}{
743		"api-version": APIVersion,
744		"interval":    autorest.Encode("query", interval),
745	}
746	if len(filter) > 0 {
747		queryParameters["$filter"] = autorest.Encode("query", filter)
748	}
749	if top != nil {
750		queryParameters["$top"] = autorest.Encode("query", *top)
751	}
752	if skip != nil {
753		queryParameters["$skip"] = autorest.Encode("query", *skip)
754	}
755
756	preparer := autorest.CreatePreparer(
757		autorest.AsGet(),
758		autorest.WithCustomBaseURL("{apimBaseUrl}", urlParameters),
759		autorest.WithPath("/reports/byTime"),
760		autorest.WithQueryParameters(queryParameters))
761	return preparer.Prepare((&http.Request{}).WithContext(ctx))
762}
763
764// ListByTimeSender sends the ListByTime request. The method will close the
765// http.Response Body if it receives an error.
766func (client ReportsClient) ListByTimeSender(req *http.Request) (*http.Response, error) {
767	return autorest.SendWithSender(client, req,
768		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
769}
770
771// ListByTimeResponder handles the response to the ListByTime request. The method always
772// closes the http.Response Body.
773func (client ReportsClient) ListByTimeResponder(resp *http.Response) (result ReportCollection, err error) {
774	err = autorest.Respond(
775		resp,
776		client.ByInspecting(),
777		azure.WithErrorUnlessStatusCode(http.StatusOK),
778		autorest.ByUnmarshallingJSON(&result),
779		autorest.ByClosing())
780	result.Response = autorest.Response{Response: resp}
781	return
782}
783
784// listByTimeNextResults retrieves the next set of results, if any.
785func (client ReportsClient) listByTimeNextResults(lastResults ReportCollection) (result ReportCollection, err error) {
786	req, err := lastResults.reportCollectionPreparer()
787	if err != nil {
788		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByTimeNextResults", nil, "Failure preparing next results request")
789	}
790	if req == nil {
791		return
792	}
793	resp, err := client.ListByTimeSender(req)
794	if err != nil {
795		result.Response = autorest.Response{Response: resp}
796		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByTimeNextResults", resp, "Failure sending next results request")
797	}
798	result, err = client.ListByTimeResponder(resp)
799	if err != nil {
800		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByTimeNextResults", resp, "Failure responding to next results request")
801	}
802	return
803}
804
805// ListByTimeComplete enumerates all values, automatically crossing page boundaries as required.
806func (client ReportsClient) ListByTimeComplete(ctx context.Context, apimBaseURL string, interval string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) {
807	result.page, err = client.ListByTime(ctx, apimBaseURL, interval, filter, top, skip)
808	return
809}
810
811// ListByUser lists report records by User.
812// Parameters:
813// apimBaseURL - the management endpoint of the API Management service, for example
814// https://myapimservice.management.azure-api.net.
815// filter - the filter to apply on the operation.
816// top - number of records to return.
817// skip - number of records to skip.
818func (client ReportsClient) ListByUser(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) {
819	if err := validation.Validate([]validation.Validation{
820		{TargetValue: top,
821			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
822				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
823		{TargetValue: skip,
824			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
825				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil {
826		return result, validation.NewError("apimanagement.ReportsClient", "ListByUser", err.Error())
827	}
828
829	result.fn = client.listByUserNextResults
830	req, err := client.ListByUserPreparer(ctx, apimBaseURL, filter, top, skip)
831	if err != nil {
832		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByUser", nil, "Failure preparing request")
833		return
834	}
835
836	resp, err := client.ListByUserSender(req)
837	if err != nil {
838		result.rc.Response = autorest.Response{Response: resp}
839		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByUser", resp, "Failure sending request")
840		return
841	}
842
843	result.rc, err = client.ListByUserResponder(resp)
844	if err != nil {
845		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByUser", resp, "Failure responding to request")
846	}
847
848	return
849}
850
851// ListByUserPreparer prepares the ListByUser request.
852func (client ReportsClient) ListByUserPreparer(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (*http.Request, error) {
853	urlParameters := map[string]interface{}{
854		"apimBaseUrl": apimBaseURL,
855	}
856
857	const APIVersion = "2017-03-01"
858	queryParameters := map[string]interface{}{
859		"$filter":     autorest.Encode("query", filter),
860		"api-version": APIVersion,
861	}
862	if top != nil {
863		queryParameters["$top"] = autorest.Encode("query", *top)
864	}
865	if skip != nil {
866		queryParameters["$skip"] = autorest.Encode("query", *skip)
867	}
868
869	preparer := autorest.CreatePreparer(
870		autorest.AsGet(),
871		autorest.WithCustomBaseURL("{apimBaseUrl}", urlParameters),
872		autorest.WithPath("/reports/byUser"),
873		autorest.WithQueryParameters(queryParameters))
874	return preparer.Prepare((&http.Request{}).WithContext(ctx))
875}
876
877// ListByUserSender sends the ListByUser request. The method will close the
878// http.Response Body if it receives an error.
879func (client ReportsClient) ListByUserSender(req *http.Request) (*http.Response, error) {
880	return autorest.SendWithSender(client, req,
881		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
882}
883
884// ListByUserResponder handles the response to the ListByUser request. The method always
885// closes the http.Response Body.
886func (client ReportsClient) ListByUserResponder(resp *http.Response) (result ReportCollection, err error) {
887	err = autorest.Respond(
888		resp,
889		client.ByInspecting(),
890		azure.WithErrorUnlessStatusCode(http.StatusOK),
891		autorest.ByUnmarshallingJSON(&result),
892		autorest.ByClosing())
893	result.Response = autorest.Response{Response: resp}
894	return
895}
896
897// listByUserNextResults retrieves the next set of results, if any.
898func (client ReportsClient) listByUserNextResults(lastResults ReportCollection) (result ReportCollection, err error) {
899	req, err := lastResults.reportCollectionPreparer()
900	if err != nil {
901		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByUserNextResults", nil, "Failure preparing next results request")
902	}
903	if req == nil {
904		return
905	}
906	resp, err := client.ListByUserSender(req)
907	if err != nil {
908		result.Response = autorest.Response{Response: resp}
909		return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByUserNextResults", resp, "Failure sending next results request")
910	}
911	result, err = client.ListByUserResponder(resp)
912	if err != nil {
913		err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByUserNextResults", resp, "Failure responding to next results request")
914	}
915	return
916}
917
918// ListByUserComplete enumerates all values, automatically crossing page boundaries as required.
919func (client ReportsClient) ListByUserComplete(ctx context.Context, apimBaseURL string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) {
920	result.page, err = client.ListByUser(ctx, apimBaseURL, filter, top, skip)
921	return
922}
923