1package billing 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/tracing" 25 "net/http" 26) 27 28// InvoiceSectionsClient is the billing client provides access to billing resources for Azure subscriptions. 29type InvoiceSectionsClient struct { 30 BaseClient 31} 32 33// NewInvoiceSectionsClient creates an instance of the InvoiceSectionsClient client. 34func NewInvoiceSectionsClient(subscriptionID string) InvoiceSectionsClient { 35 return NewInvoiceSectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewInvoiceSectionsClientWithBaseURI creates an instance of the InvoiceSectionsClient client. 39func NewInvoiceSectionsClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionsClient { 40 return InvoiceSectionsClient{NewWithBaseURI(baseURI, subscriptionID)} 41} 42 43// Create the operation to create a InvoiceSection. 44// Parameters: 45// billingAccountName - billing Account Id. 46// parameters - parameters supplied to the Create InvoiceSection operation. 47func (client InvoiceSectionsClient) Create(ctx context.Context, billingAccountName string, parameters InvoiceSectionCreationRequest) (result InvoiceSectionsCreateFuture, err error) { 48 if tracing.IsEnabled() { 49 ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.Create") 50 defer func() { 51 sc := -1 52 if result.Response() != nil { 53 sc = result.Response().StatusCode 54 } 55 tracing.EndSpan(ctx, sc, err) 56 }() 57 } 58 req, err := client.CreatePreparer(ctx, billingAccountName, parameters) 59 if err != nil { 60 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Create", nil, "Failure preparing request") 61 return 62 } 63 64 result, err = client.CreateSender(req) 65 if err != nil { 66 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Create", result.Response(), "Failure sending request") 67 return 68 } 69 70 return 71} 72 73// CreatePreparer prepares the Create request. 74func (client InvoiceSectionsClient) CreatePreparer(ctx context.Context, billingAccountName string, parameters InvoiceSectionCreationRequest) (*http.Request, error) { 75 pathParameters := map[string]interface{}{ 76 "billingAccountName": autorest.Encode("path", billingAccountName), 77 } 78 79 const APIVersion = "2018-11-01-preview" 80 queryParameters := map[string]interface{}{ 81 "api-version": APIVersion, 82 } 83 84 preparer := autorest.CreatePreparer( 85 autorest.AsContentType("application/json; charset=utf-8"), 86 autorest.AsPost(), 87 autorest.WithBaseURL(client.BaseURI), 88 autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections", pathParameters), 89 autorest.WithJSON(parameters), 90 autorest.WithQueryParameters(queryParameters)) 91 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 92} 93 94// CreateSender sends the Create request. The method will close the 95// http.Response Body if it receives an error. 96func (client InvoiceSectionsClient) CreateSender(req *http.Request) (future InvoiceSectionsCreateFuture, err error) { 97 sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 98 var resp *http.Response 99 resp, err = autorest.SendWithSender(client, req, sd...) 100 if err != nil { 101 return 102 } 103 future.Future, err = azure.NewFutureFromResponse(resp) 104 return 105} 106 107// CreateResponder handles the response to the Create request. The method always 108// closes the http.Response Body. 109func (client InvoiceSectionsClient) CreateResponder(resp *http.Response) (result InvoiceSection, err error) { 110 err = autorest.Respond( 111 resp, 112 client.ByInspecting(), 113 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 114 autorest.ByUnmarshallingJSON(&result), 115 autorest.ByClosing()) 116 result.Response = autorest.Response{Response: resp} 117 return 118} 119 120// ElevateToBillingProfile elevates the caller's access to match their billing profile access. 121// Parameters: 122// billingAccountName - billing Account Id. 123// invoiceSectionName - invoiceSection Id. 124func (client InvoiceSectionsClient) ElevateToBillingProfile(ctx context.Context, billingAccountName string, invoiceSectionName string) (result autorest.Response, err error) { 125 if tracing.IsEnabled() { 126 ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.ElevateToBillingProfile") 127 defer func() { 128 sc := -1 129 if result.Response != nil { 130 sc = result.Response.StatusCode 131 } 132 tracing.EndSpan(ctx, sc, err) 133 }() 134 } 135 req, err := client.ElevateToBillingProfilePreparer(ctx, billingAccountName, invoiceSectionName) 136 if err != nil { 137 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ElevateToBillingProfile", nil, "Failure preparing request") 138 return 139 } 140 141 resp, err := client.ElevateToBillingProfileSender(req) 142 if err != nil { 143 result.Response = resp 144 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ElevateToBillingProfile", resp, "Failure sending request") 145 return 146 } 147 148 result, err = client.ElevateToBillingProfileResponder(resp) 149 if err != nil { 150 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ElevateToBillingProfile", resp, "Failure responding to request") 151 } 152 153 return 154} 155 156// ElevateToBillingProfilePreparer prepares the ElevateToBillingProfile request. 157func (client InvoiceSectionsClient) ElevateToBillingProfilePreparer(ctx context.Context, billingAccountName string, invoiceSectionName string) (*http.Request, error) { 158 pathParameters := map[string]interface{}{ 159 "billingAccountName": autorest.Encode("path", billingAccountName), 160 "invoiceSectionName": autorest.Encode("path", invoiceSectionName), 161 } 162 163 preparer := autorest.CreatePreparer( 164 autorest.AsPost(), 165 autorest.WithBaseURL(client.BaseURI), 166 autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/elevate", pathParameters)) 167 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 168} 169 170// ElevateToBillingProfileSender sends the ElevateToBillingProfile request. The method will close the 171// http.Response Body if it receives an error. 172func (client InvoiceSectionsClient) ElevateToBillingProfileSender(req *http.Request) (*http.Response, error) { 173 sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 174 return autorest.SendWithSender(client, req, sd...) 175} 176 177// ElevateToBillingProfileResponder handles the response to the ElevateToBillingProfile request. The method always 178// closes the http.Response Body. 179func (client InvoiceSectionsClient) ElevateToBillingProfileResponder(resp *http.Response) (result autorest.Response, err error) { 180 err = autorest.Respond( 181 resp, 182 client.ByInspecting(), 183 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 184 autorest.ByClosing()) 185 result.Response = resp 186 return 187} 188 189// Get get the InvoiceSection by id. 190// Parameters: 191// billingAccountName - billing Account Id. 192// invoiceSectionName - invoiceSection Id. 193// expand - may be used to expand the billingProfiles. 194func (client InvoiceSectionsClient) Get(ctx context.Context, billingAccountName string, invoiceSectionName string, expand string) (result InvoiceSection, err error) { 195 if tracing.IsEnabled() { 196 ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.Get") 197 defer func() { 198 sc := -1 199 if result.Response.Response != nil { 200 sc = result.Response.Response.StatusCode 201 } 202 tracing.EndSpan(ctx, sc, err) 203 }() 204 } 205 req, err := client.GetPreparer(ctx, billingAccountName, invoiceSectionName, expand) 206 if err != nil { 207 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Get", nil, "Failure preparing request") 208 return 209 } 210 211 resp, err := client.GetSender(req) 212 if err != nil { 213 result.Response = autorest.Response{Response: resp} 214 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Get", resp, "Failure sending request") 215 return 216 } 217 218 result, err = client.GetResponder(resp) 219 if err != nil { 220 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Get", resp, "Failure responding to request") 221 } 222 223 return 224} 225 226// GetPreparer prepares the Get request. 227func (client InvoiceSectionsClient) GetPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, expand string) (*http.Request, error) { 228 pathParameters := map[string]interface{}{ 229 "billingAccountName": autorest.Encode("path", billingAccountName), 230 "invoiceSectionName": autorest.Encode("path", invoiceSectionName), 231 } 232 233 const APIVersion = "2018-11-01-preview" 234 queryParameters := map[string]interface{}{ 235 "api-version": APIVersion, 236 } 237 if len(expand) > 0 { 238 queryParameters["$expand"] = autorest.Encode("query", expand) 239 } 240 241 preparer := autorest.CreatePreparer( 242 autorest.AsGet(), 243 autorest.WithBaseURL(client.BaseURI), 244 autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}", pathParameters), 245 autorest.WithQueryParameters(queryParameters)) 246 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 247} 248 249// GetSender sends the Get request. The method will close the 250// http.Response Body if it receives an error. 251func (client InvoiceSectionsClient) GetSender(req *http.Request) (*http.Response, error) { 252 sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 253 return autorest.SendWithSender(client, req, sd...) 254} 255 256// GetResponder handles the response to the Get request. The method always 257// closes the http.Response Body. 258func (client InvoiceSectionsClient) GetResponder(resp *http.Response) (result InvoiceSection, err error) { 259 err = autorest.Respond( 260 resp, 261 client.ByInspecting(), 262 azure.WithErrorUnlessStatusCode(http.StatusOK), 263 autorest.ByUnmarshallingJSON(&result), 264 autorest.ByClosing()) 265 result.Response = autorest.Response{Response: resp} 266 return 267} 268 269// ListByBillingAccountName lists all invoice sections for which a user has access. 270// Parameters: 271// billingAccountName - billing Account Id. 272// expand - may be used to expand the billingProfiles. 273func (client InvoiceSectionsClient) ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string) (result InvoiceSectionListResult, err error) { 274 if tracing.IsEnabled() { 275 ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.ListByBillingAccountName") 276 defer func() { 277 sc := -1 278 if result.Response.Response != nil { 279 sc = result.Response.Response.StatusCode 280 } 281 tracing.EndSpan(ctx, sc, err) 282 }() 283 } 284 req, err := client.ListByBillingAccountNamePreparer(ctx, billingAccountName, expand) 285 if err != nil { 286 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByBillingAccountName", nil, "Failure preparing request") 287 return 288 } 289 290 resp, err := client.ListByBillingAccountNameSender(req) 291 if err != nil { 292 result.Response = autorest.Response{Response: resp} 293 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByBillingAccountName", resp, "Failure sending request") 294 return 295 } 296 297 result, err = client.ListByBillingAccountNameResponder(resp) 298 if err != nil { 299 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByBillingAccountName", resp, "Failure responding to request") 300 } 301 302 return 303} 304 305// ListByBillingAccountNamePreparer prepares the ListByBillingAccountName request. 306func (client InvoiceSectionsClient) ListByBillingAccountNamePreparer(ctx context.Context, billingAccountName string, expand string) (*http.Request, error) { 307 pathParameters := map[string]interface{}{ 308 "billingAccountName": autorest.Encode("path", billingAccountName), 309 } 310 311 const APIVersion = "2018-11-01-preview" 312 queryParameters := map[string]interface{}{ 313 "api-version": APIVersion, 314 } 315 if len(expand) > 0 { 316 queryParameters["$expand"] = autorest.Encode("query", expand) 317 } 318 319 preparer := autorest.CreatePreparer( 320 autorest.AsGet(), 321 autorest.WithBaseURL(client.BaseURI), 322 autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections", pathParameters), 323 autorest.WithQueryParameters(queryParameters)) 324 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 325} 326 327// ListByBillingAccountNameSender sends the ListByBillingAccountName request. The method will close the 328// http.Response Body if it receives an error. 329func (client InvoiceSectionsClient) ListByBillingAccountNameSender(req *http.Request) (*http.Response, error) { 330 sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 331 return autorest.SendWithSender(client, req, sd...) 332} 333 334// ListByBillingAccountNameResponder handles the response to the ListByBillingAccountName request. The method always 335// closes the http.Response Body. 336func (client InvoiceSectionsClient) ListByBillingAccountNameResponder(resp *http.Response) (result InvoiceSectionListResult, err error) { 337 err = autorest.Respond( 338 resp, 339 client.ByInspecting(), 340 azure.WithErrorUnlessStatusCode(http.StatusOK), 341 autorest.ByUnmarshallingJSON(&result), 342 autorest.ByClosing()) 343 result.Response = autorest.Response{Response: resp} 344 return 345} 346 347// ListByBillingProfileName lists all invoice sections under a billing profile for which a user has access. 348// Parameters: 349// billingAccountName - billing Account Id. 350// billingProfileName - billing Profile Id. 351func (client InvoiceSectionsClient) ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string) (result InvoiceSectionListResultPage, err error) { 352 if tracing.IsEnabled() { 353 ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.ListByBillingProfileName") 354 defer func() { 355 sc := -1 356 if result.islr.Response.Response != nil { 357 sc = result.islr.Response.Response.StatusCode 358 } 359 tracing.EndSpan(ctx, sc, err) 360 }() 361 } 362 result.fn = client.listByBillingProfileNameNextResults 363 req, err := client.ListByBillingProfileNamePreparer(ctx, billingAccountName, billingProfileName) 364 if err != nil { 365 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByBillingProfileName", nil, "Failure preparing request") 366 return 367 } 368 369 resp, err := client.ListByBillingProfileNameSender(req) 370 if err != nil { 371 result.islr.Response = autorest.Response{Response: resp} 372 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByBillingProfileName", resp, "Failure sending request") 373 return 374 } 375 376 result.islr, err = client.ListByBillingProfileNameResponder(resp) 377 if err != nil { 378 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByBillingProfileName", resp, "Failure responding to request") 379 } 380 381 return 382} 383 384// ListByBillingProfileNamePreparer prepares the ListByBillingProfileName request. 385func (client InvoiceSectionsClient) ListByBillingProfileNamePreparer(ctx context.Context, billingAccountName string, billingProfileName string) (*http.Request, error) { 386 pathParameters := map[string]interface{}{ 387 "billingAccountName": autorest.Encode("path", billingAccountName), 388 "billingProfileName": autorest.Encode("path", billingProfileName), 389 } 390 391 const APIVersion = "2018-11-01-preview" 392 queryParameters := map[string]interface{}{ 393 "api-version": APIVersion, 394 } 395 396 preparer := autorest.CreatePreparer( 397 autorest.AsGet(), 398 autorest.WithBaseURL(client.BaseURI), 399 autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections", pathParameters), 400 autorest.WithQueryParameters(queryParameters)) 401 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 402} 403 404// ListByBillingProfileNameSender sends the ListByBillingProfileName request. The method will close the 405// http.Response Body if it receives an error. 406func (client InvoiceSectionsClient) ListByBillingProfileNameSender(req *http.Request) (*http.Response, error) { 407 sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 408 return autorest.SendWithSender(client, req, sd...) 409} 410 411// ListByBillingProfileNameResponder handles the response to the ListByBillingProfileName request. The method always 412// closes the http.Response Body. 413func (client InvoiceSectionsClient) ListByBillingProfileNameResponder(resp *http.Response) (result InvoiceSectionListResult, err error) { 414 err = autorest.Respond( 415 resp, 416 client.ByInspecting(), 417 azure.WithErrorUnlessStatusCode(http.StatusOK), 418 autorest.ByUnmarshallingJSON(&result), 419 autorest.ByClosing()) 420 result.Response = autorest.Response{Response: resp} 421 return 422} 423 424// listByBillingProfileNameNextResults retrieves the next set of results, if any. 425func (client InvoiceSectionsClient) listByBillingProfileNameNextResults(ctx context.Context, lastResults InvoiceSectionListResult) (result InvoiceSectionListResult, err error) { 426 req, err := lastResults.invoiceSectionListResultPreparer(ctx) 427 if err != nil { 428 return result, autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByBillingProfileNameNextResults", nil, "Failure preparing next results request") 429 } 430 if req == nil { 431 return 432 } 433 resp, err := client.ListByBillingProfileNameSender(req) 434 if err != nil { 435 result.Response = autorest.Response{Response: resp} 436 return result, autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByBillingProfileNameNextResults", resp, "Failure sending next results request") 437 } 438 result, err = client.ListByBillingProfileNameResponder(resp) 439 if err != nil { 440 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByBillingProfileNameNextResults", resp, "Failure responding to next results request") 441 } 442 return 443} 444 445// ListByBillingProfileNameComplete enumerates all values, automatically crossing page boundaries as required. 446func (client InvoiceSectionsClient) ListByBillingProfileNameComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result InvoiceSectionListResultIterator, err error) { 447 if tracing.IsEnabled() { 448 ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.ListByBillingProfileName") 449 defer func() { 450 sc := -1 451 if result.Response().Response.Response != nil { 452 sc = result.page.Response().Response.Response.StatusCode 453 } 454 tracing.EndSpan(ctx, sc, err) 455 }() 456 } 457 result.page, err = client.ListByBillingProfileName(ctx, billingAccountName, billingProfileName) 458 return 459} 460 461// ListByCreateSubscriptionPermission lists all invoiceSections with create subscription permission for a user. 462// Parameters: 463// billingAccountName - billing Account Id. 464// expand - may be used to expand the billingProfiles. 465func (client InvoiceSectionsClient) ListByCreateSubscriptionPermission(ctx context.Context, billingAccountName string, expand string) (result InvoiceSectionListResultPage, err error) { 466 if tracing.IsEnabled() { 467 ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.ListByCreateSubscriptionPermission") 468 defer func() { 469 sc := -1 470 if result.islr.Response.Response != nil { 471 sc = result.islr.Response.Response.StatusCode 472 } 473 tracing.EndSpan(ctx, sc, err) 474 }() 475 } 476 result.fn = client.listByCreateSubscriptionPermissionNextResults 477 req, err := client.ListByCreateSubscriptionPermissionPreparer(ctx, billingAccountName, expand) 478 if err != nil { 479 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByCreateSubscriptionPermission", nil, "Failure preparing request") 480 return 481 } 482 483 resp, err := client.ListByCreateSubscriptionPermissionSender(req) 484 if err != nil { 485 result.islr.Response = autorest.Response{Response: resp} 486 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByCreateSubscriptionPermission", resp, "Failure sending request") 487 return 488 } 489 490 result.islr, err = client.ListByCreateSubscriptionPermissionResponder(resp) 491 if err != nil { 492 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByCreateSubscriptionPermission", resp, "Failure responding to request") 493 } 494 495 return 496} 497 498// ListByCreateSubscriptionPermissionPreparer prepares the ListByCreateSubscriptionPermission request. 499func (client InvoiceSectionsClient) ListByCreateSubscriptionPermissionPreparer(ctx context.Context, billingAccountName string, expand string) (*http.Request, error) { 500 pathParameters := map[string]interface{}{ 501 "billingAccountName": autorest.Encode("path", billingAccountName), 502 } 503 504 const APIVersion = "2018-11-01-preview" 505 queryParameters := map[string]interface{}{ 506 "api-version": APIVersion, 507 } 508 if len(expand) > 0 { 509 queryParameters["$expand"] = autorest.Encode("query", expand) 510 } 511 512 preparer := autorest.CreatePreparer( 513 autorest.AsGet(), 514 autorest.WithBaseURL(client.BaseURI), 515 autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/listInvoiceSectionsWithCreateSubscriptionPermission", pathParameters), 516 autorest.WithQueryParameters(queryParameters)) 517 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 518} 519 520// ListByCreateSubscriptionPermissionSender sends the ListByCreateSubscriptionPermission request. The method will close the 521// http.Response Body if it receives an error. 522func (client InvoiceSectionsClient) ListByCreateSubscriptionPermissionSender(req *http.Request) (*http.Response, error) { 523 sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 524 return autorest.SendWithSender(client, req, sd...) 525} 526 527// ListByCreateSubscriptionPermissionResponder handles the response to the ListByCreateSubscriptionPermission request. The method always 528// closes the http.Response Body. 529func (client InvoiceSectionsClient) ListByCreateSubscriptionPermissionResponder(resp *http.Response) (result InvoiceSectionListResult, err error) { 530 err = autorest.Respond( 531 resp, 532 client.ByInspecting(), 533 azure.WithErrorUnlessStatusCode(http.StatusOK), 534 autorest.ByUnmarshallingJSON(&result), 535 autorest.ByClosing()) 536 result.Response = autorest.Response{Response: resp} 537 return 538} 539 540// listByCreateSubscriptionPermissionNextResults retrieves the next set of results, if any. 541func (client InvoiceSectionsClient) listByCreateSubscriptionPermissionNextResults(ctx context.Context, lastResults InvoiceSectionListResult) (result InvoiceSectionListResult, err error) { 542 req, err := lastResults.invoiceSectionListResultPreparer(ctx) 543 if err != nil { 544 return result, autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByCreateSubscriptionPermissionNextResults", nil, "Failure preparing next results request") 545 } 546 if req == nil { 547 return 548 } 549 resp, err := client.ListByCreateSubscriptionPermissionSender(req) 550 if err != nil { 551 result.Response = autorest.Response{Response: resp} 552 return result, autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByCreateSubscriptionPermissionNextResults", resp, "Failure sending next results request") 553 } 554 result, err = client.ListByCreateSubscriptionPermissionResponder(resp) 555 if err != nil { 556 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByCreateSubscriptionPermissionNextResults", resp, "Failure responding to next results request") 557 } 558 return 559} 560 561// ListByCreateSubscriptionPermissionComplete enumerates all values, automatically crossing page boundaries as required. 562func (client InvoiceSectionsClient) ListByCreateSubscriptionPermissionComplete(ctx context.Context, billingAccountName string, expand string) (result InvoiceSectionListResultIterator, err error) { 563 if tracing.IsEnabled() { 564 ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.ListByCreateSubscriptionPermission") 565 defer func() { 566 sc := -1 567 if result.Response().Response.Response != nil { 568 sc = result.page.Response().Response.Response.StatusCode 569 } 570 tracing.EndSpan(ctx, sc, err) 571 }() 572 } 573 result.page, err = client.ListByCreateSubscriptionPermission(ctx, billingAccountName, expand) 574 return 575} 576 577// Update the operation to update a InvoiceSection. 578// Parameters: 579// billingAccountName - billing Account Id. 580// invoiceSectionName - invoiceSection Id. 581// parameters - parameters supplied to the Create InvoiceSection operation. 582func (client InvoiceSectionsClient) Update(ctx context.Context, billingAccountName string, invoiceSectionName string, parameters InvoiceSection) (result InvoiceSectionsUpdateFuture, err error) { 583 if tracing.IsEnabled() { 584 ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.Update") 585 defer func() { 586 sc := -1 587 if result.Response() != nil { 588 sc = result.Response().StatusCode 589 } 590 tracing.EndSpan(ctx, sc, err) 591 }() 592 } 593 req, err := client.UpdatePreparer(ctx, billingAccountName, invoiceSectionName, parameters) 594 if err != nil { 595 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Update", nil, "Failure preparing request") 596 return 597 } 598 599 result, err = client.UpdateSender(req) 600 if err != nil { 601 err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Update", result.Response(), "Failure sending request") 602 return 603 } 604 605 return 606} 607 608// UpdatePreparer prepares the Update request. 609func (client InvoiceSectionsClient) UpdatePreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, parameters InvoiceSection) (*http.Request, error) { 610 pathParameters := map[string]interface{}{ 611 "billingAccountName": autorest.Encode("path", billingAccountName), 612 "invoiceSectionName": autorest.Encode("path", invoiceSectionName), 613 } 614 615 const APIVersion = "2018-11-01-preview" 616 queryParameters := map[string]interface{}{ 617 "api-version": APIVersion, 618 } 619 620 preparer := autorest.CreatePreparer( 621 autorest.AsContentType("application/json; charset=utf-8"), 622 autorest.AsPut(), 623 autorest.WithBaseURL(client.BaseURI), 624 autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}", pathParameters), 625 autorest.WithJSON(parameters), 626 autorest.WithQueryParameters(queryParameters)) 627 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 628} 629 630// UpdateSender sends the Update request. The method will close the 631// http.Response Body if it receives an error. 632func (client InvoiceSectionsClient) UpdateSender(req *http.Request) (future InvoiceSectionsUpdateFuture, err error) { 633 sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 634 var resp *http.Response 635 resp, err = autorest.SendWithSender(client, req, sd...) 636 if err != nil { 637 return 638 } 639 future.Future, err = azure.NewFutureFromResponse(resp) 640 return 641} 642 643// UpdateResponder handles the response to the Update request. The method always 644// closes the http.Response Body. 645func (client InvoiceSectionsClient) UpdateResponder(resp *http.Response) (result InvoiceSection, err error) { 646 err = autorest.Respond( 647 resp, 648 client.ByInspecting(), 649 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 650 autorest.ByUnmarshallingJSON(&result), 651 autorest.ByClosing()) 652 result.Response = autorest.Response{Response: resp} 653 return 654} 655