1package consumption 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/autorest/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// MarketplacesClient is the consumption management client provides access to consumption resources for Azure 19// Enterprise Subscriptions. 20type MarketplacesClient struct { 21 BaseClient 22} 23 24// NewMarketplacesClient creates an instance of the MarketplacesClient client. 25func NewMarketplacesClient(subscriptionID string) MarketplacesClient { 26 return NewMarketplacesClientWithBaseURI(DefaultBaseURI, subscriptionID) 27} 28 29// NewMarketplacesClientWithBaseURI creates an instance of the MarketplacesClient client using a custom endpoint. Use 30// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 31func NewMarketplacesClientWithBaseURI(baseURI string, subscriptionID string) MarketplacesClient { 32 return MarketplacesClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// List lists the marketplaces for a scope by subscriptionId and current billing period. Marketplaces are available via 36// this API only for May 1, 2014 or later. 37// Parameters: 38// filter - may be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc 39// time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 40// 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. 41// top - may be used to limit the number of results to the most recent N marketplaces. 42// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response 43// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that 44// specifies a starting point to use for subsequent calls. 45func (client MarketplacesClient) List(ctx context.Context, filter string, top *int32, skiptoken string) (result MarketplacesListResultPage, err error) { 46 if tracing.IsEnabled() { 47 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.List") 48 defer func() { 49 sc := -1 50 if result.mlr.Response.Response != nil { 51 sc = result.mlr.Response.Response.StatusCode 52 } 53 tracing.EndSpan(ctx, sc, err) 54 }() 55 } 56 if err := validation.Validate([]validation.Validation{ 57 {TargetValue: top, 58 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 59 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 60 {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 61 }}}}}); err != nil { 62 return result, validation.NewError("consumption.MarketplacesClient", "List", err.Error()) 63 } 64 65 result.fn = client.listNextResults 66 req, err := client.ListPreparer(ctx, filter, top, skiptoken) 67 if err != nil { 68 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "List", nil, "Failure preparing request") 69 return 70 } 71 72 resp, err := client.ListSender(req) 73 if err != nil { 74 result.mlr.Response = autorest.Response{Response: resp} 75 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "List", resp, "Failure sending request") 76 return 77 } 78 79 result.mlr, err = client.ListResponder(resp) 80 if err != nil { 81 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "List", resp, "Failure responding to request") 82 return 83 } 84 if result.mlr.hasNextLink() && result.mlr.IsEmpty() { 85 err = result.NextWithContext(ctx) 86 return 87 } 88 89 return 90} 91 92// ListPreparer prepares the List request. 93func (client MarketplacesClient) ListPreparer(ctx context.Context, filter string, top *int32, skiptoken string) (*http.Request, error) { 94 pathParameters := map[string]interface{}{ 95 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 96 } 97 98 const APIVersion = "2018-10-01" 99 queryParameters := map[string]interface{}{ 100 "api-version": APIVersion, 101 } 102 if len(filter) > 0 { 103 queryParameters["$filter"] = autorest.Encode("query", filter) 104 } 105 if top != nil { 106 queryParameters["$top"] = autorest.Encode("query", *top) 107 } 108 if len(skiptoken) > 0 { 109 queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) 110 } 111 112 preparer := autorest.CreatePreparer( 113 autorest.AsGet(), 114 autorest.WithBaseURL(client.BaseURI), 115 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/marketplaces", pathParameters), 116 autorest.WithQueryParameters(queryParameters)) 117 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 118} 119 120// ListSender sends the List request. The method will close the 121// http.Response Body if it receives an error. 122func (client MarketplacesClient) ListSender(req *http.Request) (*http.Response, error) { 123 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 124} 125 126// ListResponder handles the response to the List request. The method always 127// closes the http.Response Body. 128func (client MarketplacesClient) ListResponder(resp *http.Response) (result MarketplacesListResult, err error) { 129 err = autorest.Respond( 130 resp, 131 azure.WithErrorUnlessStatusCode(http.StatusOK), 132 autorest.ByUnmarshallingJSON(&result), 133 autorest.ByClosing()) 134 result.Response = autorest.Response{Response: resp} 135 return 136} 137 138// listNextResults retrieves the next set of results, if any. 139func (client MarketplacesClient) listNextResults(ctx context.Context, lastResults MarketplacesListResult) (result MarketplacesListResult, err error) { 140 req, err := lastResults.marketplacesListResultPreparer(ctx) 141 if err != nil { 142 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listNextResults", nil, "Failure preparing next results request") 143 } 144 if req == nil { 145 return 146 } 147 resp, err := client.ListSender(req) 148 if err != nil { 149 result.Response = autorest.Response{Response: resp} 150 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listNextResults", resp, "Failure sending next results request") 151 } 152 result, err = client.ListResponder(resp) 153 if err != nil { 154 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listNextResults", resp, "Failure responding to next results request") 155 } 156 return 157} 158 159// ListComplete enumerates all values, automatically crossing page boundaries as required. 160func (client MarketplacesClient) ListComplete(ctx context.Context, filter string, top *int32, skiptoken string) (result MarketplacesListResultIterator, err error) { 161 if tracing.IsEnabled() { 162 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.List") 163 defer func() { 164 sc := -1 165 if result.Response().Response.Response != nil { 166 sc = result.page.Response().Response.Response.StatusCode 167 } 168 tracing.EndSpan(ctx, sc, err) 169 }() 170 } 171 result.page, err = client.List(ctx, filter, top, skiptoken) 172 return 173} 174 175// ListByBillingAccount lists the marketplaces for a scope by billingAccountId and current billing period. Marketplaces 176// are available via this API only for May 1, 2014 or later. 177// Parameters: 178// billingAccountID - billingAccount ID 179// filter - may be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc 180// time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 181// 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. 182// top - may be used to limit the number of results to the most recent N marketplaces. 183// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response 184// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that 185// specifies a starting point to use for subsequent calls. 186func (client MarketplacesClient) ListByBillingAccount(ctx context.Context, billingAccountID string, filter string, top *int32, skiptoken string) (result MarketplacesListResultPage, err error) { 187 if tracing.IsEnabled() { 188 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListByBillingAccount") 189 defer func() { 190 sc := -1 191 if result.mlr.Response.Response != nil { 192 sc = result.mlr.Response.Response.StatusCode 193 } 194 tracing.EndSpan(ctx, sc, err) 195 }() 196 } 197 if err := validation.Validate([]validation.Validation{ 198 {TargetValue: top, 199 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 200 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 201 {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 202 }}}}}); err != nil { 203 return result, validation.NewError("consumption.MarketplacesClient", "ListByBillingAccount", err.Error()) 204 } 205 206 result.fn = client.listByBillingAccountNextResults 207 req, err := client.ListByBillingAccountPreparer(ctx, billingAccountID, filter, top, skiptoken) 208 if err != nil { 209 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByBillingAccount", nil, "Failure preparing request") 210 return 211 } 212 213 resp, err := client.ListByBillingAccountSender(req) 214 if err != nil { 215 result.mlr.Response = autorest.Response{Response: resp} 216 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByBillingAccount", resp, "Failure sending request") 217 return 218 } 219 220 result.mlr, err = client.ListByBillingAccountResponder(resp) 221 if err != nil { 222 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByBillingAccount", resp, "Failure responding to request") 223 return 224 } 225 if result.mlr.hasNextLink() && result.mlr.IsEmpty() { 226 err = result.NextWithContext(ctx) 227 return 228 } 229 230 return 231} 232 233// ListByBillingAccountPreparer prepares the ListByBillingAccount request. 234func (client MarketplacesClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountID string, filter string, top *int32, skiptoken string) (*http.Request, error) { 235 pathParameters := map[string]interface{}{ 236 "billingAccountId": autorest.Encode("path", billingAccountID), 237 } 238 239 const APIVersion = "2018-10-01" 240 queryParameters := map[string]interface{}{ 241 "api-version": APIVersion, 242 } 243 if len(filter) > 0 { 244 queryParameters["$filter"] = autorest.Encode("query", filter) 245 } 246 if top != nil { 247 queryParameters["$top"] = autorest.Encode("query", *top) 248 } 249 if len(skiptoken) > 0 { 250 queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) 251 } 252 253 preparer := autorest.CreatePreparer( 254 autorest.AsGet(), 255 autorest.WithBaseURL(client.BaseURI), 256 autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/marketplaces", pathParameters), 257 autorest.WithQueryParameters(queryParameters)) 258 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 259} 260 261// ListByBillingAccountSender sends the ListByBillingAccount request. The method will close the 262// http.Response Body if it receives an error. 263func (client MarketplacesClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) { 264 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 265} 266 267// ListByBillingAccountResponder handles the response to the ListByBillingAccount request. The method always 268// closes the http.Response Body. 269func (client MarketplacesClient) ListByBillingAccountResponder(resp *http.Response) (result MarketplacesListResult, err error) { 270 err = autorest.Respond( 271 resp, 272 azure.WithErrorUnlessStatusCode(http.StatusOK), 273 autorest.ByUnmarshallingJSON(&result), 274 autorest.ByClosing()) 275 result.Response = autorest.Response{Response: resp} 276 return 277} 278 279// listByBillingAccountNextResults retrieves the next set of results, if any. 280func (client MarketplacesClient) listByBillingAccountNextResults(ctx context.Context, lastResults MarketplacesListResult) (result MarketplacesListResult, err error) { 281 req, err := lastResults.marketplacesListResultPreparer(ctx) 282 if err != nil { 283 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByBillingAccountNextResults", nil, "Failure preparing next results request") 284 } 285 if req == nil { 286 return 287 } 288 resp, err := client.ListByBillingAccountSender(req) 289 if err != nil { 290 result.Response = autorest.Response{Response: resp} 291 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByBillingAccountNextResults", resp, "Failure sending next results request") 292 } 293 result, err = client.ListByBillingAccountResponder(resp) 294 if err != nil { 295 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByBillingAccountNextResults", resp, "Failure responding to next results request") 296 } 297 return 298} 299 300// ListByBillingAccountComplete enumerates all values, automatically crossing page boundaries as required. 301func (client MarketplacesClient) ListByBillingAccountComplete(ctx context.Context, billingAccountID string, filter string, top *int32, skiptoken string) (result MarketplacesListResultIterator, err error) { 302 if tracing.IsEnabled() { 303 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListByBillingAccount") 304 defer func() { 305 sc := -1 306 if result.Response().Response.Response != nil { 307 sc = result.page.Response().Response.Response.StatusCode 308 } 309 tracing.EndSpan(ctx, sc, err) 310 }() 311 } 312 result.page, err = client.ListByBillingAccount(ctx, billingAccountID, filter, top, skiptoken) 313 return 314} 315 316// ListByBillingPeriod lists the marketplaces for a scope by billing period and subscriptionId. Marketplaces are 317// available via this API only for May 1, 2014 or later. 318// Parameters: 319// billingPeriodName - billing Period Name. 320// filter - may be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc 321// time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 322// 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. 323// top - may be used to limit the number of results to the most recent N marketplaces. 324// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response 325// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that 326// specifies a starting point to use for subsequent calls. 327func (client MarketplacesClient) ListByBillingPeriod(ctx context.Context, billingPeriodName string, filter string, top *int32, skiptoken string) (result MarketplacesListResultPage, err error) { 328 if tracing.IsEnabled() { 329 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListByBillingPeriod") 330 defer func() { 331 sc := -1 332 if result.mlr.Response.Response != nil { 333 sc = result.mlr.Response.Response.StatusCode 334 } 335 tracing.EndSpan(ctx, sc, err) 336 }() 337 } 338 if err := validation.Validate([]validation.Validation{ 339 {TargetValue: top, 340 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 341 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 342 {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 343 }}}}}); err != nil { 344 return result, validation.NewError("consumption.MarketplacesClient", "ListByBillingPeriod", err.Error()) 345 } 346 347 result.fn = client.listByBillingPeriodNextResults 348 req, err := client.ListByBillingPeriodPreparer(ctx, billingPeriodName, filter, top, skiptoken) 349 if err != nil { 350 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByBillingPeriod", nil, "Failure preparing request") 351 return 352 } 353 354 resp, err := client.ListByBillingPeriodSender(req) 355 if err != nil { 356 result.mlr.Response = autorest.Response{Response: resp} 357 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByBillingPeriod", resp, "Failure sending request") 358 return 359 } 360 361 result.mlr, err = client.ListByBillingPeriodResponder(resp) 362 if err != nil { 363 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByBillingPeriod", resp, "Failure responding to request") 364 return 365 } 366 if result.mlr.hasNextLink() && result.mlr.IsEmpty() { 367 err = result.NextWithContext(ctx) 368 return 369 } 370 371 return 372} 373 374// ListByBillingPeriodPreparer prepares the ListByBillingPeriod request. 375func (client MarketplacesClient) ListByBillingPeriodPreparer(ctx context.Context, billingPeriodName string, filter string, top *int32, skiptoken string) (*http.Request, error) { 376 pathParameters := map[string]interface{}{ 377 "billingPeriodName": autorest.Encode("path", billingPeriodName), 378 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 379 } 380 381 const APIVersion = "2018-10-01" 382 queryParameters := map[string]interface{}{ 383 "api-version": APIVersion, 384 } 385 if len(filter) > 0 { 386 queryParameters["$filter"] = autorest.Encode("query", filter) 387 } 388 if top != nil { 389 queryParameters["$top"] = autorest.Encode("query", *top) 390 } 391 if len(skiptoken) > 0 { 392 queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) 393 } 394 395 preparer := autorest.CreatePreparer( 396 autorest.AsGet(), 397 autorest.WithBaseURL(client.BaseURI), 398 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces", pathParameters), 399 autorest.WithQueryParameters(queryParameters)) 400 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 401} 402 403// ListByBillingPeriodSender sends the ListByBillingPeriod request. The method will close the 404// http.Response Body if it receives an error. 405func (client MarketplacesClient) ListByBillingPeriodSender(req *http.Request) (*http.Response, error) { 406 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 407} 408 409// ListByBillingPeriodResponder handles the response to the ListByBillingPeriod request. The method always 410// closes the http.Response Body. 411func (client MarketplacesClient) ListByBillingPeriodResponder(resp *http.Response) (result MarketplacesListResult, err error) { 412 err = autorest.Respond( 413 resp, 414 azure.WithErrorUnlessStatusCode(http.StatusOK), 415 autorest.ByUnmarshallingJSON(&result), 416 autorest.ByClosing()) 417 result.Response = autorest.Response{Response: resp} 418 return 419} 420 421// listByBillingPeriodNextResults retrieves the next set of results, if any. 422func (client MarketplacesClient) listByBillingPeriodNextResults(ctx context.Context, lastResults MarketplacesListResult) (result MarketplacesListResult, err error) { 423 req, err := lastResults.marketplacesListResultPreparer(ctx) 424 if err != nil { 425 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByBillingPeriodNextResults", nil, "Failure preparing next results request") 426 } 427 if req == nil { 428 return 429 } 430 resp, err := client.ListByBillingPeriodSender(req) 431 if err != nil { 432 result.Response = autorest.Response{Response: resp} 433 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByBillingPeriodNextResults", resp, "Failure sending next results request") 434 } 435 result, err = client.ListByBillingPeriodResponder(resp) 436 if err != nil { 437 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByBillingPeriodNextResults", resp, "Failure responding to next results request") 438 } 439 return 440} 441 442// ListByBillingPeriodComplete enumerates all values, automatically crossing page boundaries as required. 443func (client MarketplacesClient) ListByBillingPeriodComplete(ctx context.Context, billingPeriodName string, filter string, top *int32, skiptoken string) (result MarketplacesListResultIterator, err error) { 444 if tracing.IsEnabled() { 445 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListByBillingPeriod") 446 defer func() { 447 sc := -1 448 if result.Response().Response.Response != nil { 449 sc = result.page.Response().Response.Response.StatusCode 450 } 451 tracing.EndSpan(ctx, sc, err) 452 }() 453 } 454 result.page, err = client.ListByBillingPeriod(ctx, billingPeriodName, filter, top, skiptoken) 455 return 456} 457 458// ListByDepartment lists the marketplaces for a scope by departmentId and current billing period. Marketplaces are 459// available via this API only for May 1, 2014 or later. 460// Parameters: 461// departmentID - department ID 462// filter - may be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc 463// time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 464// 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. 465// top - may be used to limit the number of results to the most recent N marketplaces. 466// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response 467// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that 468// specifies a starting point to use for subsequent calls. 469func (client MarketplacesClient) ListByDepartment(ctx context.Context, departmentID string, filter string, top *int32, skiptoken string) (result MarketplacesListResultPage, err error) { 470 if tracing.IsEnabled() { 471 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListByDepartment") 472 defer func() { 473 sc := -1 474 if result.mlr.Response.Response != nil { 475 sc = result.mlr.Response.Response.StatusCode 476 } 477 tracing.EndSpan(ctx, sc, err) 478 }() 479 } 480 if err := validation.Validate([]validation.Validation{ 481 {TargetValue: top, 482 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 483 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 484 {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 485 }}}}}); err != nil { 486 return result, validation.NewError("consumption.MarketplacesClient", "ListByDepartment", err.Error()) 487 } 488 489 result.fn = client.listByDepartmentNextResults 490 req, err := client.ListByDepartmentPreparer(ctx, departmentID, filter, top, skiptoken) 491 if err != nil { 492 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByDepartment", nil, "Failure preparing request") 493 return 494 } 495 496 resp, err := client.ListByDepartmentSender(req) 497 if err != nil { 498 result.mlr.Response = autorest.Response{Response: resp} 499 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByDepartment", resp, "Failure sending request") 500 return 501 } 502 503 result.mlr, err = client.ListByDepartmentResponder(resp) 504 if err != nil { 505 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByDepartment", resp, "Failure responding to request") 506 return 507 } 508 if result.mlr.hasNextLink() && result.mlr.IsEmpty() { 509 err = result.NextWithContext(ctx) 510 return 511 } 512 513 return 514} 515 516// ListByDepartmentPreparer prepares the ListByDepartment request. 517func (client MarketplacesClient) ListByDepartmentPreparer(ctx context.Context, departmentID string, filter string, top *int32, skiptoken string) (*http.Request, error) { 518 pathParameters := map[string]interface{}{ 519 "departmentId": autorest.Encode("path", departmentID), 520 } 521 522 const APIVersion = "2018-10-01" 523 queryParameters := map[string]interface{}{ 524 "api-version": APIVersion, 525 } 526 if len(filter) > 0 { 527 queryParameters["$filter"] = autorest.Encode("query", filter) 528 } 529 if top != nil { 530 queryParameters["$top"] = autorest.Encode("query", *top) 531 } 532 if len(skiptoken) > 0 { 533 queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) 534 } 535 536 preparer := autorest.CreatePreparer( 537 autorest.AsGet(), 538 autorest.WithBaseURL(client.BaseURI), 539 autorest.WithPathParameters("/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Consumption/marketplaces", pathParameters), 540 autorest.WithQueryParameters(queryParameters)) 541 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 542} 543 544// ListByDepartmentSender sends the ListByDepartment request. The method will close the 545// http.Response Body if it receives an error. 546func (client MarketplacesClient) ListByDepartmentSender(req *http.Request) (*http.Response, error) { 547 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 548} 549 550// ListByDepartmentResponder handles the response to the ListByDepartment request. The method always 551// closes the http.Response Body. 552func (client MarketplacesClient) ListByDepartmentResponder(resp *http.Response) (result MarketplacesListResult, err error) { 553 err = autorest.Respond( 554 resp, 555 azure.WithErrorUnlessStatusCode(http.StatusOK), 556 autorest.ByUnmarshallingJSON(&result), 557 autorest.ByClosing()) 558 result.Response = autorest.Response{Response: resp} 559 return 560} 561 562// listByDepartmentNextResults retrieves the next set of results, if any. 563func (client MarketplacesClient) listByDepartmentNextResults(ctx context.Context, lastResults MarketplacesListResult) (result MarketplacesListResult, err error) { 564 req, err := lastResults.marketplacesListResultPreparer(ctx) 565 if err != nil { 566 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByDepartmentNextResults", nil, "Failure preparing next results request") 567 } 568 if req == nil { 569 return 570 } 571 resp, err := client.ListByDepartmentSender(req) 572 if err != nil { 573 result.Response = autorest.Response{Response: resp} 574 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByDepartmentNextResults", resp, "Failure sending next results request") 575 } 576 result, err = client.ListByDepartmentResponder(resp) 577 if err != nil { 578 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByDepartmentNextResults", resp, "Failure responding to next results request") 579 } 580 return 581} 582 583// ListByDepartmentComplete enumerates all values, automatically crossing page boundaries as required. 584func (client MarketplacesClient) ListByDepartmentComplete(ctx context.Context, departmentID string, filter string, top *int32, skiptoken string) (result MarketplacesListResultIterator, err error) { 585 if tracing.IsEnabled() { 586 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListByDepartment") 587 defer func() { 588 sc := -1 589 if result.Response().Response.Response != nil { 590 sc = result.page.Response().Response.Response.StatusCode 591 } 592 tracing.EndSpan(ctx, sc, err) 593 }() 594 } 595 result.page, err = client.ListByDepartment(ctx, departmentID, filter, top, skiptoken) 596 return 597} 598 599// ListByEnrollmentAccount lists the marketplaces for a scope by enrollmentAccountId and current billing period. 600// Marketplaces are available via this API only for May 1, 2014 or later. 601// Parameters: 602// enrollmentAccountID - enrollmentAccount ID 603// filter - may be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc 604// time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 605// 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. 606// top - may be used to limit the number of results to the most recent N marketplaces. 607// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response 608// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that 609// specifies a starting point to use for subsequent calls. 610func (client MarketplacesClient) ListByEnrollmentAccount(ctx context.Context, enrollmentAccountID string, filter string, top *int32, skiptoken string) (result MarketplacesListResultPage, err error) { 611 if tracing.IsEnabled() { 612 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListByEnrollmentAccount") 613 defer func() { 614 sc := -1 615 if result.mlr.Response.Response != nil { 616 sc = result.mlr.Response.Response.StatusCode 617 } 618 tracing.EndSpan(ctx, sc, err) 619 }() 620 } 621 if err := validation.Validate([]validation.Validation{ 622 {TargetValue: top, 623 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 624 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 625 {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 626 }}}}}); err != nil { 627 return result, validation.NewError("consumption.MarketplacesClient", "ListByEnrollmentAccount", err.Error()) 628 } 629 630 result.fn = client.listByEnrollmentAccountNextResults 631 req, err := client.ListByEnrollmentAccountPreparer(ctx, enrollmentAccountID, filter, top, skiptoken) 632 if err != nil { 633 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByEnrollmentAccount", nil, "Failure preparing request") 634 return 635 } 636 637 resp, err := client.ListByEnrollmentAccountSender(req) 638 if err != nil { 639 result.mlr.Response = autorest.Response{Response: resp} 640 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByEnrollmentAccount", resp, "Failure sending request") 641 return 642 } 643 644 result.mlr, err = client.ListByEnrollmentAccountResponder(resp) 645 if err != nil { 646 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByEnrollmentAccount", resp, "Failure responding to request") 647 return 648 } 649 if result.mlr.hasNextLink() && result.mlr.IsEmpty() { 650 err = result.NextWithContext(ctx) 651 return 652 } 653 654 return 655} 656 657// ListByEnrollmentAccountPreparer prepares the ListByEnrollmentAccount request. 658func (client MarketplacesClient) ListByEnrollmentAccountPreparer(ctx context.Context, enrollmentAccountID string, filter string, top *int32, skiptoken string) (*http.Request, error) { 659 pathParameters := map[string]interface{}{ 660 "enrollmentAccountId": autorest.Encode("path", enrollmentAccountID), 661 } 662 663 const APIVersion = "2018-10-01" 664 queryParameters := map[string]interface{}{ 665 "api-version": APIVersion, 666 } 667 if len(filter) > 0 { 668 queryParameters["$filter"] = autorest.Encode("query", filter) 669 } 670 if top != nil { 671 queryParameters["$top"] = autorest.Encode("query", *top) 672 } 673 if len(skiptoken) > 0 { 674 queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) 675 } 676 677 preparer := autorest.CreatePreparer( 678 autorest.AsGet(), 679 autorest.WithBaseURL(client.BaseURI), 680 autorest.WithPathParameters("/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Consumption/marketplaces", pathParameters), 681 autorest.WithQueryParameters(queryParameters)) 682 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 683} 684 685// ListByEnrollmentAccountSender sends the ListByEnrollmentAccount request. The method will close the 686// http.Response Body if it receives an error. 687func (client MarketplacesClient) ListByEnrollmentAccountSender(req *http.Request) (*http.Response, error) { 688 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 689} 690 691// ListByEnrollmentAccountResponder handles the response to the ListByEnrollmentAccount request. The method always 692// closes the http.Response Body. 693func (client MarketplacesClient) ListByEnrollmentAccountResponder(resp *http.Response) (result MarketplacesListResult, err error) { 694 err = autorest.Respond( 695 resp, 696 azure.WithErrorUnlessStatusCode(http.StatusOK), 697 autorest.ByUnmarshallingJSON(&result), 698 autorest.ByClosing()) 699 result.Response = autorest.Response{Response: resp} 700 return 701} 702 703// listByEnrollmentAccountNextResults retrieves the next set of results, if any. 704func (client MarketplacesClient) listByEnrollmentAccountNextResults(ctx context.Context, lastResults MarketplacesListResult) (result MarketplacesListResult, err error) { 705 req, err := lastResults.marketplacesListResultPreparer(ctx) 706 if err != nil { 707 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByEnrollmentAccountNextResults", nil, "Failure preparing next results request") 708 } 709 if req == nil { 710 return 711 } 712 resp, err := client.ListByEnrollmentAccountSender(req) 713 if err != nil { 714 result.Response = autorest.Response{Response: resp} 715 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByEnrollmentAccountNextResults", resp, "Failure sending next results request") 716 } 717 result, err = client.ListByEnrollmentAccountResponder(resp) 718 if err != nil { 719 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByEnrollmentAccountNextResults", resp, "Failure responding to next results request") 720 } 721 return 722} 723 724// ListByEnrollmentAccountComplete enumerates all values, automatically crossing page boundaries as required. 725func (client MarketplacesClient) ListByEnrollmentAccountComplete(ctx context.Context, enrollmentAccountID string, filter string, top *int32, skiptoken string) (result MarketplacesListResultIterator, err error) { 726 if tracing.IsEnabled() { 727 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListByEnrollmentAccount") 728 defer func() { 729 sc := -1 730 if result.Response().Response.Response != nil { 731 sc = result.page.Response().Response.Response.StatusCode 732 } 733 tracing.EndSpan(ctx, sc, err) 734 }() 735 } 736 result.page, err = client.ListByEnrollmentAccount(ctx, enrollmentAccountID, filter, top, skiptoken) 737 return 738} 739 740// ListByManagementGroup lists the marketplace records for all subscriptions belonging to a management group scope by 741// current billing period. Marketplaces are available via this API only for May 1, 2014 or later. 742// Parameters: 743// managementGroupID - azure Management Group ID. 744// filter - may be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc 745// time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 746// 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. 747// top - may be used to limit the number of results to the most recent N marketplaces. 748// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response 749// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that 750// specifies a starting point to use for subsequent calls. 751func (client MarketplacesClient) ListByManagementGroup(ctx context.Context, managementGroupID string, filter string, top *int32, skiptoken string) (result MarketplacesListResultPage, err error) { 752 if tracing.IsEnabled() { 753 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListByManagementGroup") 754 defer func() { 755 sc := -1 756 if result.mlr.Response.Response != nil { 757 sc = result.mlr.Response.Response.StatusCode 758 } 759 tracing.EndSpan(ctx, sc, err) 760 }() 761 } 762 if err := validation.Validate([]validation.Validation{ 763 {TargetValue: top, 764 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 765 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 766 {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 767 }}}}}); err != nil { 768 return result, validation.NewError("consumption.MarketplacesClient", "ListByManagementGroup", err.Error()) 769 } 770 771 result.fn = client.listByManagementGroupNextResults 772 req, err := client.ListByManagementGroupPreparer(ctx, managementGroupID, filter, top, skiptoken) 773 if err != nil { 774 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByManagementGroup", nil, "Failure preparing request") 775 return 776 } 777 778 resp, err := client.ListByManagementGroupSender(req) 779 if err != nil { 780 result.mlr.Response = autorest.Response{Response: resp} 781 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByManagementGroup", resp, "Failure sending request") 782 return 783 } 784 785 result.mlr, err = client.ListByManagementGroupResponder(resp) 786 if err != nil { 787 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListByManagementGroup", resp, "Failure responding to request") 788 return 789 } 790 if result.mlr.hasNextLink() && result.mlr.IsEmpty() { 791 err = result.NextWithContext(ctx) 792 return 793 } 794 795 return 796} 797 798// ListByManagementGroupPreparer prepares the ListByManagementGroup request. 799func (client MarketplacesClient) ListByManagementGroupPreparer(ctx context.Context, managementGroupID string, filter string, top *int32, skiptoken string) (*http.Request, error) { 800 pathParameters := map[string]interface{}{ 801 "managementGroupId": autorest.Encode("path", managementGroupID), 802 } 803 804 const APIVersion = "2018-10-01" 805 queryParameters := map[string]interface{}{ 806 "api-version": APIVersion, 807 } 808 if len(filter) > 0 { 809 queryParameters["$filter"] = autorest.Encode("query", filter) 810 } 811 if top != nil { 812 queryParameters["$top"] = autorest.Encode("query", *top) 813 } 814 if len(skiptoken) > 0 { 815 queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) 816 } 817 818 preparer := autorest.CreatePreparer( 819 autorest.AsGet(), 820 autorest.WithBaseURL(client.BaseURI), 821 autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Consumption/marketplaces", pathParameters), 822 autorest.WithQueryParameters(queryParameters)) 823 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 824} 825 826// ListByManagementGroupSender sends the ListByManagementGroup request. The method will close the 827// http.Response Body if it receives an error. 828func (client MarketplacesClient) ListByManagementGroupSender(req *http.Request) (*http.Response, error) { 829 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 830} 831 832// ListByManagementGroupResponder handles the response to the ListByManagementGroup request. The method always 833// closes the http.Response Body. 834func (client MarketplacesClient) ListByManagementGroupResponder(resp *http.Response) (result MarketplacesListResult, err error) { 835 err = autorest.Respond( 836 resp, 837 azure.WithErrorUnlessStatusCode(http.StatusOK), 838 autorest.ByUnmarshallingJSON(&result), 839 autorest.ByClosing()) 840 result.Response = autorest.Response{Response: resp} 841 return 842} 843 844// listByManagementGroupNextResults retrieves the next set of results, if any. 845func (client MarketplacesClient) listByManagementGroupNextResults(ctx context.Context, lastResults MarketplacesListResult) (result MarketplacesListResult, err error) { 846 req, err := lastResults.marketplacesListResultPreparer(ctx) 847 if err != nil { 848 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByManagementGroupNextResults", nil, "Failure preparing next results request") 849 } 850 if req == nil { 851 return 852 } 853 resp, err := client.ListByManagementGroupSender(req) 854 if err != nil { 855 result.Response = autorest.Response{Response: resp} 856 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByManagementGroupNextResults", resp, "Failure sending next results request") 857 } 858 result, err = client.ListByManagementGroupResponder(resp) 859 if err != nil { 860 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listByManagementGroupNextResults", resp, "Failure responding to next results request") 861 } 862 return 863} 864 865// ListByManagementGroupComplete enumerates all values, automatically crossing page boundaries as required. 866func (client MarketplacesClient) ListByManagementGroupComplete(ctx context.Context, managementGroupID string, filter string, top *int32, skiptoken string) (result MarketplacesListResultIterator, err error) { 867 if tracing.IsEnabled() { 868 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListByManagementGroup") 869 defer func() { 870 sc := -1 871 if result.Response().Response.Response != nil { 872 sc = result.page.Response().Response.Response.StatusCode 873 } 874 tracing.EndSpan(ctx, sc, err) 875 }() 876 } 877 result.page, err = client.ListByManagementGroup(ctx, managementGroupID, filter, top, skiptoken) 878 return 879} 880 881// ListForBillingPeriodByBillingAccount lists the marketplaces for a scope by billing period and billingAccountId. 882// Marketplaces are available via this API only for May 1, 2014 or later. 883// Parameters: 884// billingAccountID - billingAccount ID 885// billingPeriodName - billing Period Name. 886// filter - may be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc 887// time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 888// 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. 889// top - may be used to limit the number of results to the most recent N marketplaces. 890// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response 891// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that 892// specifies a starting point to use for subsequent calls. 893func (client MarketplacesClient) ListForBillingPeriodByBillingAccount(ctx context.Context, billingAccountID string, billingPeriodName string, filter string, top *int32, skiptoken string) (result MarketplacesListResultPage, err error) { 894 if tracing.IsEnabled() { 895 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListForBillingPeriodByBillingAccount") 896 defer func() { 897 sc := -1 898 if result.mlr.Response.Response != nil { 899 sc = result.mlr.Response.Response.StatusCode 900 } 901 tracing.EndSpan(ctx, sc, err) 902 }() 903 } 904 if err := validation.Validate([]validation.Validation{ 905 {TargetValue: top, 906 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 907 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 908 {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 909 }}}}}); err != nil { 910 return result, validation.NewError("consumption.MarketplacesClient", "ListForBillingPeriodByBillingAccount", err.Error()) 911 } 912 913 result.fn = client.listForBillingPeriodByBillingAccountNextResults 914 req, err := client.ListForBillingPeriodByBillingAccountPreparer(ctx, billingAccountID, billingPeriodName, filter, top, skiptoken) 915 if err != nil { 916 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListForBillingPeriodByBillingAccount", nil, "Failure preparing request") 917 return 918 } 919 920 resp, err := client.ListForBillingPeriodByBillingAccountSender(req) 921 if err != nil { 922 result.mlr.Response = autorest.Response{Response: resp} 923 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListForBillingPeriodByBillingAccount", resp, "Failure sending request") 924 return 925 } 926 927 result.mlr, err = client.ListForBillingPeriodByBillingAccountResponder(resp) 928 if err != nil { 929 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListForBillingPeriodByBillingAccount", resp, "Failure responding to request") 930 return 931 } 932 if result.mlr.hasNextLink() && result.mlr.IsEmpty() { 933 err = result.NextWithContext(ctx) 934 return 935 } 936 937 return 938} 939 940// ListForBillingPeriodByBillingAccountPreparer prepares the ListForBillingPeriodByBillingAccount request. 941func (client MarketplacesClient) ListForBillingPeriodByBillingAccountPreparer(ctx context.Context, billingAccountID string, billingPeriodName string, filter string, top *int32, skiptoken string) (*http.Request, error) { 942 pathParameters := map[string]interface{}{ 943 "billingAccountId": autorest.Encode("path", billingAccountID), 944 "billingPeriodName": autorest.Encode("path", billingPeriodName), 945 } 946 947 const APIVersion = "2018-10-01" 948 queryParameters := map[string]interface{}{ 949 "api-version": APIVersion, 950 } 951 if len(filter) > 0 { 952 queryParameters["$filter"] = autorest.Encode("query", filter) 953 } 954 if top != nil { 955 queryParameters["$top"] = autorest.Encode("query", *top) 956 } 957 if len(skiptoken) > 0 { 958 queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) 959 } 960 961 preparer := autorest.CreatePreparer( 962 autorest.AsGet(), 963 autorest.WithBaseURL(client.BaseURI), 964 autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces", pathParameters), 965 autorest.WithQueryParameters(queryParameters)) 966 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 967} 968 969// ListForBillingPeriodByBillingAccountSender sends the ListForBillingPeriodByBillingAccount request. The method will close the 970// http.Response Body if it receives an error. 971func (client MarketplacesClient) ListForBillingPeriodByBillingAccountSender(req *http.Request) (*http.Response, error) { 972 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 973} 974 975// ListForBillingPeriodByBillingAccountResponder handles the response to the ListForBillingPeriodByBillingAccount request. The method always 976// closes the http.Response Body. 977func (client MarketplacesClient) ListForBillingPeriodByBillingAccountResponder(resp *http.Response) (result MarketplacesListResult, err error) { 978 err = autorest.Respond( 979 resp, 980 azure.WithErrorUnlessStatusCode(http.StatusOK), 981 autorest.ByUnmarshallingJSON(&result), 982 autorest.ByClosing()) 983 result.Response = autorest.Response{Response: resp} 984 return 985} 986 987// listForBillingPeriodByBillingAccountNextResults retrieves the next set of results, if any. 988func (client MarketplacesClient) listForBillingPeriodByBillingAccountNextResults(ctx context.Context, lastResults MarketplacesListResult) (result MarketplacesListResult, err error) { 989 req, err := lastResults.marketplacesListResultPreparer(ctx) 990 if err != nil { 991 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listForBillingPeriodByBillingAccountNextResults", nil, "Failure preparing next results request") 992 } 993 if req == nil { 994 return 995 } 996 resp, err := client.ListForBillingPeriodByBillingAccountSender(req) 997 if err != nil { 998 result.Response = autorest.Response{Response: resp} 999 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listForBillingPeriodByBillingAccountNextResults", resp, "Failure sending next results request") 1000 } 1001 result, err = client.ListForBillingPeriodByBillingAccountResponder(resp) 1002 if err != nil { 1003 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listForBillingPeriodByBillingAccountNextResults", resp, "Failure responding to next results request") 1004 } 1005 return 1006} 1007 1008// ListForBillingPeriodByBillingAccountComplete enumerates all values, automatically crossing page boundaries as required. 1009func (client MarketplacesClient) ListForBillingPeriodByBillingAccountComplete(ctx context.Context, billingAccountID string, billingPeriodName string, filter string, top *int32, skiptoken string) (result MarketplacesListResultIterator, err error) { 1010 if tracing.IsEnabled() { 1011 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListForBillingPeriodByBillingAccount") 1012 defer func() { 1013 sc := -1 1014 if result.Response().Response.Response != nil { 1015 sc = result.page.Response().Response.Response.StatusCode 1016 } 1017 tracing.EndSpan(ctx, sc, err) 1018 }() 1019 } 1020 result.page, err = client.ListForBillingPeriodByBillingAccount(ctx, billingAccountID, billingPeriodName, filter, top, skiptoken) 1021 return 1022} 1023 1024// ListForBillingPeriodByDepartment lists the marketplaces for a scope by billing period and departmentId. Marketplaces 1025// are available via this API only for May 1, 2014 or later. 1026// Parameters: 1027// departmentID - department ID 1028// billingPeriodName - billing Period Name. 1029// filter - may be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc 1030// time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 1031// 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. 1032// top - may be used to limit the number of results to the most recent N marketplaces. 1033// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response 1034// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that 1035// specifies a starting point to use for subsequent calls. 1036func (client MarketplacesClient) ListForBillingPeriodByDepartment(ctx context.Context, departmentID string, billingPeriodName string, filter string, top *int32, skiptoken string) (result MarketplacesListResultPage, err error) { 1037 if tracing.IsEnabled() { 1038 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListForBillingPeriodByDepartment") 1039 defer func() { 1040 sc := -1 1041 if result.mlr.Response.Response != nil { 1042 sc = result.mlr.Response.Response.StatusCode 1043 } 1044 tracing.EndSpan(ctx, sc, err) 1045 }() 1046 } 1047 if err := validation.Validate([]validation.Validation{ 1048 {TargetValue: top, 1049 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1050 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 1051 {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 1052 }}}}}); err != nil { 1053 return result, validation.NewError("consumption.MarketplacesClient", "ListForBillingPeriodByDepartment", err.Error()) 1054 } 1055 1056 result.fn = client.listForBillingPeriodByDepartmentNextResults 1057 req, err := client.ListForBillingPeriodByDepartmentPreparer(ctx, departmentID, billingPeriodName, filter, top, skiptoken) 1058 if err != nil { 1059 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListForBillingPeriodByDepartment", nil, "Failure preparing request") 1060 return 1061 } 1062 1063 resp, err := client.ListForBillingPeriodByDepartmentSender(req) 1064 if err != nil { 1065 result.mlr.Response = autorest.Response{Response: resp} 1066 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListForBillingPeriodByDepartment", resp, "Failure sending request") 1067 return 1068 } 1069 1070 result.mlr, err = client.ListForBillingPeriodByDepartmentResponder(resp) 1071 if err != nil { 1072 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListForBillingPeriodByDepartment", resp, "Failure responding to request") 1073 return 1074 } 1075 if result.mlr.hasNextLink() && result.mlr.IsEmpty() { 1076 err = result.NextWithContext(ctx) 1077 return 1078 } 1079 1080 return 1081} 1082 1083// ListForBillingPeriodByDepartmentPreparer prepares the ListForBillingPeriodByDepartment request. 1084func (client MarketplacesClient) ListForBillingPeriodByDepartmentPreparer(ctx context.Context, departmentID string, billingPeriodName string, filter string, top *int32, skiptoken string) (*http.Request, error) { 1085 pathParameters := map[string]interface{}{ 1086 "billingPeriodName": autorest.Encode("path", billingPeriodName), 1087 "departmentId": autorest.Encode("path", departmentID), 1088 } 1089 1090 const APIVersion = "2018-10-01" 1091 queryParameters := map[string]interface{}{ 1092 "api-version": APIVersion, 1093 } 1094 if len(filter) > 0 { 1095 queryParameters["$filter"] = autorest.Encode("query", filter) 1096 } 1097 if top != nil { 1098 queryParameters["$top"] = autorest.Encode("query", *top) 1099 } 1100 if len(skiptoken) > 0 { 1101 queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) 1102 } 1103 1104 preparer := autorest.CreatePreparer( 1105 autorest.AsGet(), 1106 autorest.WithBaseURL(client.BaseURI), 1107 autorest.WithPathParameters("/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces", pathParameters), 1108 autorest.WithQueryParameters(queryParameters)) 1109 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1110} 1111 1112// ListForBillingPeriodByDepartmentSender sends the ListForBillingPeriodByDepartment request. The method will close the 1113// http.Response Body if it receives an error. 1114func (client MarketplacesClient) ListForBillingPeriodByDepartmentSender(req *http.Request) (*http.Response, error) { 1115 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1116} 1117 1118// ListForBillingPeriodByDepartmentResponder handles the response to the ListForBillingPeriodByDepartment request. The method always 1119// closes the http.Response Body. 1120func (client MarketplacesClient) ListForBillingPeriodByDepartmentResponder(resp *http.Response) (result MarketplacesListResult, err error) { 1121 err = autorest.Respond( 1122 resp, 1123 azure.WithErrorUnlessStatusCode(http.StatusOK), 1124 autorest.ByUnmarshallingJSON(&result), 1125 autorest.ByClosing()) 1126 result.Response = autorest.Response{Response: resp} 1127 return 1128} 1129 1130// listForBillingPeriodByDepartmentNextResults retrieves the next set of results, if any. 1131func (client MarketplacesClient) listForBillingPeriodByDepartmentNextResults(ctx context.Context, lastResults MarketplacesListResult) (result MarketplacesListResult, err error) { 1132 req, err := lastResults.marketplacesListResultPreparer(ctx) 1133 if err != nil { 1134 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listForBillingPeriodByDepartmentNextResults", nil, "Failure preparing next results request") 1135 } 1136 if req == nil { 1137 return 1138 } 1139 resp, err := client.ListForBillingPeriodByDepartmentSender(req) 1140 if err != nil { 1141 result.Response = autorest.Response{Response: resp} 1142 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listForBillingPeriodByDepartmentNextResults", resp, "Failure sending next results request") 1143 } 1144 result, err = client.ListForBillingPeriodByDepartmentResponder(resp) 1145 if err != nil { 1146 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listForBillingPeriodByDepartmentNextResults", resp, "Failure responding to next results request") 1147 } 1148 return 1149} 1150 1151// ListForBillingPeriodByDepartmentComplete enumerates all values, automatically crossing page boundaries as required. 1152func (client MarketplacesClient) ListForBillingPeriodByDepartmentComplete(ctx context.Context, departmentID string, billingPeriodName string, filter string, top *int32, skiptoken string) (result MarketplacesListResultIterator, err error) { 1153 if tracing.IsEnabled() { 1154 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListForBillingPeriodByDepartment") 1155 defer func() { 1156 sc := -1 1157 if result.Response().Response.Response != nil { 1158 sc = result.page.Response().Response.Response.StatusCode 1159 } 1160 tracing.EndSpan(ctx, sc, err) 1161 }() 1162 } 1163 result.page, err = client.ListForBillingPeriodByDepartment(ctx, departmentID, billingPeriodName, filter, top, skiptoken) 1164 return 1165} 1166 1167// ListForBillingPeriodByEnrollmentAccount lists the marketplaces for a scope by billing period and 1168// enrollmentAccountId. Marketplaces are available via this API only for May 1, 2014 or later. 1169// Parameters: 1170// enrollmentAccountID - enrollmentAccount ID 1171// billingPeriodName - billing Period Name. 1172// filter - may be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc 1173// time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 1174// 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. 1175// top - may be used to limit the number of results to the most recent N marketplaces. 1176// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response 1177// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that 1178// specifies a starting point to use for subsequent calls. 1179func (client MarketplacesClient) ListForBillingPeriodByEnrollmentAccount(ctx context.Context, enrollmentAccountID string, billingPeriodName string, filter string, top *int32, skiptoken string) (result MarketplacesListResultPage, err error) { 1180 if tracing.IsEnabled() { 1181 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListForBillingPeriodByEnrollmentAccount") 1182 defer func() { 1183 sc := -1 1184 if result.mlr.Response.Response != nil { 1185 sc = result.mlr.Response.Response.StatusCode 1186 } 1187 tracing.EndSpan(ctx, sc, err) 1188 }() 1189 } 1190 if err := validation.Validate([]validation.Validation{ 1191 {TargetValue: top, 1192 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1193 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 1194 {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 1195 }}}}}); err != nil { 1196 return result, validation.NewError("consumption.MarketplacesClient", "ListForBillingPeriodByEnrollmentAccount", err.Error()) 1197 } 1198 1199 result.fn = client.listForBillingPeriodByEnrollmentAccountNextResults 1200 req, err := client.ListForBillingPeriodByEnrollmentAccountPreparer(ctx, enrollmentAccountID, billingPeriodName, filter, top, skiptoken) 1201 if err != nil { 1202 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListForBillingPeriodByEnrollmentAccount", nil, "Failure preparing request") 1203 return 1204 } 1205 1206 resp, err := client.ListForBillingPeriodByEnrollmentAccountSender(req) 1207 if err != nil { 1208 result.mlr.Response = autorest.Response{Response: resp} 1209 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListForBillingPeriodByEnrollmentAccount", resp, "Failure sending request") 1210 return 1211 } 1212 1213 result.mlr, err = client.ListForBillingPeriodByEnrollmentAccountResponder(resp) 1214 if err != nil { 1215 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListForBillingPeriodByEnrollmentAccount", resp, "Failure responding to request") 1216 return 1217 } 1218 if result.mlr.hasNextLink() && result.mlr.IsEmpty() { 1219 err = result.NextWithContext(ctx) 1220 return 1221 } 1222 1223 return 1224} 1225 1226// ListForBillingPeriodByEnrollmentAccountPreparer prepares the ListForBillingPeriodByEnrollmentAccount request. 1227func (client MarketplacesClient) ListForBillingPeriodByEnrollmentAccountPreparer(ctx context.Context, enrollmentAccountID string, billingPeriodName string, filter string, top *int32, skiptoken string) (*http.Request, error) { 1228 pathParameters := map[string]interface{}{ 1229 "billingPeriodName": autorest.Encode("path", billingPeriodName), 1230 "enrollmentAccountId": autorest.Encode("path", enrollmentAccountID), 1231 } 1232 1233 const APIVersion = "2018-10-01" 1234 queryParameters := map[string]interface{}{ 1235 "api-version": APIVersion, 1236 } 1237 if len(filter) > 0 { 1238 queryParameters["$filter"] = autorest.Encode("query", filter) 1239 } 1240 if top != nil { 1241 queryParameters["$top"] = autorest.Encode("query", *top) 1242 } 1243 if len(skiptoken) > 0 { 1244 queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) 1245 } 1246 1247 preparer := autorest.CreatePreparer( 1248 autorest.AsGet(), 1249 autorest.WithBaseURL(client.BaseURI), 1250 autorest.WithPathParameters("/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces", pathParameters), 1251 autorest.WithQueryParameters(queryParameters)) 1252 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1253} 1254 1255// ListForBillingPeriodByEnrollmentAccountSender sends the ListForBillingPeriodByEnrollmentAccount request. The method will close the 1256// http.Response Body if it receives an error. 1257func (client MarketplacesClient) ListForBillingPeriodByEnrollmentAccountSender(req *http.Request) (*http.Response, error) { 1258 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1259} 1260 1261// ListForBillingPeriodByEnrollmentAccountResponder handles the response to the ListForBillingPeriodByEnrollmentAccount request. The method always 1262// closes the http.Response Body. 1263func (client MarketplacesClient) ListForBillingPeriodByEnrollmentAccountResponder(resp *http.Response) (result MarketplacesListResult, err error) { 1264 err = autorest.Respond( 1265 resp, 1266 azure.WithErrorUnlessStatusCode(http.StatusOK), 1267 autorest.ByUnmarshallingJSON(&result), 1268 autorest.ByClosing()) 1269 result.Response = autorest.Response{Response: resp} 1270 return 1271} 1272 1273// listForBillingPeriodByEnrollmentAccountNextResults retrieves the next set of results, if any. 1274func (client MarketplacesClient) listForBillingPeriodByEnrollmentAccountNextResults(ctx context.Context, lastResults MarketplacesListResult) (result MarketplacesListResult, err error) { 1275 req, err := lastResults.marketplacesListResultPreparer(ctx) 1276 if err != nil { 1277 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listForBillingPeriodByEnrollmentAccountNextResults", nil, "Failure preparing next results request") 1278 } 1279 if req == nil { 1280 return 1281 } 1282 resp, err := client.ListForBillingPeriodByEnrollmentAccountSender(req) 1283 if err != nil { 1284 result.Response = autorest.Response{Response: resp} 1285 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listForBillingPeriodByEnrollmentAccountNextResults", resp, "Failure sending next results request") 1286 } 1287 result, err = client.ListForBillingPeriodByEnrollmentAccountResponder(resp) 1288 if err != nil { 1289 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listForBillingPeriodByEnrollmentAccountNextResults", resp, "Failure responding to next results request") 1290 } 1291 return 1292} 1293 1294// ListForBillingPeriodByEnrollmentAccountComplete enumerates all values, automatically crossing page boundaries as required. 1295func (client MarketplacesClient) ListForBillingPeriodByEnrollmentAccountComplete(ctx context.Context, enrollmentAccountID string, billingPeriodName string, filter string, top *int32, skiptoken string) (result MarketplacesListResultIterator, err error) { 1296 if tracing.IsEnabled() { 1297 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListForBillingPeriodByEnrollmentAccount") 1298 defer func() { 1299 sc := -1 1300 if result.Response().Response.Response != nil { 1301 sc = result.page.Response().Response.Response.StatusCode 1302 } 1303 tracing.EndSpan(ctx, sc, err) 1304 }() 1305 } 1306 result.page, err = client.ListForBillingPeriodByEnrollmentAccount(ctx, enrollmentAccountID, billingPeriodName, filter, top, skiptoken) 1307 return 1308} 1309 1310// ListForBillingPeriodByManagementGroup lists the marketplace records for all subscriptions belonging to a management 1311// group scope by specified billing period. Marketplaces are available via this API only for May 1, 2014 or later. 1312// Parameters: 1313// managementGroupID - azure Management Group ID. 1314// billingPeriodName - billing Period Name. 1315// filter - may be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc 1316// time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 1317// 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. 1318// top - may be used to limit the number of results to the most recent N marketplaces. 1319// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response 1320// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that 1321// specifies a starting point to use for subsequent calls. 1322func (client MarketplacesClient) ListForBillingPeriodByManagementGroup(ctx context.Context, managementGroupID string, billingPeriodName string, filter string, top *int32, skiptoken string) (result MarketplacesListResultPage, err error) { 1323 if tracing.IsEnabled() { 1324 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListForBillingPeriodByManagementGroup") 1325 defer func() { 1326 sc := -1 1327 if result.mlr.Response.Response != nil { 1328 sc = result.mlr.Response.Response.StatusCode 1329 } 1330 tracing.EndSpan(ctx, sc, err) 1331 }() 1332 } 1333 if err := validation.Validate([]validation.Validation{ 1334 {TargetValue: top, 1335 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1336 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, 1337 {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 1338 }}}}}); err != nil { 1339 return result, validation.NewError("consumption.MarketplacesClient", "ListForBillingPeriodByManagementGroup", err.Error()) 1340 } 1341 1342 result.fn = client.listForBillingPeriodByManagementGroupNextResults 1343 req, err := client.ListForBillingPeriodByManagementGroupPreparer(ctx, managementGroupID, billingPeriodName, filter, top, skiptoken) 1344 if err != nil { 1345 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListForBillingPeriodByManagementGroup", nil, "Failure preparing request") 1346 return 1347 } 1348 1349 resp, err := client.ListForBillingPeriodByManagementGroupSender(req) 1350 if err != nil { 1351 result.mlr.Response = autorest.Response{Response: resp} 1352 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListForBillingPeriodByManagementGroup", resp, "Failure sending request") 1353 return 1354 } 1355 1356 result.mlr, err = client.ListForBillingPeriodByManagementGroupResponder(resp) 1357 if err != nil { 1358 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "ListForBillingPeriodByManagementGroup", resp, "Failure responding to request") 1359 return 1360 } 1361 if result.mlr.hasNextLink() && result.mlr.IsEmpty() { 1362 err = result.NextWithContext(ctx) 1363 return 1364 } 1365 1366 return 1367} 1368 1369// ListForBillingPeriodByManagementGroupPreparer prepares the ListForBillingPeriodByManagementGroup request. 1370func (client MarketplacesClient) ListForBillingPeriodByManagementGroupPreparer(ctx context.Context, managementGroupID string, billingPeriodName string, filter string, top *int32, skiptoken string) (*http.Request, error) { 1371 pathParameters := map[string]interface{}{ 1372 "billingPeriodName": autorest.Encode("path", billingPeriodName), 1373 "managementGroupId": autorest.Encode("path", managementGroupID), 1374 } 1375 1376 const APIVersion = "2018-10-01" 1377 queryParameters := map[string]interface{}{ 1378 "api-version": APIVersion, 1379 } 1380 if len(filter) > 0 { 1381 queryParameters["$filter"] = autorest.Encode("query", filter) 1382 } 1383 if top != nil { 1384 queryParameters["$top"] = autorest.Encode("query", *top) 1385 } 1386 if len(skiptoken) > 0 { 1387 queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) 1388 } 1389 1390 preparer := autorest.CreatePreparer( 1391 autorest.AsGet(), 1392 autorest.WithBaseURL(client.BaseURI), 1393 autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces", pathParameters), 1394 autorest.WithQueryParameters(queryParameters)) 1395 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1396} 1397 1398// ListForBillingPeriodByManagementGroupSender sends the ListForBillingPeriodByManagementGroup request. The method will close the 1399// http.Response Body if it receives an error. 1400func (client MarketplacesClient) ListForBillingPeriodByManagementGroupSender(req *http.Request) (*http.Response, error) { 1401 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1402} 1403 1404// ListForBillingPeriodByManagementGroupResponder handles the response to the ListForBillingPeriodByManagementGroup request. The method always 1405// closes the http.Response Body. 1406func (client MarketplacesClient) ListForBillingPeriodByManagementGroupResponder(resp *http.Response) (result MarketplacesListResult, err error) { 1407 err = autorest.Respond( 1408 resp, 1409 azure.WithErrorUnlessStatusCode(http.StatusOK), 1410 autorest.ByUnmarshallingJSON(&result), 1411 autorest.ByClosing()) 1412 result.Response = autorest.Response{Response: resp} 1413 return 1414} 1415 1416// listForBillingPeriodByManagementGroupNextResults retrieves the next set of results, if any. 1417func (client MarketplacesClient) listForBillingPeriodByManagementGroupNextResults(ctx context.Context, lastResults MarketplacesListResult) (result MarketplacesListResult, err error) { 1418 req, err := lastResults.marketplacesListResultPreparer(ctx) 1419 if err != nil { 1420 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listForBillingPeriodByManagementGroupNextResults", nil, "Failure preparing next results request") 1421 } 1422 if req == nil { 1423 return 1424 } 1425 resp, err := client.ListForBillingPeriodByManagementGroupSender(req) 1426 if err != nil { 1427 result.Response = autorest.Response{Response: resp} 1428 return result, autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listForBillingPeriodByManagementGroupNextResults", resp, "Failure sending next results request") 1429 } 1430 result, err = client.ListForBillingPeriodByManagementGroupResponder(resp) 1431 if err != nil { 1432 err = autorest.NewErrorWithError(err, "consumption.MarketplacesClient", "listForBillingPeriodByManagementGroupNextResults", resp, "Failure responding to next results request") 1433 } 1434 return 1435} 1436 1437// ListForBillingPeriodByManagementGroupComplete enumerates all values, automatically crossing page boundaries as required. 1438func (client MarketplacesClient) ListForBillingPeriodByManagementGroupComplete(ctx context.Context, managementGroupID string, billingPeriodName string, filter string, top *int32, skiptoken string) (result MarketplacesListResultIterator, err error) { 1439 if tracing.IsEnabled() { 1440 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesClient.ListForBillingPeriodByManagementGroup") 1441 defer func() { 1442 sc := -1 1443 if result.Response().Response.Response != nil { 1444 sc = result.page.Response().Response.Response.StatusCode 1445 } 1446 tracing.EndSpan(ctx, sc, err) 1447 }() 1448 } 1449 result.page, err = client.ListForBillingPeriodByManagementGroup(ctx, managementGroupID, billingPeriodName, filter, top, skiptoken) 1450 return 1451} 1452