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