1package costmanagement
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
10	"context"
11	"github.com/Azure/go-autorest/autorest"
12	"github.com/Azure/go-autorest/autorest/azure"
13	"github.com/Azure/go-autorest/autorest/validation"
14	"github.com/Azure/go-autorest/tracing"
15	"net/http"
16)
17
18// ReportsClient is the client for the Reports methods of the Costmanagement service.
19type ReportsClient struct {
20	BaseClient
21}
22
23// NewReportsClient creates an instance of the ReportsClient client.
24func NewReportsClient(subscriptionID string) ReportsClient {
25	return NewReportsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewReportsClientWithBaseURI creates an instance of the ReportsClient client using a custom endpoint.  Use this when
29// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewReportsClientWithBaseURI(baseURI string, subscriptionID string) ReportsClient {
31	return ReportsClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// CreateOrUpdate the operation to create or update a report. Update operation requires latest eTag to be set in the
35// request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not require
36// eTag.
37// Parameters:
38// reportName - report Name.
39// parameters - parameters supplied to the CreateOrUpdate Report operation.
40func (client ReportsClient) CreateOrUpdate(ctx context.Context, reportName string, parameters Report) (result Report, err error) {
41	if tracing.IsEnabled() {
42		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.CreateOrUpdate")
43		defer func() {
44			sc := -1
45			if result.Response.Response != nil {
46				sc = result.Response.Response.StatusCode
47			}
48			tracing.EndSpan(ctx, sc, err)
49		}()
50	}
51	if err := validation.Validate([]validation.Validation{
52		{TargetValue: parameters,
53			Constraints: []validation.Constraint{{Target: "parameters.ReportProperties", Name: validation.Null, Rule: false,
54				Chain: []validation.Constraint{{Target: "parameters.ReportProperties.Schedule", Name: validation.Null, Rule: false,
55					Chain: []validation.Constraint{{Target: "parameters.ReportProperties.Schedule.RecurrencePeriod", Name: validation.Null, Rule: false,
56						Chain: []validation.Constraint{{Target: "parameters.ReportProperties.Schedule.RecurrencePeriod.From", Name: validation.Null, Rule: true, Chain: nil}}},
57					}},
58				}}}}}); err != nil {
59		return result, validation.NewError("costmanagement.ReportsClient", "CreateOrUpdate", err.Error())
60	}
61
62	req, err := client.CreateOrUpdatePreparer(ctx, reportName, parameters)
63	if err != nil {
64		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "CreateOrUpdate", nil, "Failure preparing request")
65		return
66	}
67
68	resp, err := client.CreateOrUpdateSender(req)
69	if err != nil {
70		result.Response = autorest.Response{Response: resp}
71		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "CreateOrUpdate", resp, "Failure sending request")
72		return
73	}
74
75	result, err = client.CreateOrUpdateResponder(resp)
76	if err != nil {
77		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "CreateOrUpdate", resp, "Failure responding to request")
78		return
79	}
80
81	return
82}
83
84// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
85func (client ReportsClient) CreateOrUpdatePreparer(ctx context.Context, reportName string, parameters Report) (*http.Request, error) {
86	pathParameters := map[string]interface{}{
87		"reportName":     autorest.Encode("path", reportName),
88		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
89	}
90
91	const APIVersion = "2018-08-01-preview"
92	queryParameters := map[string]interface{}{
93		"api-version": APIVersion,
94	}
95
96	preparer := autorest.CreatePreparer(
97		autorest.AsContentType("application/json; charset=utf-8"),
98		autorest.AsPut(),
99		autorest.WithBaseURL(client.BaseURI),
100		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/reports/{reportName}", pathParameters),
101		autorest.WithJSON(parameters),
102		autorest.WithQueryParameters(queryParameters))
103	return preparer.Prepare((&http.Request{}).WithContext(ctx))
104}
105
106// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
107// http.Response Body if it receives an error.
108func (client ReportsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
109	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
110}
111
112// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
113// closes the http.Response Body.
114func (client ReportsClient) CreateOrUpdateResponder(resp *http.Response) (result Report, err error) {
115	err = autorest.Respond(
116		resp,
117		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
118		autorest.ByUnmarshallingJSON(&result),
119		autorest.ByClosing())
120	result.Response = autorest.Response{Response: resp}
121	return
122}
123
124// CreateOrUpdateByBillingAccount the operation to create or update a report for billingAccount. Update operation
125// requires latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get
126// operation. Create operation does not require eTag.
127// Parameters:
128// billingAccountID - billingAccount ID
129// reportName - report Name.
130// parameters - parameters supplied to the CreateOrUpdate Report operation.
131func (client ReportsClient) CreateOrUpdateByBillingAccount(ctx context.Context, billingAccountID string, reportName string, parameters Report) (result Report, err error) {
132	if tracing.IsEnabled() {
133		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.CreateOrUpdateByBillingAccount")
134		defer func() {
135			sc := -1
136			if result.Response.Response != nil {
137				sc = result.Response.Response.StatusCode
138			}
139			tracing.EndSpan(ctx, sc, err)
140		}()
141	}
142	if err := validation.Validate([]validation.Validation{
143		{TargetValue: parameters,
144			Constraints: []validation.Constraint{{Target: "parameters.ReportProperties", Name: validation.Null, Rule: false,
145				Chain: []validation.Constraint{{Target: "parameters.ReportProperties.Schedule", Name: validation.Null, Rule: false,
146					Chain: []validation.Constraint{{Target: "parameters.ReportProperties.Schedule.RecurrencePeriod", Name: validation.Null, Rule: false,
147						Chain: []validation.Constraint{{Target: "parameters.ReportProperties.Schedule.RecurrencePeriod.From", Name: validation.Null, Rule: true, Chain: nil}}},
148					}},
149				}}}}}); err != nil {
150		return result, validation.NewError("costmanagement.ReportsClient", "CreateOrUpdateByBillingAccount", err.Error())
151	}
152
153	req, err := client.CreateOrUpdateByBillingAccountPreparer(ctx, billingAccountID, reportName, parameters)
154	if err != nil {
155		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "CreateOrUpdateByBillingAccount", nil, "Failure preparing request")
156		return
157	}
158
159	resp, err := client.CreateOrUpdateByBillingAccountSender(req)
160	if err != nil {
161		result.Response = autorest.Response{Response: resp}
162		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "CreateOrUpdateByBillingAccount", resp, "Failure sending request")
163		return
164	}
165
166	result, err = client.CreateOrUpdateByBillingAccountResponder(resp)
167	if err != nil {
168		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "CreateOrUpdateByBillingAccount", resp, "Failure responding to request")
169		return
170	}
171
172	return
173}
174
175// CreateOrUpdateByBillingAccountPreparer prepares the CreateOrUpdateByBillingAccount request.
176func (client ReportsClient) CreateOrUpdateByBillingAccountPreparer(ctx context.Context, billingAccountID string, reportName string, parameters Report) (*http.Request, error) {
177	pathParameters := map[string]interface{}{
178		"billingAccountId": autorest.Encode("path", billingAccountID),
179		"reportName":       autorest.Encode("path", reportName),
180	}
181
182	const APIVersion = "2018-08-01-preview"
183	queryParameters := map[string]interface{}{
184		"api-version": APIVersion,
185	}
186
187	preparer := autorest.CreatePreparer(
188		autorest.AsContentType("application/json; charset=utf-8"),
189		autorest.AsPut(),
190		autorest.WithBaseURL(client.BaseURI),
191		autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/reports/{reportName}", pathParameters),
192		autorest.WithJSON(parameters),
193		autorest.WithQueryParameters(queryParameters))
194	return preparer.Prepare((&http.Request{}).WithContext(ctx))
195}
196
197// CreateOrUpdateByBillingAccountSender sends the CreateOrUpdateByBillingAccount request. The method will close the
198// http.Response Body if it receives an error.
199func (client ReportsClient) CreateOrUpdateByBillingAccountSender(req *http.Request) (*http.Response, error) {
200	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
201}
202
203// CreateOrUpdateByBillingAccountResponder handles the response to the CreateOrUpdateByBillingAccount request. The method always
204// closes the http.Response Body.
205func (client ReportsClient) CreateOrUpdateByBillingAccountResponder(resp *http.Response) (result Report, err error) {
206	err = autorest.Respond(
207		resp,
208		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
209		autorest.ByUnmarshallingJSON(&result),
210		autorest.ByClosing())
211	result.Response = autorest.Response{Response: resp}
212	return
213}
214
215// CreateOrUpdateByDepartment the operation to create or update a report for department. Update operation requires
216// latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation.
217// Create operation does not require eTag.
218// Parameters:
219// departmentID - department ID
220// reportName - report Name.
221// parameters - parameters supplied to the CreateOrUpdate Report operation.
222func (client ReportsClient) CreateOrUpdateByDepartment(ctx context.Context, departmentID string, reportName string, parameters Report) (result Report, err error) {
223	if tracing.IsEnabled() {
224		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.CreateOrUpdateByDepartment")
225		defer func() {
226			sc := -1
227			if result.Response.Response != nil {
228				sc = result.Response.Response.StatusCode
229			}
230			tracing.EndSpan(ctx, sc, err)
231		}()
232	}
233	if err := validation.Validate([]validation.Validation{
234		{TargetValue: parameters,
235			Constraints: []validation.Constraint{{Target: "parameters.ReportProperties", Name: validation.Null, Rule: false,
236				Chain: []validation.Constraint{{Target: "parameters.ReportProperties.Schedule", Name: validation.Null, Rule: false,
237					Chain: []validation.Constraint{{Target: "parameters.ReportProperties.Schedule.RecurrencePeriod", Name: validation.Null, Rule: false,
238						Chain: []validation.Constraint{{Target: "parameters.ReportProperties.Schedule.RecurrencePeriod.From", Name: validation.Null, Rule: true, Chain: nil}}},
239					}},
240				}}}}}); err != nil {
241		return result, validation.NewError("costmanagement.ReportsClient", "CreateOrUpdateByDepartment", err.Error())
242	}
243
244	req, err := client.CreateOrUpdateByDepartmentPreparer(ctx, departmentID, reportName, parameters)
245	if err != nil {
246		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "CreateOrUpdateByDepartment", nil, "Failure preparing request")
247		return
248	}
249
250	resp, err := client.CreateOrUpdateByDepartmentSender(req)
251	if err != nil {
252		result.Response = autorest.Response{Response: resp}
253		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "CreateOrUpdateByDepartment", resp, "Failure sending request")
254		return
255	}
256
257	result, err = client.CreateOrUpdateByDepartmentResponder(resp)
258	if err != nil {
259		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "CreateOrUpdateByDepartment", resp, "Failure responding to request")
260		return
261	}
262
263	return
264}
265
266// CreateOrUpdateByDepartmentPreparer prepares the CreateOrUpdateByDepartment request.
267func (client ReportsClient) CreateOrUpdateByDepartmentPreparer(ctx context.Context, departmentID string, reportName string, parameters Report) (*http.Request, error) {
268	pathParameters := map[string]interface{}{
269		"departmentId": autorest.Encode("path", departmentID),
270		"reportName":   autorest.Encode("path", reportName),
271	}
272
273	const APIVersion = "2018-08-01-preview"
274	queryParameters := map[string]interface{}{
275		"api-version": APIVersion,
276	}
277
278	preparer := autorest.CreatePreparer(
279		autorest.AsContentType("application/json; charset=utf-8"),
280		autorest.AsPut(),
281		autorest.WithBaseURL(client.BaseURI),
282		autorest.WithPathParameters("/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.CostManagement/reports/{reportName}", pathParameters),
283		autorest.WithJSON(parameters),
284		autorest.WithQueryParameters(queryParameters))
285	return preparer.Prepare((&http.Request{}).WithContext(ctx))
286}
287
288// CreateOrUpdateByDepartmentSender sends the CreateOrUpdateByDepartment request. The method will close the
289// http.Response Body if it receives an error.
290func (client ReportsClient) CreateOrUpdateByDepartmentSender(req *http.Request) (*http.Response, error) {
291	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
292}
293
294// CreateOrUpdateByDepartmentResponder handles the response to the CreateOrUpdateByDepartment request. The method always
295// closes the http.Response Body.
296func (client ReportsClient) CreateOrUpdateByDepartmentResponder(resp *http.Response) (result Report, err error) {
297	err = autorest.Respond(
298		resp,
299		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
300		autorest.ByUnmarshallingJSON(&result),
301		autorest.ByClosing())
302	result.Response = autorest.Response{Response: resp}
303	return
304}
305
306// CreateOrUpdateByResourceGroupName the operation to create or update a report. Update operation requires latest eTag
307// to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation
308// does not require eTag.
309// Parameters:
310// resourceGroupName - azure Resource Group Name.
311// reportName - report Name.
312// parameters - parameters supplied to the CreateOrUpdate Report operation.
313func (client ReportsClient) CreateOrUpdateByResourceGroupName(ctx context.Context, resourceGroupName string, reportName string, parameters Report) (result Report, err error) {
314	if tracing.IsEnabled() {
315		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.CreateOrUpdateByResourceGroupName")
316		defer func() {
317			sc := -1
318			if result.Response.Response != nil {
319				sc = result.Response.Response.StatusCode
320			}
321			tracing.EndSpan(ctx, sc, err)
322		}()
323	}
324	if err := validation.Validate([]validation.Validation{
325		{TargetValue: parameters,
326			Constraints: []validation.Constraint{{Target: "parameters.ReportProperties", Name: validation.Null, Rule: false,
327				Chain: []validation.Constraint{{Target: "parameters.ReportProperties.Schedule", Name: validation.Null, Rule: false,
328					Chain: []validation.Constraint{{Target: "parameters.ReportProperties.Schedule.RecurrencePeriod", Name: validation.Null, Rule: false,
329						Chain: []validation.Constraint{{Target: "parameters.ReportProperties.Schedule.RecurrencePeriod.From", Name: validation.Null, Rule: true, Chain: nil}}},
330					}},
331				}}}}}); err != nil {
332		return result, validation.NewError("costmanagement.ReportsClient", "CreateOrUpdateByResourceGroupName", err.Error())
333	}
334
335	req, err := client.CreateOrUpdateByResourceGroupNamePreparer(ctx, resourceGroupName, reportName, parameters)
336	if err != nil {
337		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "CreateOrUpdateByResourceGroupName", nil, "Failure preparing request")
338		return
339	}
340
341	resp, err := client.CreateOrUpdateByResourceGroupNameSender(req)
342	if err != nil {
343		result.Response = autorest.Response{Response: resp}
344		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "CreateOrUpdateByResourceGroupName", resp, "Failure sending request")
345		return
346	}
347
348	result, err = client.CreateOrUpdateByResourceGroupNameResponder(resp)
349	if err != nil {
350		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "CreateOrUpdateByResourceGroupName", resp, "Failure responding to request")
351		return
352	}
353
354	return
355}
356
357// CreateOrUpdateByResourceGroupNamePreparer prepares the CreateOrUpdateByResourceGroupName request.
358func (client ReportsClient) CreateOrUpdateByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportName string, parameters Report) (*http.Request, error) {
359	pathParameters := map[string]interface{}{
360		"reportName":        autorest.Encode("path", reportName),
361		"resourceGroupName": autorest.Encode("path", resourceGroupName),
362		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
363	}
364
365	const APIVersion = "2018-08-01-preview"
366	queryParameters := map[string]interface{}{
367		"api-version": APIVersion,
368	}
369
370	preparer := autorest.CreatePreparer(
371		autorest.AsContentType("application/json; charset=utf-8"),
372		autorest.AsPut(),
373		autorest.WithBaseURL(client.BaseURI),
374		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CostManagement/reports/{reportName}", pathParameters),
375		autorest.WithJSON(parameters),
376		autorest.WithQueryParameters(queryParameters))
377	return preparer.Prepare((&http.Request{}).WithContext(ctx))
378}
379
380// CreateOrUpdateByResourceGroupNameSender sends the CreateOrUpdateByResourceGroupName request. The method will close the
381// http.Response Body if it receives an error.
382func (client ReportsClient) CreateOrUpdateByResourceGroupNameSender(req *http.Request) (*http.Response, error) {
383	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
384}
385
386// CreateOrUpdateByResourceGroupNameResponder handles the response to the CreateOrUpdateByResourceGroupName request. The method always
387// closes the http.Response Body.
388func (client ReportsClient) CreateOrUpdateByResourceGroupNameResponder(resp *http.Response) (result Report, err error) {
389	err = autorest.Respond(
390		resp,
391		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
392		autorest.ByUnmarshallingJSON(&result),
393		autorest.ByClosing())
394	result.Response = autorest.Response{Response: resp}
395	return
396}
397
398// Delete the operation to delete a report.
399// Parameters:
400// reportName - report Name.
401func (client ReportsClient) Delete(ctx context.Context, reportName string) (result autorest.Response, err error) {
402	if tracing.IsEnabled() {
403		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.Delete")
404		defer func() {
405			sc := -1
406			if result.Response != nil {
407				sc = result.Response.StatusCode
408			}
409			tracing.EndSpan(ctx, sc, err)
410		}()
411	}
412	req, err := client.DeletePreparer(ctx, reportName)
413	if err != nil {
414		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "Delete", nil, "Failure preparing request")
415		return
416	}
417
418	resp, err := client.DeleteSender(req)
419	if err != nil {
420		result.Response = resp
421		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "Delete", resp, "Failure sending request")
422		return
423	}
424
425	result, err = client.DeleteResponder(resp)
426	if err != nil {
427		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "Delete", resp, "Failure responding to request")
428		return
429	}
430
431	return
432}
433
434// DeletePreparer prepares the Delete request.
435func (client ReportsClient) DeletePreparer(ctx context.Context, reportName string) (*http.Request, error) {
436	pathParameters := map[string]interface{}{
437		"reportName":     autorest.Encode("path", reportName),
438		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
439	}
440
441	const APIVersion = "2018-08-01-preview"
442	queryParameters := map[string]interface{}{
443		"api-version": APIVersion,
444	}
445
446	preparer := autorest.CreatePreparer(
447		autorest.AsDelete(),
448		autorest.WithBaseURL(client.BaseURI),
449		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/reports/{reportName}", pathParameters),
450		autorest.WithQueryParameters(queryParameters))
451	return preparer.Prepare((&http.Request{}).WithContext(ctx))
452}
453
454// DeleteSender sends the Delete request. The method will close the
455// http.Response Body if it receives an error.
456func (client ReportsClient) DeleteSender(req *http.Request) (*http.Response, error) {
457	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
458}
459
460// DeleteResponder handles the response to the Delete request. The method always
461// closes the http.Response Body.
462func (client ReportsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
463	err = autorest.Respond(
464		resp,
465		azure.WithErrorUnlessStatusCode(http.StatusOK),
466		autorest.ByClosing())
467	result.Response = resp
468	return
469}
470
471// DeleteByBillingAccount the operation to delete a report for billing account.
472// Parameters:
473// billingAccountID - billingAccount ID
474// reportName - report Name.
475func (client ReportsClient) DeleteByBillingAccount(ctx context.Context, billingAccountID string, reportName string) (result autorest.Response, err error) {
476	if tracing.IsEnabled() {
477		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.DeleteByBillingAccount")
478		defer func() {
479			sc := -1
480			if result.Response != nil {
481				sc = result.Response.StatusCode
482			}
483			tracing.EndSpan(ctx, sc, err)
484		}()
485	}
486	req, err := client.DeleteByBillingAccountPreparer(ctx, billingAccountID, reportName)
487	if err != nil {
488		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "DeleteByBillingAccount", nil, "Failure preparing request")
489		return
490	}
491
492	resp, err := client.DeleteByBillingAccountSender(req)
493	if err != nil {
494		result.Response = resp
495		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "DeleteByBillingAccount", resp, "Failure sending request")
496		return
497	}
498
499	result, err = client.DeleteByBillingAccountResponder(resp)
500	if err != nil {
501		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "DeleteByBillingAccount", resp, "Failure responding to request")
502		return
503	}
504
505	return
506}
507
508// DeleteByBillingAccountPreparer prepares the DeleteByBillingAccount request.
509func (client ReportsClient) DeleteByBillingAccountPreparer(ctx context.Context, billingAccountID string, reportName string) (*http.Request, error) {
510	pathParameters := map[string]interface{}{
511		"billingAccountId": autorest.Encode("path", billingAccountID),
512		"reportName":       autorest.Encode("path", reportName),
513	}
514
515	const APIVersion = "2018-08-01-preview"
516	queryParameters := map[string]interface{}{
517		"api-version": APIVersion,
518	}
519
520	preparer := autorest.CreatePreparer(
521		autorest.AsDelete(),
522		autorest.WithBaseURL(client.BaseURI),
523		autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/reports/{reportName}", pathParameters),
524		autorest.WithQueryParameters(queryParameters))
525	return preparer.Prepare((&http.Request{}).WithContext(ctx))
526}
527
528// DeleteByBillingAccountSender sends the DeleteByBillingAccount request. The method will close the
529// http.Response Body if it receives an error.
530func (client ReportsClient) DeleteByBillingAccountSender(req *http.Request) (*http.Response, error) {
531	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
532}
533
534// DeleteByBillingAccountResponder handles the response to the DeleteByBillingAccount request. The method always
535// closes the http.Response Body.
536func (client ReportsClient) DeleteByBillingAccountResponder(resp *http.Response) (result autorest.Response, err error) {
537	err = autorest.Respond(
538		resp,
539		azure.WithErrorUnlessStatusCode(http.StatusOK),
540		autorest.ByClosing())
541	result.Response = resp
542	return
543}
544
545// DeleteByDepartment the operation to delete a report for department.
546// Parameters:
547// departmentID - department ID
548// reportName - report Name.
549func (client ReportsClient) DeleteByDepartment(ctx context.Context, departmentID string, reportName string) (result autorest.Response, err error) {
550	if tracing.IsEnabled() {
551		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.DeleteByDepartment")
552		defer func() {
553			sc := -1
554			if result.Response != nil {
555				sc = result.Response.StatusCode
556			}
557			tracing.EndSpan(ctx, sc, err)
558		}()
559	}
560	req, err := client.DeleteByDepartmentPreparer(ctx, departmentID, reportName)
561	if err != nil {
562		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "DeleteByDepartment", nil, "Failure preparing request")
563		return
564	}
565
566	resp, err := client.DeleteByDepartmentSender(req)
567	if err != nil {
568		result.Response = resp
569		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "DeleteByDepartment", resp, "Failure sending request")
570		return
571	}
572
573	result, err = client.DeleteByDepartmentResponder(resp)
574	if err != nil {
575		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "DeleteByDepartment", resp, "Failure responding to request")
576		return
577	}
578
579	return
580}
581
582// DeleteByDepartmentPreparer prepares the DeleteByDepartment request.
583func (client ReportsClient) DeleteByDepartmentPreparer(ctx context.Context, departmentID string, reportName string) (*http.Request, error) {
584	pathParameters := map[string]interface{}{
585		"departmentId": autorest.Encode("path", departmentID),
586		"reportName":   autorest.Encode("path", reportName),
587	}
588
589	const APIVersion = "2018-08-01-preview"
590	queryParameters := map[string]interface{}{
591		"api-version": APIVersion,
592	}
593
594	preparer := autorest.CreatePreparer(
595		autorest.AsDelete(),
596		autorest.WithBaseURL(client.BaseURI),
597		autorest.WithPathParameters("/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.CostManagement/reports/{reportName}", pathParameters),
598		autorest.WithQueryParameters(queryParameters))
599	return preparer.Prepare((&http.Request{}).WithContext(ctx))
600}
601
602// DeleteByDepartmentSender sends the DeleteByDepartment request. The method will close the
603// http.Response Body if it receives an error.
604func (client ReportsClient) DeleteByDepartmentSender(req *http.Request) (*http.Response, error) {
605	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
606}
607
608// DeleteByDepartmentResponder handles the response to the DeleteByDepartment request. The method always
609// closes the http.Response Body.
610func (client ReportsClient) DeleteByDepartmentResponder(resp *http.Response) (result autorest.Response, err error) {
611	err = autorest.Respond(
612		resp,
613		azure.WithErrorUnlessStatusCode(http.StatusOK),
614		autorest.ByClosing())
615	result.Response = resp
616	return
617}
618
619// DeleteByResourceGroupName the operation to delete a report.
620// Parameters:
621// resourceGroupName - azure Resource Group Name.
622// reportName - report Name.
623func (client ReportsClient) DeleteByResourceGroupName(ctx context.Context, resourceGroupName string, reportName string) (result autorest.Response, err error) {
624	if tracing.IsEnabled() {
625		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.DeleteByResourceGroupName")
626		defer func() {
627			sc := -1
628			if result.Response != nil {
629				sc = result.Response.StatusCode
630			}
631			tracing.EndSpan(ctx, sc, err)
632		}()
633	}
634	req, err := client.DeleteByResourceGroupNamePreparer(ctx, resourceGroupName, reportName)
635	if err != nil {
636		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "DeleteByResourceGroupName", nil, "Failure preparing request")
637		return
638	}
639
640	resp, err := client.DeleteByResourceGroupNameSender(req)
641	if err != nil {
642		result.Response = resp
643		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "DeleteByResourceGroupName", resp, "Failure sending request")
644		return
645	}
646
647	result, err = client.DeleteByResourceGroupNameResponder(resp)
648	if err != nil {
649		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "DeleteByResourceGroupName", resp, "Failure responding to request")
650		return
651	}
652
653	return
654}
655
656// DeleteByResourceGroupNamePreparer prepares the DeleteByResourceGroupName request.
657func (client ReportsClient) DeleteByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportName string) (*http.Request, error) {
658	pathParameters := map[string]interface{}{
659		"reportName":        autorest.Encode("path", reportName),
660		"resourceGroupName": autorest.Encode("path", resourceGroupName),
661		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
662	}
663
664	const APIVersion = "2018-08-01-preview"
665	queryParameters := map[string]interface{}{
666		"api-version": APIVersion,
667	}
668
669	preparer := autorest.CreatePreparer(
670		autorest.AsDelete(),
671		autorest.WithBaseURL(client.BaseURI),
672		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CostManagement/reports/{reportName}", pathParameters),
673		autorest.WithQueryParameters(queryParameters))
674	return preparer.Prepare((&http.Request{}).WithContext(ctx))
675}
676
677// DeleteByResourceGroupNameSender sends the DeleteByResourceGroupName request. The method will close the
678// http.Response Body if it receives an error.
679func (client ReportsClient) DeleteByResourceGroupNameSender(req *http.Request) (*http.Response, error) {
680	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
681}
682
683// DeleteByResourceGroupNameResponder handles the response to the DeleteByResourceGroupName request. The method always
684// closes the http.Response Body.
685func (client ReportsClient) DeleteByResourceGroupNameResponder(resp *http.Response) (result autorest.Response, err error) {
686	err = autorest.Respond(
687		resp,
688		azure.WithErrorUnlessStatusCode(http.StatusOK),
689		autorest.ByClosing())
690	result.Response = resp
691	return
692}
693
694// Execute the operation to execute a report.
695// Parameters:
696// reportName - report Name.
697func (client ReportsClient) Execute(ctx context.Context, reportName string) (result autorest.Response, err error) {
698	if tracing.IsEnabled() {
699		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.Execute")
700		defer func() {
701			sc := -1
702			if result.Response != nil {
703				sc = result.Response.StatusCode
704			}
705			tracing.EndSpan(ctx, sc, err)
706		}()
707	}
708	req, err := client.ExecutePreparer(ctx, reportName)
709	if err != nil {
710		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "Execute", nil, "Failure preparing request")
711		return
712	}
713
714	resp, err := client.ExecuteSender(req)
715	if err != nil {
716		result.Response = resp
717		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "Execute", resp, "Failure sending request")
718		return
719	}
720
721	result, err = client.ExecuteResponder(resp)
722	if err != nil {
723		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "Execute", resp, "Failure responding to request")
724		return
725	}
726
727	return
728}
729
730// ExecutePreparer prepares the Execute request.
731func (client ReportsClient) ExecutePreparer(ctx context.Context, reportName string) (*http.Request, error) {
732	pathParameters := map[string]interface{}{
733		"reportName":     autorest.Encode("path", reportName),
734		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
735	}
736
737	const APIVersion = "2018-08-01-preview"
738	queryParameters := map[string]interface{}{
739		"api-version": APIVersion,
740	}
741
742	preparer := autorest.CreatePreparer(
743		autorest.AsPost(),
744		autorest.WithBaseURL(client.BaseURI),
745		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/reports/{reportName}/run", pathParameters),
746		autorest.WithQueryParameters(queryParameters))
747	return preparer.Prepare((&http.Request{}).WithContext(ctx))
748}
749
750// ExecuteSender sends the Execute request. The method will close the
751// http.Response Body if it receives an error.
752func (client ReportsClient) ExecuteSender(req *http.Request) (*http.Response, error) {
753	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
754}
755
756// ExecuteResponder handles the response to the Execute request. The method always
757// closes the http.Response Body.
758func (client ReportsClient) ExecuteResponder(resp *http.Response) (result autorest.Response, err error) {
759	err = autorest.Respond(
760		resp,
761		azure.WithErrorUnlessStatusCode(http.StatusOK),
762		autorest.ByClosing())
763	result.Response = resp
764	return
765}
766
767// ExecuteByBillingAccount the operation to execute a report by billing account.
768// Parameters:
769// billingAccountID - billingAccount ID
770// reportName - report Name.
771func (client ReportsClient) ExecuteByBillingAccount(ctx context.Context, billingAccountID string, reportName string) (result autorest.Response, err error) {
772	if tracing.IsEnabled() {
773		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ExecuteByBillingAccount")
774		defer func() {
775			sc := -1
776			if result.Response != nil {
777				sc = result.Response.StatusCode
778			}
779			tracing.EndSpan(ctx, sc, err)
780		}()
781	}
782	req, err := client.ExecuteByBillingAccountPreparer(ctx, billingAccountID, reportName)
783	if err != nil {
784		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ExecuteByBillingAccount", nil, "Failure preparing request")
785		return
786	}
787
788	resp, err := client.ExecuteByBillingAccountSender(req)
789	if err != nil {
790		result.Response = resp
791		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ExecuteByBillingAccount", resp, "Failure sending request")
792		return
793	}
794
795	result, err = client.ExecuteByBillingAccountResponder(resp)
796	if err != nil {
797		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ExecuteByBillingAccount", resp, "Failure responding to request")
798		return
799	}
800
801	return
802}
803
804// ExecuteByBillingAccountPreparer prepares the ExecuteByBillingAccount request.
805func (client ReportsClient) ExecuteByBillingAccountPreparer(ctx context.Context, billingAccountID string, reportName string) (*http.Request, error) {
806	pathParameters := map[string]interface{}{
807		"billingAccountId": autorest.Encode("path", billingAccountID),
808		"reportName":       autorest.Encode("path", reportName),
809	}
810
811	const APIVersion = "2018-08-01-preview"
812	queryParameters := map[string]interface{}{
813		"api-version": APIVersion,
814	}
815
816	preparer := autorest.CreatePreparer(
817		autorest.AsPost(),
818		autorest.WithBaseURL(client.BaseURI),
819		autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/reports/{reportName}/run", pathParameters),
820		autorest.WithQueryParameters(queryParameters))
821	return preparer.Prepare((&http.Request{}).WithContext(ctx))
822}
823
824// ExecuteByBillingAccountSender sends the ExecuteByBillingAccount request. The method will close the
825// http.Response Body if it receives an error.
826func (client ReportsClient) ExecuteByBillingAccountSender(req *http.Request) (*http.Response, error) {
827	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
828}
829
830// ExecuteByBillingAccountResponder handles the response to the ExecuteByBillingAccount request. The method always
831// closes the http.Response Body.
832func (client ReportsClient) ExecuteByBillingAccountResponder(resp *http.Response) (result autorest.Response, err error) {
833	err = autorest.Respond(
834		resp,
835		azure.WithErrorUnlessStatusCode(http.StatusOK),
836		autorest.ByClosing())
837	result.Response = resp
838	return
839}
840
841// ExecuteByDepartment the operation to execute a report by department.
842// Parameters:
843// departmentID - department ID
844// reportName - report Name.
845func (client ReportsClient) ExecuteByDepartment(ctx context.Context, departmentID string, reportName string) (result autorest.Response, err error) {
846	if tracing.IsEnabled() {
847		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ExecuteByDepartment")
848		defer func() {
849			sc := -1
850			if result.Response != nil {
851				sc = result.Response.StatusCode
852			}
853			tracing.EndSpan(ctx, sc, err)
854		}()
855	}
856	req, err := client.ExecuteByDepartmentPreparer(ctx, departmentID, reportName)
857	if err != nil {
858		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ExecuteByDepartment", nil, "Failure preparing request")
859		return
860	}
861
862	resp, err := client.ExecuteByDepartmentSender(req)
863	if err != nil {
864		result.Response = resp
865		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ExecuteByDepartment", resp, "Failure sending request")
866		return
867	}
868
869	result, err = client.ExecuteByDepartmentResponder(resp)
870	if err != nil {
871		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ExecuteByDepartment", resp, "Failure responding to request")
872		return
873	}
874
875	return
876}
877
878// ExecuteByDepartmentPreparer prepares the ExecuteByDepartment request.
879func (client ReportsClient) ExecuteByDepartmentPreparer(ctx context.Context, departmentID string, reportName string) (*http.Request, error) {
880	pathParameters := map[string]interface{}{
881		"departmentId": autorest.Encode("path", departmentID),
882		"reportName":   autorest.Encode("path", reportName),
883	}
884
885	const APIVersion = "2018-08-01-preview"
886	queryParameters := map[string]interface{}{
887		"api-version": APIVersion,
888	}
889
890	preparer := autorest.CreatePreparer(
891		autorest.AsPost(),
892		autorest.WithBaseURL(client.BaseURI),
893		autorest.WithPathParameters("/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.CostManagement/reports/{reportName}/run", pathParameters),
894		autorest.WithQueryParameters(queryParameters))
895	return preparer.Prepare((&http.Request{}).WithContext(ctx))
896}
897
898// ExecuteByDepartmentSender sends the ExecuteByDepartment request. The method will close the
899// http.Response Body if it receives an error.
900func (client ReportsClient) ExecuteByDepartmentSender(req *http.Request) (*http.Response, error) {
901	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
902}
903
904// ExecuteByDepartmentResponder handles the response to the ExecuteByDepartment request. The method always
905// closes the http.Response Body.
906func (client ReportsClient) ExecuteByDepartmentResponder(resp *http.Response) (result autorest.Response, err error) {
907	err = autorest.Respond(
908		resp,
909		azure.WithErrorUnlessStatusCode(http.StatusOK),
910		autorest.ByClosing())
911	result.Response = resp
912	return
913}
914
915// ExecuteByResourceGroupName the operation to execute a report.
916// Parameters:
917// resourceGroupName - azure Resource Group Name.
918// reportName - report Name.
919func (client ReportsClient) ExecuteByResourceGroupName(ctx context.Context, resourceGroupName string, reportName string) (result autorest.Response, err error) {
920	if tracing.IsEnabled() {
921		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ExecuteByResourceGroupName")
922		defer func() {
923			sc := -1
924			if result.Response != nil {
925				sc = result.Response.StatusCode
926			}
927			tracing.EndSpan(ctx, sc, err)
928		}()
929	}
930	req, err := client.ExecuteByResourceGroupNamePreparer(ctx, resourceGroupName, reportName)
931	if err != nil {
932		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ExecuteByResourceGroupName", nil, "Failure preparing request")
933		return
934	}
935
936	resp, err := client.ExecuteByResourceGroupNameSender(req)
937	if err != nil {
938		result.Response = resp
939		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ExecuteByResourceGroupName", resp, "Failure sending request")
940		return
941	}
942
943	result, err = client.ExecuteByResourceGroupNameResponder(resp)
944	if err != nil {
945		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ExecuteByResourceGroupName", resp, "Failure responding to request")
946		return
947	}
948
949	return
950}
951
952// ExecuteByResourceGroupNamePreparer prepares the ExecuteByResourceGroupName request.
953func (client ReportsClient) ExecuteByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportName string) (*http.Request, error) {
954	pathParameters := map[string]interface{}{
955		"reportName":        autorest.Encode("path", reportName),
956		"resourceGroupName": autorest.Encode("path", resourceGroupName),
957		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
958	}
959
960	const APIVersion = "2018-08-01-preview"
961	queryParameters := map[string]interface{}{
962		"api-version": APIVersion,
963	}
964
965	preparer := autorest.CreatePreparer(
966		autorest.AsPost(),
967		autorest.WithBaseURL(client.BaseURI),
968		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CostManagement/reports/{reportName}/run", pathParameters),
969		autorest.WithQueryParameters(queryParameters))
970	return preparer.Prepare((&http.Request{}).WithContext(ctx))
971}
972
973// ExecuteByResourceGroupNameSender sends the ExecuteByResourceGroupName request. The method will close the
974// http.Response Body if it receives an error.
975func (client ReportsClient) ExecuteByResourceGroupNameSender(req *http.Request) (*http.Response, error) {
976	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
977}
978
979// ExecuteByResourceGroupNameResponder handles the response to the ExecuteByResourceGroupName request. The method always
980// closes the http.Response Body.
981func (client ReportsClient) ExecuteByResourceGroupNameResponder(resp *http.Response) (result autorest.Response, err error) {
982	err = autorest.Respond(
983		resp,
984		azure.WithErrorUnlessStatusCode(http.StatusOK),
985		autorest.ByClosing())
986	result.Response = resp
987	return
988}
989
990// Get gets the report for a subscription by report name.
991// Parameters:
992// reportName - report Name.
993func (client ReportsClient) Get(ctx context.Context, reportName string) (result Report, err error) {
994	if tracing.IsEnabled() {
995		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.Get")
996		defer func() {
997			sc := -1
998			if result.Response.Response != nil {
999				sc = result.Response.Response.StatusCode
1000			}
1001			tracing.EndSpan(ctx, sc, err)
1002		}()
1003	}
1004	req, err := client.GetPreparer(ctx, reportName)
1005	if err != nil {
1006		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "Get", nil, "Failure preparing request")
1007		return
1008	}
1009
1010	resp, err := client.GetSender(req)
1011	if err != nil {
1012		result.Response = autorest.Response{Response: resp}
1013		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "Get", resp, "Failure sending request")
1014		return
1015	}
1016
1017	result, err = client.GetResponder(resp)
1018	if err != nil {
1019		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "Get", resp, "Failure responding to request")
1020		return
1021	}
1022
1023	return
1024}
1025
1026// GetPreparer prepares the Get request.
1027func (client ReportsClient) GetPreparer(ctx context.Context, reportName string) (*http.Request, error) {
1028	pathParameters := map[string]interface{}{
1029		"reportName":     autorest.Encode("path", reportName),
1030		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
1031	}
1032
1033	const APIVersion = "2018-08-01-preview"
1034	queryParameters := map[string]interface{}{
1035		"api-version": APIVersion,
1036	}
1037
1038	preparer := autorest.CreatePreparer(
1039		autorest.AsGet(),
1040		autorest.WithBaseURL(client.BaseURI),
1041		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/reports/{reportName}", pathParameters),
1042		autorest.WithQueryParameters(queryParameters))
1043	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1044}
1045
1046// GetSender sends the Get request. The method will close the
1047// http.Response Body if it receives an error.
1048func (client ReportsClient) GetSender(req *http.Request) (*http.Response, error) {
1049	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1050}
1051
1052// GetResponder handles the response to the Get request. The method always
1053// closes the http.Response Body.
1054func (client ReportsClient) GetResponder(resp *http.Response) (result Report, err error) {
1055	err = autorest.Respond(
1056		resp,
1057		azure.WithErrorUnlessStatusCode(http.StatusOK),
1058		autorest.ByUnmarshallingJSON(&result),
1059		autorest.ByClosing())
1060	result.Response = autorest.Response{Response: resp}
1061	return
1062}
1063
1064// GetByBillingAccount gets the report for a billing account by report name.
1065// Parameters:
1066// billingAccountID - billingAccount ID
1067// reportName - report Name.
1068func (client ReportsClient) GetByBillingAccount(ctx context.Context, billingAccountID string, reportName string) (result Report, err error) {
1069	if tracing.IsEnabled() {
1070		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.GetByBillingAccount")
1071		defer func() {
1072			sc := -1
1073			if result.Response.Response != nil {
1074				sc = result.Response.Response.StatusCode
1075			}
1076			tracing.EndSpan(ctx, sc, err)
1077		}()
1078	}
1079	req, err := client.GetByBillingAccountPreparer(ctx, billingAccountID, reportName)
1080	if err != nil {
1081		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetByBillingAccount", nil, "Failure preparing request")
1082		return
1083	}
1084
1085	resp, err := client.GetByBillingAccountSender(req)
1086	if err != nil {
1087		result.Response = autorest.Response{Response: resp}
1088		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetByBillingAccount", resp, "Failure sending request")
1089		return
1090	}
1091
1092	result, err = client.GetByBillingAccountResponder(resp)
1093	if err != nil {
1094		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetByBillingAccount", resp, "Failure responding to request")
1095		return
1096	}
1097
1098	return
1099}
1100
1101// GetByBillingAccountPreparer prepares the GetByBillingAccount request.
1102func (client ReportsClient) GetByBillingAccountPreparer(ctx context.Context, billingAccountID string, reportName string) (*http.Request, error) {
1103	pathParameters := map[string]interface{}{
1104		"billingAccountId": autorest.Encode("path", billingAccountID),
1105		"reportName":       autorest.Encode("path", reportName),
1106	}
1107
1108	const APIVersion = "2018-08-01-preview"
1109	queryParameters := map[string]interface{}{
1110		"api-version": APIVersion,
1111	}
1112
1113	preparer := autorest.CreatePreparer(
1114		autorest.AsGet(),
1115		autorest.WithBaseURL(client.BaseURI),
1116		autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/reports/{reportName}", pathParameters),
1117		autorest.WithQueryParameters(queryParameters))
1118	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1119}
1120
1121// GetByBillingAccountSender sends the GetByBillingAccount request. The method will close the
1122// http.Response Body if it receives an error.
1123func (client ReportsClient) GetByBillingAccountSender(req *http.Request) (*http.Response, error) {
1124	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1125}
1126
1127// GetByBillingAccountResponder handles the response to the GetByBillingAccount request. The method always
1128// closes the http.Response Body.
1129func (client ReportsClient) GetByBillingAccountResponder(resp *http.Response) (result Report, err error) {
1130	err = autorest.Respond(
1131		resp,
1132		azure.WithErrorUnlessStatusCode(http.StatusOK),
1133		autorest.ByUnmarshallingJSON(&result),
1134		autorest.ByClosing())
1135	result.Response = autorest.Response{Response: resp}
1136	return
1137}
1138
1139// GetByDepartment gets the report for a department by report name.
1140// Parameters:
1141// departmentID - department ID
1142// reportName - report Name.
1143func (client ReportsClient) GetByDepartment(ctx context.Context, departmentID string, reportName string) (result Report, err error) {
1144	if tracing.IsEnabled() {
1145		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.GetByDepartment")
1146		defer func() {
1147			sc := -1
1148			if result.Response.Response != nil {
1149				sc = result.Response.Response.StatusCode
1150			}
1151			tracing.EndSpan(ctx, sc, err)
1152		}()
1153	}
1154	req, err := client.GetByDepartmentPreparer(ctx, departmentID, reportName)
1155	if err != nil {
1156		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetByDepartment", nil, "Failure preparing request")
1157		return
1158	}
1159
1160	resp, err := client.GetByDepartmentSender(req)
1161	if err != nil {
1162		result.Response = autorest.Response{Response: resp}
1163		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetByDepartment", resp, "Failure sending request")
1164		return
1165	}
1166
1167	result, err = client.GetByDepartmentResponder(resp)
1168	if err != nil {
1169		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetByDepartment", resp, "Failure responding to request")
1170		return
1171	}
1172
1173	return
1174}
1175
1176// GetByDepartmentPreparer prepares the GetByDepartment request.
1177func (client ReportsClient) GetByDepartmentPreparer(ctx context.Context, departmentID string, reportName string) (*http.Request, error) {
1178	pathParameters := map[string]interface{}{
1179		"departmentId": autorest.Encode("path", departmentID),
1180		"reportName":   autorest.Encode("path", reportName),
1181	}
1182
1183	const APIVersion = "2018-08-01-preview"
1184	queryParameters := map[string]interface{}{
1185		"api-version": APIVersion,
1186	}
1187
1188	preparer := autorest.CreatePreparer(
1189		autorest.AsGet(),
1190		autorest.WithBaseURL(client.BaseURI),
1191		autorest.WithPathParameters("/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.CostManagement/reports/{reportName}", pathParameters),
1192		autorest.WithQueryParameters(queryParameters))
1193	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1194}
1195
1196// GetByDepartmentSender sends the GetByDepartment request. The method will close the
1197// http.Response Body if it receives an error.
1198func (client ReportsClient) GetByDepartmentSender(req *http.Request) (*http.Response, error) {
1199	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1200}
1201
1202// GetByDepartmentResponder handles the response to the GetByDepartment request. The method always
1203// closes the http.Response Body.
1204func (client ReportsClient) GetByDepartmentResponder(resp *http.Response) (result Report, err error) {
1205	err = autorest.Respond(
1206		resp,
1207		azure.WithErrorUnlessStatusCode(http.StatusOK),
1208		autorest.ByUnmarshallingJSON(&result),
1209		autorest.ByClosing())
1210	result.Response = autorest.Response{Response: resp}
1211	return
1212}
1213
1214// GetByResourceGroupName gets the report for a resource group under a subscription by report name.
1215// Parameters:
1216// resourceGroupName - azure Resource Group Name.
1217// reportName - report Name.
1218func (client ReportsClient) GetByResourceGroupName(ctx context.Context, resourceGroupName string, reportName string) (result Report, err error) {
1219	if tracing.IsEnabled() {
1220		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.GetByResourceGroupName")
1221		defer func() {
1222			sc := -1
1223			if result.Response.Response != nil {
1224				sc = result.Response.Response.StatusCode
1225			}
1226			tracing.EndSpan(ctx, sc, err)
1227		}()
1228	}
1229	req, err := client.GetByResourceGroupNamePreparer(ctx, resourceGroupName, reportName)
1230	if err != nil {
1231		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetByResourceGroupName", nil, "Failure preparing request")
1232		return
1233	}
1234
1235	resp, err := client.GetByResourceGroupNameSender(req)
1236	if err != nil {
1237		result.Response = autorest.Response{Response: resp}
1238		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetByResourceGroupName", resp, "Failure sending request")
1239		return
1240	}
1241
1242	result, err = client.GetByResourceGroupNameResponder(resp)
1243	if err != nil {
1244		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetByResourceGroupName", resp, "Failure responding to request")
1245		return
1246	}
1247
1248	return
1249}
1250
1251// GetByResourceGroupNamePreparer prepares the GetByResourceGroupName request.
1252func (client ReportsClient) GetByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportName string) (*http.Request, error) {
1253	pathParameters := map[string]interface{}{
1254		"reportName":        autorest.Encode("path", reportName),
1255		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1256		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1257	}
1258
1259	const APIVersion = "2018-08-01-preview"
1260	queryParameters := map[string]interface{}{
1261		"api-version": APIVersion,
1262	}
1263
1264	preparer := autorest.CreatePreparer(
1265		autorest.AsGet(),
1266		autorest.WithBaseURL(client.BaseURI),
1267		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CostManagement/reports/{reportName}", pathParameters),
1268		autorest.WithQueryParameters(queryParameters))
1269	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1270}
1271
1272// GetByResourceGroupNameSender sends the GetByResourceGroupName request. The method will close the
1273// http.Response Body if it receives an error.
1274func (client ReportsClient) GetByResourceGroupNameSender(req *http.Request) (*http.Response, error) {
1275	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1276}
1277
1278// GetByResourceGroupNameResponder handles the response to the GetByResourceGroupName request. The method always
1279// closes the http.Response Body.
1280func (client ReportsClient) GetByResourceGroupNameResponder(resp *http.Response) (result Report, err error) {
1281	err = autorest.Respond(
1282		resp,
1283		azure.WithErrorUnlessStatusCode(http.StatusOK),
1284		autorest.ByUnmarshallingJSON(&result),
1285		autorest.ByClosing())
1286	result.Response = autorest.Response{Response: resp}
1287	return
1288}
1289
1290// GetExecutionHistory gets the execution history of a report for a subscription by report name.
1291// Parameters:
1292// reportName - report Name.
1293func (client ReportsClient) GetExecutionHistory(ctx context.Context, reportName string) (result ReportExecutionListResult, err error) {
1294	if tracing.IsEnabled() {
1295		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.GetExecutionHistory")
1296		defer func() {
1297			sc := -1
1298			if result.Response.Response != nil {
1299				sc = result.Response.Response.StatusCode
1300			}
1301			tracing.EndSpan(ctx, sc, err)
1302		}()
1303	}
1304	req, err := client.GetExecutionHistoryPreparer(ctx, reportName)
1305	if err != nil {
1306		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetExecutionHistory", nil, "Failure preparing request")
1307		return
1308	}
1309
1310	resp, err := client.GetExecutionHistorySender(req)
1311	if err != nil {
1312		result.Response = autorest.Response{Response: resp}
1313		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetExecutionHistory", resp, "Failure sending request")
1314		return
1315	}
1316
1317	result, err = client.GetExecutionHistoryResponder(resp)
1318	if err != nil {
1319		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetExecutionHistory", resp, "Failure responding to request")
1320		return
1321	}
1322
1323	return
1324}
1325
1326// GetExecutionHistoryPreparer prepares the GetExecutionHistory request.
1327func (client ReportsClient) GetExecutionHistoryPreparer(ctx context.Context, reportName string) (*http.Request, error) {
1328	pathParameters := map[string]interface{}{
1329		"reportName":     autorest.Encode("path", reportName),
1330		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
1331	}
1332
1333	const APIVersion = "2018-08-01-preview"
1334	queryParameters := map[string]interface{}{
1335		"api-version": APIVersion,
1336	}
1337
1338	preparer := autorest.CreatePreparer(
1339		autorest.AsGet(),
1340		autorest.WithBaseURL(client.BaseURI),
1341		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/reports/{reportName}/runHistory", pathParameters),
1342		autorest.WithQueryParameters(queryParameters))
1343	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1344}
1345
1346// GetExecutionHistorySender sends the GetExecutionHistory request. The method will close the
1347// http.Response Body if it receives an error.
1348func (client ReportsClient) GetExecutionHistorySender(req *http.Request) (*http.Response, error) {
1349	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1350}
1351
1352// GetExecutionHistoryResponder handles the response to the GetExecutionHistory request. The method always
1353// closes the http.Response Body.
1354func (client ReportsClient) GetExecutionHistoryResponder(resp *http.Response) (result ReportExecutionListResult, err error) {
1355	err = autorest.Respond(
1356		resp,
1357		azure.WithErrorUnlessStatusCode(http.StatusOK),
1358		autorest.ByUnmarshallingJSON(&result),
1359		autorest.ByClosing())
1360	result.Response = autorest.Response{Response: resp}
1361	return
1362}
1363
1364// GetExecutionHistoryByBillingAccount gets the execution history of a report for a billing account by report name.
1365// Parameters:
1366// billingAccountID - billingAccount ID
1367// reportName - report Name.
1368func (client ReportsClient) GetExecutionHistoryByBillingAccount(ctx context.Context, billingAccountID string, reportName string) (result ReportExecutionListResult, err error) {
1369	if tracing.IsEnabled() {
1370		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.GetExecutionHistoryByBillingAccount")
1371		defer func() {
1372			sc := -1
1373			if result.Response.Response != nil {
1374				sc = result.Response.Response.StatusCode
1375			}
1376			tracing.EndSpan(ctx, sc, err)
1377		}()
1378	}
1379	req, err := client.GetExecutionHistoryByBillingAccountPreparer(ctx, billingAccountID, reportName)
1380	if err != nil {
1381		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetExecutionHistoryByBillingAccount", nil, "Failure preparing request")
1382		return
1383	}
1384
1385	resp, err := client.GetExecutionHistoryByBillingAccountSender(req)
1386	if err != nil {
1387		result.Response = autorest.Response{Response: resp}
1388		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetExecutionHistoryByBillingAccount", resp, "Failure sending request")
1389		return
1390	}
1391
1392	result, err = client.GetExecutionHistoryByBillingAccountResponder(resp)
1393	if err != nil {
1394		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetExecutionHistoryByBillingAccount", resp, "Failure responding to request")
1395		return
1396	}
1397
1398	return
1399}
1400
1401// GetExecutionHistoryByBillingAccountPreparer prepares the GetExecutionHistoryByBillingAccount request.
1402func (client ReportsClient) GetExecutionHistoryByBillingAccountPreparer(ctx context.Context, billingAccountID string, reportName string) (*http.Request, error) {
1403	pathParameters := map[string]interface{}{
1404		"billingAccountId": autorest.Encode("path", billingAccountID),
1405		"reportName":       autorest.Encode("path", reportName),
1406	}
1407
1408	const APIVersion = "2018-08-01-preview"
1409	queryParameters := map[string]interface{}{
1410		"api-version": APIVersion,
1411	}
1412
1413	preparer := autorest.CreatePreparer(
1414		autorest.AsGet(),
1415		autorest.WithBaseURL(client.BaseURI),
1416		autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/reports/{reportName}/runHistory", pathParameters),
1417		autorest.WithQueryParameters(queryParameters))
1418	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1419}
1420
1421// GetExecutionHistoryByBillingAccountSender sends the GetExecutionHistoryByBillingAccount request. The method will close the
1422// http.Response Body if it receives an error.
1423func (client ReportsClient) GetExecutionHistoryByBillingAccountSender(req *http.Request) (*http.Response, error) {
1424	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1425}
1426
1427// GetExecutionHistoryByBillingAccountResponder handles the response to the GetExecutionHistoryByBillingAccount request. The method always
1428// closes the http.Response Body.
1429func (client ReportsClient) GetExecutionHistoryByBillingAccountResponder(resp *http.Response) (result ReportExecutionListResult, err error) {
1430	err = autorest.Respond(
1431		resp,
1432		azure.WithErrorUnlessStatusCode(http.StatusOK),
1433		autorest.ByUnmarshallingJSON(&result),
1434		autorest.ByClosing())
1435	result.Response = autorest.Response{Response: resp}
1436	return
1437}
1438
1439// GetExecutionHistoryByDepartment gets the execution history of a report for a department by report name.
1440// Parameters:
1441// departmentID - department ID
1442// reportName - report Name.
1443func (client ReportsClient) GetExecutionHistoryByDepartment(ctx context.Context, departmentID string, reportName string) (result ReportExecutionListResult, err error) {
1444	if tracing.IsEnabled() {
1445		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.GetExecutionHistoryByDepartment")
1446		defer func() {
1447			sc := -1
1448			if result.Response.Response != nil {
1449				sc = result.Response.Response.StatusCode
1450			}
1451			tracing.EndSpan(ctx, sc, err)
1452		}()
1453	}
1454	req, err := client.GetExecutionHistoryByDepartmentPreparer(ctx, departmentID, reportName)
1455	if err != nil {
1456		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetExecutionHistoryByDepartment", nil, "Failure preparing request")
1457		return
1458	}
1459
1460	resp, err := client.GetExecutionHistoryByDepartmentSender(req)
1461	if err != nil {
1462		result.Response = autorest.Response{Response: resp}
1463		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetExecutionHistoryByDepartment", resp, "Failure sending request")
1464		return
1465	}
1466
1467	result, err = client.GetExecutionHistoryByDepartmentResponder(resp)
1468	if err != nil {
1469		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetExecutionHistoryByDepartment", resp, "Failure responding to request")
1470		return
1471	}
1472
1473	return
1474}
1475
1476// GetExecutionHistoryByDepartmentPreparer prepares the GetExecutionHistoryByDepartment request.
1477func (client ReportsClient) GetExecutionHistoryByDepartmentPreparer(ctx context.Context, departmentID string, reportName string) (*http.Request, error) {
1478	pathParameters := map[string]interface{}{
1479		"departmentId": autorest.Encode("path", departmentID),
1480		"reportName":   autorest.Encode("path", reportName),
1481	}
1482
1483	const APIVersion = "2018-08-01-preview"
1484	queryParameters := map[string]interface{}{
1485		"api-version": APIVersion,
1486	}
1487
1488	preparer := autorest.CreatePreparer(
1489		autorest.AsGet(),
1490		autorest.WithBaseURL(client.BaseURI),
1491		autorest.WithPathParameters("/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.CostManagement/reports/{reportName}/runHistory", pathParameters),
1492		autorest.WithQueryParameters(queryParameters))
1493	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1494}
1495
1496// GetExecutionHistoryByDepartmentSender sends the GetExecutionHistoryByDepartment request. The method will close the
1497// http.Response Body if it receives an error.
1498func (client ReportsClient) GetExecutionHistoryByDepartmentSender(req *http.Request) (*http.Response, error) {
1499	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1500}
1501
1502// GetExecutionHistoryByDepartmentResponder handles the response to the GetExecutionHistoryByDepartment request. The method always
1503// closes the http.Response Body.
1504func (client ReportsClient) GetExecutionHistoryByDepartmentResponder(resp *http.Response) (result ReportExecutionListResult, err error) {
1505	err = autorest.Respond(
1506		resp,
1507		azure.WithErrorUnlessStatusCode(http.StatusOK),
1508		autorest.ByUnmarshallingJSON(&result),
1509		autorest.ByClosing())
1510	result.Response = autorest.Response{Response: resp}
1511	return
1512}
1513
1514// GetExecutionHistoryByResourceGroupName gets the execution history of a report for a resource group by report name.
1515// Parameters:
1516// resourceGroupName - azure Resource Group Name.
1517// reportName - report Name.
1518func (client ReportsClient) GetExecutionHistoryByResourceGroupName(ctx context.Context, resourceGroupName string, reportName string) (result ReportExecutionListResult, err error) {
1519	if tracing.IsEnabled() {
1520		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.GetExecutionHistoryByResourceGroupName")
1521		defer func() {
1522			sc := -1
1523			if result.Response.Response != nil {
1524				sc = result.Response.Response.StatusCode
1525			}
1526			tracing.EndSpan(ctx, sc, err)
1527		}()
1528	}
1529	req, err := client.GetExecutionHistoryByResourceGroupNamePreparer(ctx, resourceGroupName, reportName)
1530	if err != nil {
1531		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetExecutionHistoryByResourceGroupName", nil, "Failure preparing request")
1532		return
1533	}
1534
1535	resp, err := client.GetExecutionHistoryByResourceGroupNameSender(req)
1536	if err != nil {
1537		result.Response = autorest.Response{Response: resp}
1538		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetExecutionHistoryByResourceGroupName", resp, "Failure sending request")
1539		return
1540	}
1541
1542	result, err = client.GetExecutionHistoryByResourceGroupNameResponder(resp)
1543	if err != nil {
1544		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "GetExecutionHistoryByResourceGroupName", resp, "Failure responding to request")
1545		return
1546	}
1547
1548	return
1549}
1550
1551// GetExecutionHistoryByResourceGroupNamePreparer prepares the GetExecutionHistoryByResourceGroupName request.
1552func (client ReportsClient) GetExecutionHistoryByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportName string) (*http.Request, error) {
1553	pathParameters := map[string]interface{}{
1554		"reportName":        autorest.Encode("path", reportName),
1555		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1556		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1557	}
1558
1559	const APIVersion = "2018-08-01-preview"
1560	queryParameters := map[string]interface{}{
1561		"api-version": APIVersion,
1562	}
1563
1564	preparer := autorest.CreatePreparer(
1565		autorest.AsGet(),
1566		autorest.WithBaseURL(client.BaseURI),
1567		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CostManagement/reports/{reportName}/runHistory", pathParameters),
1568		autorest.WithQueryParameters(queryParameters))
1569	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1570}
1571
1572// GetExecutionHistoryByResourceGroupNameSender sends the GetExecutionHistoryByResourceGroupName request. The method will close the
1573// http.Response Body if it receives an error.
1574func (client ReportsClient) GetExecutionHistoryByResourceGroupNameSender(req *http.Request) (*http.Response, error) {
1575	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1576}
1577
1578// GetExecutionHistoryByResourceGroupNameResponder handles the response to the GetExecutionHistoryByResourceGroupName request. The method always
1579// closes the http.Response Body.
1580func (client ReportsClient) GetExecutionHistoryByResourceGroupNameResponder(resp *http.Response) (result ReportExecutionListResult, err error) {
1581	err = autorest.Respond(
1582		resp,
1583		azure.WithErrorUnlessStatusCode(http.StatusOK),
1584		autorest.ByUnmarshallingJSON(&result),
1585		autorest.ByClosing())
1586	result.Response = autorest.Response{Response: resp}
1587	return
1588}
1589
1590// List lists all reports for a subscription.
1591func (client ReportsClient) List(ctx context.Context) (result ReportListResult, err error) {
1592	if tracing.IsEnabled() {
1593		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.List")
1594		defer func() {
1595			sc := -1
1596			if result.Response.Response != nil {
1597				sc = result.Response.Response.StatusCode
1598			}
1599			tracing.EndSpan(ctx, sc, err)
1600		}()
1601	}
1602	req, err := client.ListPreparer(ctx)
1603	if err != nil {
1604		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "List", nil, "Failure preparing request")
1605		return
1606	}
1607
1608	resp, err := client.ListSender(req)
1609	if err != nil {
1610		result.Response = autorest.Response{Response: resp}
1611		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "List", resp, "Failure sending request")
1612		return
1613	}
1614
1615	result, err = client.ListResponder(resp)
1616	if err != nil {
1617		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "List", resp, "Failure responding to request")
1618		return
1619	}
1620
1621	return
1622}
1623
1624// ListPreparer prepares the List request.
1625func (client ReportsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
1626	pathParameters := map[string]interface{}{
1627		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
1628	}
1629
1630	const APIVersion = "2018-08-01-preview"
1631	queryParameters := map[string]interface{}{
1632		"api-version": APIVersion,
1633	}
1634
1635	preparer := autorest.CreatePreparer(
1636		autorest.AsGet(),
1637		autorest.WithBaseURL(client.BaseURI),
1638		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/reports", pathParameters),
1639		autorest.WithQueryParameters(queryParameters))
1640	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1641}
1642
1643// ListSender sends the List request. The method will close the
1644// http.Response Body if it receives an error.
1645func (client ReportsClient) ListSender(req *http.Request) (*http.Response, error) {
1646	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1647}
1648
1649// ListResponder handles the response to the List request. The method always
1650// closes the http.Response Body.
1651func (client ReportsClient) ListResponder(resp *http.Response) (result ReportListResult, err error) {
1652	err = autorest.Respond(
1653		resp,
1654		azure.WithErrorUnlessStatusCode(http.StatusOK),
1655		autorest.ByUnmarshallingJSON(&result),
1656		autorest.ByClosing())
1657	result.Response = autorest.Response{Response: resp}
1658	return
1659}
1660
1661// ListByBillingAccount lists all reports for a billing account.
1662// Parameters:
1663// billingAccountID - billingAccount ID
1664func (client ReportsClient) ListByBillingAccount(ctx context.Context, billingAccountID string) (result ReportListResult, err error) {
1665	if tracing.IsEnabled() {
1666		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByBillingAccount")
1667		defer func() {
1668			sc := -1
1669			if result.Response.Response != nil {
1670				sc = result.Response.Response.StatusCode
1671			}
1672			tracing.EndSpan(ctx, sc, err)
1673		}()
1674	}
1675	req, err := client.ListByBillingAccountPreparer(ctx, billingAccountID)
1676	if err != nil {
1677		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ListByBillingAccount", nil, "Failure preparing request")
1678		return
1679	}
1680
1681	resp, err := client.ListByBillingAccountSender(req)
1682	if err != nil {
1683		result.Response = autorest.Response{Response: resp}
1684		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ListByBillingAccount", resp, "Failure sending request")
1685		return
1686	}
1687
1688	result, err = client.ListByBillingAccountResponder(resp)
1689	if err != nil {
1690		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ListByBillingAccount", resp, "Failure responding to request")
1691		return
1692	}
1693
1694	return
1695}
1696
1697// ListByBillingAccountPreparer prepares the ListByBillingAccount request.
1698func (client ReportsClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountID string) (*http.Request, error) {
1699	pathParameters := map[string]interface{}{
1700		"billingAccountId": autorest.Encode("path", billingAccountID),
1701	}
1702
1703	const APIVersion = "2018-08-01-preview"
1704	queryParameters := map[string]interface{}{
1705		"api-version": APIVersion,
1706	}
1707
1708	preparer := autorest.CreatePreparer(
1709		autorest.AsGet(),
1710		autorest.WithBaseURL(client.BaseURI),
1711		autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/reports", pathParameters),
1712		autorest.WithQueryParameters(queryParameters))
1713	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1714}
1715
1716// ListByBillingAccountSender sends the ListByBillingAccount request. The method will close the
1717// http.Response Body if it receives an error.
1718func (client ReportsClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) {
1719	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1720}
1721
1722// ListByBillingAccountResponder handles the response to the ListByBillingAccount request. The method always
1723// closes the http.Response Body.
1724func (client ReportsClient) ListByBillingAccountResponder(resp *http.Response) (result ReportListResult, err error) {
1725	err = autorest.Respond(
1726		resp,
1727		azure.WithErrorUnlessStatusCode(http.StatusOK),
1728		autorest.ByUnmarshallingJSON(&result),
1729		autorest.ByClosing())
1730	result.Response = autorest.Response{Response: resp}
1731	return
1732}
1733
1734// ListByDepartment lists all reports for a department.
1735// Parameters:
1736// departmentID - department ID
1737func (client ReportsClient) ListByDepartment(ctx context.Context, departmentID string) (result ReportListResult, err error) {
1738	if tracing.IsEnabled() {
1739		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByDepartment")
1740		defer func() {
1741			sc := -1
1742			if result.Response.Response != nil {
1743				sc = result.Response.Response.StatusCode
1744			}
1745			tracing.EndSpan(ctx, sc, err)
1746		}()
1747	}
1748	req, err := client.ListByDepartmentPreparer(ctx, departmentID)
1749	if err != nil {
1750		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ListByDepartment", nil, "Failure preparing request")
1751		return
1752	}
1753
1754	resp, err := client.ListByDepartmentSender(req)
1755	if err != nil {
1756		result.Response = autorest.Response{Response: resp}
1757		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ListByDepartment", resp, "Failure sending request")
1758		return
1759	}
1760
1761	result, err = client.ListByDepartmentResponder(resp)
1762	if err != nil {
1763		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ListByDepartment", resp, "Failure responding to request")
1764		return
1765	}
1766
1767	return
1768}
1769
1770// ListByDepartmentPreparer prepares the ListByDepartment request.
1771func (client ReportsClient) ListByDepartmentPreparer(ctx context.Context, departmentID string) (*http.Request, error) {
1772	pathParameters := map[string]interface{}{
1773		"departmentId": autorest.Encode("path", departmentID),
1774	}
1775
1776	const APIVersion = "2018-08-01-preview"
1777	queryParameters := map[string]interface{}{
1778		"api-version": APIVersion,
1779	}
1780
1781	preparer := autorest.CreatePreparer(
1782		autorest.AsGet(),
1783		autorest.WithBaseURL(client.BaseURI),
1784		autorest.WithPathParameters("/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.CostManagement/reports", pathParameters),
1785		autorest.WithQueryParameters(queryParameters))
1786	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1787}
1788
1789// ListByDepartmentSender sends the ListByDepartment request. The method will close the
1790// http.Response Body if it receives an error.
1791func (client ReportsClient) ListByDepartmentSender(req *http.Request) (*http.Response, error) {
1792	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1793}
1794
1795// ListByDepartmentResponder handles the response to the ListByDepartment request. The method always
1796// closes the http.Response Body.
1797func (client ReportsClient) ListByDepartmentResponder(resp *http.Response) (result ReportListResult, err error) {
1798	err = autorest.Respond(
1799		resp,
1800		azure.WithErrorUnlessStatusCode(http.StatusOK),
1801		autorest.ByUnmarshallingJSON(&result),
1802		autorest.ByClosing())
1803	result.Response = autorest.Response{Response: resp}
1804	return
1805}
1806
1807// ListByResourceGroupName lists all reports for a resource group under a subscription.
1808// Parameters:
1809// resourceGroupName - azure Resource Group Name.
1810func (client ReportsClient) ListByResourceGroupName(ctx context.Context, resourceGroupName string) (result ReportListResult, err error) {
1811	if tracing.IsEnabled() {
1812		ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByResourceGroupName")
1813		defer func() {
1814			sc := -1
1815			if result.Response.Response != nil {
1816				sc = result.Response.Response.StatusCode
1817			}
1818			tracing.EndSpan(ctx, sc, err)
1819		}()
1820	}
1821	req, err := client.ListByResourceGroupNamePreparer(ctx, resourceGroupName)
1822	if err != nil {
1823		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ListByResourceGroupName", nil, "Failure preparing request")
1824		return
1825	}
1826
1827	resp, err := client.ListByResourceGroupNameSender(req)
1828	if err != nil {
1829		result.Response = autorest.Response{Response: resp}
1830		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ListByResourceGroupName", resp, "Failure sending request")
1831		return
1832	}
1833
1834	result, err = client.ListByResourceGroupNameResponder(resp)
1835	if err != nil {
1836		err = autorest.NewErrorWithError(err, "costmanagement.ReportsClient", "ListByResourceGroupName", resp, "Failure responding to request")
1837		return
1838	}
1839
1840	return
1841}
1842
1843// ListByResourceGroupNamePreparer prepares the ListByResourceGroupName request.
1844func (client ReportsClient) ListByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
1845	pathParameters := map[string]interface{}{
1846		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1847		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1848	}
1849
1850	const APIVersion = "2018-08-01-preview"
1851	queryParameters := map[string]interface{}{
1852		"api-version": APIVersion,
1853	}
1854
1855	preparer := autorest.CreatePreparer(
1856		autorest.AsGet(),
1857		autorest.WithBaseURL(client.BaseURI),
1858		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CostManagement/reports", pathParameters),
1859		autorest.WithQueryParameters(queryParameters))
1860	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1861}
1862
1863// ListByResourceGroupNameSender sends the ListByResourceGroupName request. The method will close the
1864// http.Response Body if it receives an error.
1865func (client ReportsClient) ListByResourceGroupNameSender(req *http.Request) (*http.Response, error) {
1866	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1867}
1868
1869// ListByResourceGroupNameResponder handles the response to the ListByResourceGroupName request. The method always
1870// closes the http.Response Body.
1871func (client ReportsClient) ListByResourceGroupNameResponder(resp *http.Response) (result ReportListResult, err error) {
1872	err = autorest.Respond(
1873		resp,
1874		azure.WithErrorUnlessStatusCode(http.StatusOK),
1875		autorest.ByUnmarshallingJSON(&result),
1876		autorest.ByClosing())
1877	result.Response = autorest.Response{Response: resp}
1878	return
1879}
1880