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