1package consumption 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 "encoding/json" 23 "github.com/Azure/go-autorest/autorest" 24 "github.com/Azure/go-autorest/autorest/date" 25 "github.com/Azure/go-autorest/autorest/to" 26 "github.com/Azure/go-autorest/tracing" 27 "github.com/shopspring/decimal" 28 "net/http" 29) 30 31// The package's fully qualified name. 32const fqdn = "github.com/Azure/azure-sdk-for-go/services/consumption/mgmt/2018-01-31/consumption" 33 34// Budget a budget resource. 35type Budget struct { 36 autorest.Response `json:"-"` 37 *BudgetProperties `json:"properties,omitempty"` 38 // ID - READ-ONLY; Resource Id. 39 ID *string `json:"id,omitempty"` 40 // Name - READ-ONLY; Resource name. 41 Name *string `json:"name,omitempty"` 42 // Type - READ-ONLY; Resource type. 43 Type *string `json:"type,omitempty"` 44 // ETag - eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. 45 ETag *string `json:"eTag,omitempty"` 46} 47 48// MarshalJSON is the custom marshaler for Budget. 49func (b Budget) MarshalJSON() ([]byte, error) { 50 objectMap := make(map[string]interface{}) 51 if b.BudgetProperties != nil { 52 objectMap["properties"] = b.BudgetProperties 53 } 54 if b.ETag != nil { 55 objectMap["eTag"] = b.ETag 56 } 57 return json.Marshal(objectMap) 58} 59 60// UnmarshalJSON is the custom unmarshaler for Budget struct. 61func (b *Budget) UnmarshalJSON(body []byte) error { 62 var m map[string]*json.RawMessage 63 err := json.Unmarshal(body, &m) 64 if err != nil { 65 return err 66 } 67 for k, v := range m { 68 switch k { 69 case "properties": 70 if v != nil { 71 var budgetProperties BudgetProperties 72 err = json.Unmarshal(*v, &budgetProperties) 73 if err != nil { 74 return err 75 } 76 b.BudgetProperties = &budgetProperties 77 } 78 case "id": 79 if v != nil { 80 var ID string 81 err = json.Unmarshal(*v, &ID) 82 if err != nil { 83 return err 84 } 85 b.ID = &ID 86 } 87 case "name": 88 if v != nil { 89 var name string 90 err = json.Unmarshal(*v, &name) 91 if err != nil { 92 return err 93 } 94 b.Name = &name 95 } 96 case "type": 97 if v != nil { 98 var typeVar string 99 err = json.Unmarshal(*v, &typeVar) 100 if err != nil { 101 return err 102 } 103 b.Type = &typeVar 104 } 105 case "eTag": 106 if v != nil { 107 var eTag string 108 err = json.Unmarshal(*v, &eTag) 109 if err != nil { 110 return err 111 } 112 b.ETag = &eTag 113 } 114 } 115 } 116 117 return nil 118} 119 120// BudgetProperties the properties of the budget. 121type BudgetProperties struct { 122 // Category - The category of the budget, whether the budget tracks cost or usage. Possible values include: 'Cost', 'Usage' 123 Category CategoryType `json:"category,omitempty"` 124 // Amount - The total amount of cost to track with the budget 125 Amount *decimal.Decimal `json:"amount,omitempty"` 126 // TimeGrain - The time covered by a budget. Tracking of the amount will be reset based on the time grain. Possible values include: 'Monthly', 'Quarterly', 'Annually' 127 TimeGrain TimeGrainType `json:"timeGrain,omitempty"` 128 // TimePeriod - Has start and end date of the budget. The start date must be first of the month and should be less than the end date. Budget start date must be on or after June 1, 2017. Future start date should not be more than three months. Past start date should be selected within the timegrain period. There are no restrictions on the end date. 129 TimePeriod *BudgetTimePeriod `json:"timePeriod,omitempty"` 130 // Filters - May be used to filter budgets by resource group, resource, or meter. 131 Filters *Filters `json:"filters,omitempty"` 132 // CurrentSpend - READ-ONLY; The current amount of cost which is being tracked for a budget. 133 CurrentSpend *CurrentSpend `json:"currentSpend,omitempty"` 134 // Notifications - Dictionary of notifications associated with the budget. Budget can have up to five notifications. 135 Notifications map[string]*Notification `json:"notifications"` 136} 137 138// MarshalJSON is the custom marshaler for BudgetProperties. 139func (bp BudgetProperties) MarshalJSON() ([]byte, error) { 140 objectMap := make(map[string]interface{}) 141 if bp.Category != "" { 142 objectMap["category"] = bp.Category 143 } 144 if bp.Amount != nil { 145 objectMap["amount"] = bp.Amount 146 } 147 if bp.TimeGrain != "" { 148 objectMap["timeGrain"] = bp.TimeGrain 149 } 150 if bp.TimePeriod != nil { 151 objectMap["timePeriod"] = bp.TimePeriod 152 } 153 if bp.Filters != nil { 154 objectMap["filters"] = bp.Filters 155 } 156 if bp.Notifications != nil { 157 objectMap["notifications"] = bp.Notifications 158 } 159 return json.Marshal(objectMap) 160} 161 162// BudgetsListResult result of listing budgets. It contains a list of available budgets in the scope 163// provided. 164type BudgetsListResult struct { 165 autorest.Response `json:"-"` 166 // Value - READ-ONLY; The list of budgets. 167 Value *[]Budget `json:"value,omitempty"` 168 // NextLink - READ-ONLY; The link (url) to the next page of results. 169 NextLink *string `json:"nextLink,omitempty"` 170} 171 172// BudgetsListResultIterator provides access to a complete listing of Budget values. 173type BudgetsListResultIterator struct { 174 i int 175 page BudgetsListResultPage 176} 177 178// NextWithContext advances to the next value. If there was an error making 179// the request the iterator does not advance and the error is returned. 180func (iter *BudgetsListResultIterator) NextWithContext(ctx context.Context) (err error) { 181 if tracing.IsEnabled() { 182 ctx = tracing.StartSpan(ctx, fqdn+"/BudgetsListResultIterator.NextWithContext") 183 defer func() { 184 sc := -1 185 if iter.Response().Response.Response != nil { 186 sc = iter.Response().Response.Response.StatusCode 187 } 188 tracing.EndSpan(ctx, sc, err) 189 }() 190 } 191 iter.i++ 192 if iter.i < len(iter.page.Values()) { 193 return nil 194 } 195 err = iter.page.NextWithContext(ctx) 196 if err != nil { 197 iter.i-- 198 return err 199 } 200 iter.i = 0 201 return nil 202} 203 204// Next advances to the next value. If there was an error making 205// the request the iterator does not advance and the error is returned. 206// Deprecated: Use NextWithContext() instead. 207func (iter *BudgetsListResultIterator) Next() error { 208 return iter.NextWithContext(context.Background()) 209} 210 211// NotDone returns true if the enumeration should be started or is not yet complete. 212func (iter BudgetsListResultIterator) NotDone() bool { 213 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 214} 215 216// Response returns the raw server response from the last page request. 217func (iter BudgetsListResultIterator) Response() BudgetsListResult { 218 return iter.page.Response() 219} 220 221// Value returns the current value or a zero-initialized value if the 222// iterator has advanced beyond the end of the collection. 223func (iter BudgetsListResultIterator) Value() Budget { 224 if !iter.page.NotDone() { 225 return Budget{} 226 } 227 return iter.page.Values()[iter.i] 228} 229 230// Creates a new instance of the BudgetsListResultIterator type. 231func NewBudgetsListResultIterator(page BudgetsListResultPage) BudgetsListResultIterator { 232 return BudgetsListResultIterator{page: page} 233} 234 235// IsEmpty returns true if the ListResult contains no values. 236func (blr BudgetsListResult) IsEmpty() bool { 237 return blr.Value == nil || len(*blr.Value) == 0 238} 239 240// hasNextLink returns true if the NextLink is not empty. 241func (blr BudgetsListResult) hasNextLink() bool { 242 return blr.NextLink != nil && len(*blr.NextLink) != 0 243} 244 245// budgetsListResultPreparer prepares a request to retrieve the next set of results. 246// It returns nil if no more results exist. 247func (blr BudgetsListResult) budgetsListResultPreparer(ctx context.Context) (*http.Request, error) { 248 if !blr.hasNextLink() { 249 return nil, nil 250 } 251 return autorest.Prepare((&http.Request{}).WithContext(ctx), 252 autorest.AsJSON(), 253 autorest.AsGet(), 254 autorest.WithBaseURL(to.String(blr.NextLink))) 255} 256 257// BudgetsListResultPage contains a page of Budget values. 258type BudgetsListResultPage struct { 259 fn func(context.Context, BudgetsListResult) (BudgetsListResult, error) 260 blr BudgetsListResult 261} 262 263// NextWithContext advances to the next page of values. If there was an error making 264// the request the page does not advance and the error is returned. 265func (page *BudgetsListResultPage) NextWithContext(ctx context.Context) (err error) { 266 if tracing.IsEnabled() { 267 ctx = tracing.StartSpan(ctx, fqdn+"/BudgetsListResultPage.NextWithContext") 268 defer func() { 269 sc := -1 270 if page.Response().Response.Response != nil { 271 sc = page.Response().Response.Response.StatusCode 272 } 273 tracing.EndSpan(ctx, sc, err) 274 }() 275 } 276 for { 277 next, err := page.fn(ctx, page.blr) 278 if err != nil { 279 return err 280 } 281 page.blr = next 282 if !next.hasNextLink() || !next.IsEmpty() { 283 break 284 } 285 } 286 return nil 287} 288 289// Next advances to the next page of values. If there was an error making 290// the request the page does not advance and the error is returned. 291// Deprecated: Use NextWithContext() instead. 292func (page *BudgetsListResultPage) Next() error { 293 return page.NextWithContext(context.Background()) 294} 295 296// NotDone returns true if the page enumeration should be started or is not yet complete. 297func (page BudgetsListResultPage) NotDone() bool { 298 return !page.blr.IsEmpty() 299} 300 301// Response returns the raw server response from the last page request. 302func (page BudgetsListResultPage) Response() BudgetsListResult { 303 return page.blr 304} 305 306// Values returns the slice of values for the current page or nil if there are no values. 307func (page BudgetsListResultPage) Values() []Budget { 308 if page.blr.IsEmpty() { 309 return nil 310 } 311 return *page.blr.Value 312} 313 314// Creates a new instance of the BudgetsListResultPage type. 315func NewBudgetsListResultPage(cur BudgetsListResult, getNextPage func(context.Context, BudgetsListResult) (BudgetsListResult, error)) BudgetsListResultPage { 316 return BudgetsListResultPage{ 317 fn: getNextPage, 318 blr: cur, 319 } 320} 321 322// BudgetTimePeriod the start and end date for a budget. 323type BudgetTimePeriod struct { 324 // StartDate - The start date for the budget. 325 StartDate *date.Time `json:"startDate,omitempty"` 326 // EndDate - The end date for the budget. If not provided, we default this to 10 years from the start date. 327 EndDate *date.Time `json:"endDate,omitempty"` 328} 329 330// CurrentSpend the current amount of cost which is being tracked for a budget. 331type CurrentSpend struct { 332 // Amount - READ-ONLY; The total amount of cost which is being tracked by the budget. 333 Amount *decimal.Decimal `json:"amount,omitempty"` 334 // Unit - READ-ONLY; The unit of measure for the budget amount. 335 Unit *string `json:"unit,omitempty"` 336} 337 338// ErrorDetails the details of the error. 339type ErrorDetails struct { 340 // Code - READ-ONLY; Error code. 341 Code *string `json:"code,omitempty"` 342 // Message - READ-ONLY; Error message indicating why the operation failed. 343 Message *string `json:"message,omitempty"` 344} 345 346// ErrorResponse error response indicates that the service is not able to process the incoming request. The 347// reason is provided in the error message. 348type ErrorResponse struct { 349 // Error - The details of the error. 350 Error *ErrorDetails `json:"error,omitempty"` 351} 352 353// Filters may be used to filter budgets by resource group, resource, or meter. 354type Filters struct { 355 // ResourceGroups - The list of filters on resource groups, allowed at subscription level only. 356 ResourceGroups *[]string `json:"resourceGroups,omitempty"` 357 // Resources - The list of filters on resources. 358 Resources *[]string `json:"resources,omitempty"` 359 // Meters - The list of filters on meters, mandatory for budgets of usage category. 360 Meters *[]string `json:"meters,omitempty"` 361} 362 363// Marketplace an marketplace resource. 364type Marketplace struct { 365 *MarketplaceProperties `json:"properties,omitempty"` 366 // ID - READ-ONLY; Resource Id. 367 ID *string `json:"id,omitempty"` 368 // Name - READ-ONLY; Resource name. 369 Name *string `json:"name,omitempty"` 370 // Type - READ-ONLY; Resource type. 371 Type *string `json:"type,omitempty"` 372 // Tags - READ-ONLY; Resource tags. 373 Tags map[string]*string `json:"tags"` 374} 375 376// MarshalJSON is the custom marshaler for Marketplace. 377func (mVar Marketplace) MarshalJSON() ([]byte, error) { 378 objectMap := make(map[string]interface{}) 379 if mVar.MarketplaceProperties != nil { 380 objectMap["properties"] = mVar.MarketplaceProperties 381 } 382 return json.Marshal(objectMap) 383} 384 385// UnmarshalJSON is the custom unmarshaler for Marketplace struct. 386func (mVar *Marketplace) UnmarshalJSON(body []byte) error { 387 var m map[string]*json.RawMessage 388 err := json.Unmarshal(body, &m) 389 if err != nil { 390 return err 391 } 392 for k, v := range m { 393 switch k { 394 case "properties": 395 if v != nil { 396 var marketplaceProperties MarketplaceProperties 397 err = json.Unmarshal(*v, &marketplaceProperties) 398 if err != nil { 399 return err 400 } 401 mVar.MarketplaceProperties = &marketplaceProperties 402 } 403 case "id": 404 if v != nil { 405 var ID string 406 err = json.Unmarshal(*v, &ID) 407 if err != nil { 408 return err 409 } 410 mVar.ID = &ID 411 } 412 case "name": 413 if v != nil { 414 var name string 415 err = json.Unmarshal(*v, &name) 416 if err != nil { 417 return err 418 } 419 mVar.Name = &name 420 } 421 case "type": 422 if v != nil { 423 var typeVar string 424 err = json.Unmarshal(*v, &typeVar) 425 if err != nil { 426 return err 427 } 428 mVar.Type = &typeVar 429 } 430 case "tags": 431 if v != nil { 432 var tags map[string]*string 433 err = json.Unmarshal(*v, &tags) 434 if err != nil { 435 return err 436 } 437 mVar.Tags = tags 438 } 439 } 440 } 441 442 return nil 443} 444 445// MarketplaceProperties the properties of the marketplace usage detail. 446type MarketplaceProperties struct { 447 // BillingPeriodID - READ-ONLY; The id of the billing period resource that the usage belongs to. 448 BillingPeriodID *string `json:"billingPeriodId,omitempty"` 449 // UsageStart - READ-ONLY; The start of the date time range covered by the usage detail. 450 UsageStart *date.Time `json:"usageStart,omitempty"` 451 // UsageEnd - READ-ONLY; The end of the date time range covered by the usage detail. 452 UsageEnd *date.Time `json:"usageEnd,omitempty"` 453 // ResourceRate - READ-ONLY; The marketplace resource rate. 454 ResourceRate *decimal.Decimal `json:"resourceRate,omitempty"` 455 // OfferName - READ-ONLY; The type of offer. 456 OfferName *string `json:"offerName,omitempty"` 457 // ResourceGroup - READ-ONLY; The name of resource group. 458 ResourceGroup *string `json:"resourceGroup,omitempty"` 459 // OrderNumber - READ-ONLY; The order number. 460 OrderNumber *string `json:"orderNumber,omitempty"` 461 // InstanceName - READ-ONLY; The name of the resource instance that the usage is about. 462 InstanceName *string `json:"instanceName,omitempty"` 463 // InstanceID - READ-ONLY; The uri of the resource instance that the usage is about. 464 InstanceID *string `json:"instanceId,omitempty"` 465 // Currency - READ-ONLY; The ISO currency in which the meter is charged, for example, USD. 466 Currency *string `json:"currency,omitempty"` 467 // ConsumedQuantity - READ-ONLY; The quantity of usage. 468 ConsumedQuantity *decimal.Decimal `json:"consumedQuantity,omitempty"` 469 // UnitOfMeasure - READ-ONLY; The unit of measure. 470 UnitOfMeasure *string `json:"unitOfMeasure,omitempty"` 471 // PretaxCost - READ-ONLY; The amount of cost before tax. 472 PretaxCost *decimal.Decimal `json:"pretaxCost,omitempty"` 473 // IsEstimated - READ-ONLY; The estimated usage is subject to change. 474 IsEstimated *bool `json:"isEstimated,omitempty"` 475 // MeterID - READ-ONLY; The meter id. 476 MeterID *string `json:"meterId,omitempty"` 477 // SubscriptionGUID - READ-ONLY; Subscription guid. 478 SubscriptionGUID *string `json:"subscriptionGuid,omitempty"` 479 // SubscriptionName - READ-ONLY; Subscription name. 480 SubscriptionName *string `json:"subscriptionName,omitempty"` 481 // AccountName - READ-ONLY; Account name. 482 AccountName *string `json:"accountName,omitempty"` 483 // DepartmentName - READ-ONLY; Department name. 484 DepartmentName *string `json:"departmentName,omitempty"` 485 // ConsumedService - READ-ONLY; Consumed service name. 486 ConsumedService *string `json:"consumedService,omitempty"` 487 // CostCenter - READ-ONLY; The cost center of this department if it is a department and a costcenter exists 488 CostCenter *string `json:"costCenter,omitempty"` 489 // AdditionalProperties - READ-ONLY; Additional details of this usage item. By default this is not populated, unless it's specified in $expand. 490 AdditionalProperties *string `json:"additionalProperties,omitempty"` 491 // PublisherName - READ-ONLY; The name of publisher. 492 PublisherName *string `json:"publisherName,omitempty"` 493 // PlanName - READ-ONLY; The name of plan. 494 PlanName *string `json:"planName,omitempty"` 495} 496 497// MarketplacesListResult result of listing marketplaces. It contains a list of available marketplaces in 498// reverse chronological order by billing period. 499type MarketplacesListResult struct { 500 autorest.Response `json:"-"` 501 // Value - READ-ONLY; The list of marketplaces. 502 Value *[]Marketplace `json:"value,omitempty"` 503 // NextLink - READ-ONLY; The link (url) to the next page of results. 504 NextLink *string `json:"nextLink,omitempty"` 505} 506 507// MarketplacesListResultIterator provides access to a complete listing of Marketplace values. 508type MarketplacesListResultIterator struct { 509 i int 510 page MarketplacesListResultPage 511} 512 513// NextWithContext advances to the next value. If there was an error making 514// the request the iterator does not advance and the error is returned. 515func (iter *MarketplacesListResultIterator) NextWithContext(ctx context.Context) (err error) { 516 if tracing.IsEnabled() { 517 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesListResultIterator.NextWithContext") 518 defer func() { 519 sc := -1 520 if iter.Response().Response.Response != nil { 521 sc = iter.Response().Response.Response.StatusCode 522 } 523 tracing.EndSpan(ctx, sc, err) 524 }() 525 } 526 iter.i++ 527 if iter.i < len(iter.page.Values()) { 528 return nil 529 } 530 err = iter.page.NextWithContext(ctx) 531 if err != nil { 532 iter.i-- 533 return err 534 } 535 iter.i = 0 536 return nil 537} 538 539// Next advances to the next value. If there was an error making 540// the request the iterator does not advance and the error is returned. 541// Deprecated: Use NextWithContext() instead. 542func (iter *MarketplacesListResultIterator) Next() error { 543 return iter.NextWithContext(context.Background()) 544} 545 546// NotDone returns true if the enumeration should be started or is not yet complete. 547func (iter MarketplacesListResultIterator) NotDone() bool { 548 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 549} 550 551// Response returns the raw server response from the last page request. 552func (iter MarketplacesListResultIterator) Response() MarketplacesListResult { 553 return iter.page.Response() 554} 555 556// Value returns the current value or a zero-initialized value if the 557// iterator has advanced beyond the end of the collection. 558func (iter MarketplacesListResultIterator) Value() Marketplace { 559 if !iter.page.NotDone() { 560 return Marketplace{} 561 } 562 return iter.page.Values()[iter.i] 563} 564 565// Creates a new instance of the MarketplacesListResultIterator type. 566func NewMarketplacesListResultIterator(page MarketplacesListResultPage) MarketplacesListResultIterator { 567 return MarketplacesListResultIterator{page: page} 568} 569 570// IsEmpty returns true if the ListResult contains no values. 571func (mlr MarketplacesListResult) IsEmpty() bool { 572 return mlr.Value == nil || len(*mlr.Value) == 0 573} 574 575// hasNextLink returns true if the NextLink is not empty. 576func (mlr MarketplacesListResult) hasNextLink() bool { 577 return mlr.NextLink != nil && len(*mlr.NextLink) != 0 578} 579 580// marketplacesListResultPreparer prepares a request to retrieve the next set of results. 581// It returns nil if no more results exist. 582func (mlr MarketplacesListResult) marketplacesListResultPreparer(ctx context.Context) (*http.Request, error) { 583 if !mlr.hasNextLink() { 584 return nil, nil 585 } 586 return autorest.Prepare((&http.Request{}).WithContext(ctx), 587 autorest.AsJSON(), 588 autorest.AsGet(), 589 autorest.WithBaseURL(to.String(mlr.NextLink))) 590} 591 592// MarketplacesListResultPage contains a page of Marketplace values. 593type MarketplacesListResultPage struct { 594 fn func(context.Context, MarketplacesListResult) (MarketplacesListResult, error) 595 mlr MarketplacesListResult 596} 597 598// NextWithContext advances to the next page of values. If there was an error making 599// the request the page does not advance and the error is returned. 600func (page *MarketplacesListResultPage) NextWithContext(ctx context.Context) (err error) { 601 if tracing.IsEnabled() { 602 ctx = tracing.StartSpan(ctx, fqdn+"/MarketplacesListResultPage.NextWithContext") 603 defer func() { 604 sc := -1 605 if page.Response().Response.Response != nil { 606 sc = page.Response().Response.Response.StatusCode 607 } 608 tracing.EndSpan(ctx, sc, err) 609 }() 610 } 611 for { 612 next, err := page.fn(ctx, page.mlr) 613 if err != nil { 614 return err 615 } 616 page.mlr = next 617 if !next.hasNextLink() || !next.IsEmpty() { 618 break 619 } 620 } 621 return nil 622} 623 624// Next advances to the next page of values. If there was an error making 625// the request the page does not advance and the error is returned. 626// Deprecated: Use NextWithContext() instead. 627func (page *MarketplacesListResultPage) Next() error { 628 return page.NextWithContext(context.Background()) 629} 630 631// NotDone returns true if the page enumeration should be started or is not yet complete. 632func (page MarketplacesListResultPage) NotDone() bool { 633 return !page.mlr.IsEmpty() 634} 635 636// Response returns the raw server response from the last page request. 637func (page MarketplacesListResultPage) Response() MarketplacesListResult { 638 return page.mlr 639} 640 641// Values returns the slice of values for the current page or nil if there are no values. 642func (page MarketplacesListResultPage) Values() []Marketplace { 643 if page.mlr.IsEmpty() { 644 return nil 645 } 646 return *page.mlr.Value 647} 648 649// Creates a new instance of the MarketplacesListResultPage type. 650func NewMarketplacesListResultPage(cur MarketplacesListResult, getNextPage func(context.Context, MarketplacesListResult) (MarketplacesListResult, error)) MarketplacesListResultPage { 651 return MarketplacesListResultPage{ 652 fn: getNextPage, 653 mlr: cur, 654 } 655} 656 657// MeterDetails the properties of the meter detail. 658type MeterDetails struct { 659 // MeterName - READ-ONLY; The name of the meter, within the given meter category 660 MeterName *string `json:"meterName,omitempty"` 661 // MeterCategory - READ-ONLY; The category of the meter, for example, 'Cloud services', 'Networking', etc.. 662 MeterCategory *string `json:"meterCategory,omitempty"` 663 // MeterSubCategory - READ-ONLY; The subcategory of the meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. 664 MeterSubCategory *string `json:"meterSubCategory,omitempty"` 665 // Unit - READ-ONLY; The unit in which the meter consumption is charged, for example, 'Hours', 'GB', etc. 666 Unit *string `json:"unit,omitempty"` 667 // MeterLocation - READ-ONLY; The location in which the Azure service is available. 668 MeterLocation *string `json:"meterLocation,omitempty"` 669 // TotalIncludedQuantity - READ-ONLY; The total included quantity associated with the offer. 670 TotalIncludedQuantity *decimal.Decimal `json:"totalIncludedQuantity,omitempty"` 671 // PretaxStandardRate - READ-ONLY; The pretax listing price. 672 PretaxStandardRate *decimal.Decimal `json:"pretaxStandardRate,omitempty"` 673} 674 675// Notification the notification associated with a budget. 676type Notification struct { 677 // Enabled - The notification is enabled or not. 678 Enabled *bool `json:"enabled,omitempty"` 679 // Operator - The comparison operator. Possible values include: 'EqualTo', 'GreaterThan', 'GreaterThanOrEqualTo' 680 Operator OperatorType `json:"operator,omitempty"` 681 // Threshold - Threshold value associated with a notification. Notification is sent when the cost exceeded the threshold. It is always percent and has to be between 0 and 1000. 682 Threshold *decimal.Decimal `json:"threshold,omitempty"` 683 // ContactEmails - Email addresses to send the budget notification to when the threshold is exceeded. 684 ContactEmails *[]string `json:"contactEmails,omitempty"` 685 // ContactRoles - Contact roles to send the budget notification to when the threshold is exceeded. 686 ContactRoles *[]string `json:"contactRoles,omitempty"` 687 // ContactGroups - Action groups to send the budget notification to when the threshold is exceeded. 688 ContactGroups *[]string `json:"contactGroups,omitempty"` 689} 690 691// Operation a Consumption REST API operation. 692type Operation struct { 693 // Name - READ-ONLY; Operation name: {provider}/{resource}/{operation}. 694 Name *string `json:"name,omitempty"` 695 // Display - The object that represents the operation. 696 Display *OperationDisplay `json:"display,omitempty"` 697} 698 699// MarshalJSON is the custom marshaler for Operation. 700func (o Operation) MarshalJSON() ([]byte, error) { 701 objectMap := make(map[string]interface{}) 702 if o.Display != nil { 703 objectMap["display"] = o.Display 704 } 705 return json.Marshal(objectMap) 706} 707 708// OperationDisplay the object that represents the operation. 709type OperationDisplay struct { 710 // Provider - READ-ONLY; Service provider: Microsoft.Consumption. 711 Provider *string `json:"provider,omitempty"` 712 // Resource - READ-ONLY; Resource on which the operation is performed: UsageDetail, etc. 713 Resource *string `json:"resource,omitempty"` 714 // Operation - READ-ONLY; Operation type: Read, write, delete, etc. 715 Operation *string `json:"operation,omitempty"` 716} 717 718// OperationListResult result of listing consumption operations. It contains a list of operations and a URL 719// link to get the next set of results. 720type OperationListResult struct { 721 autorest.Response `json:"-"` 722 // Value - READ-ONLY; List of consumption operations supported by the Microsoft.Consumption resource provider. 723 Value *[]Operation `json:"value,omitempty"` 724 // NextLink - READ-ONLY; URL to get the next set of operation list results if there are any. 725 NextLink *string `json:"nextLink,omitempty"` 726} 727 728// OperationListResultIterator provides access to a complete listing of Operation values. 729type OperationListResultIterator struct { 730 i int 731 page OperationListResultPage 732} 733 734// NextWithContext advances to the next value. If there was an error making 735// the request the iterator does not advance and the error is returned. 736func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { 737 if tracing.IsEnabled() { 738 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") 739 defer func() { 740 sc := -1 741 if iter.Response().Response.Response != nil { 742 sc = iter.Response().Response.Response.StatusCode 743 } 744 tracing.EndSpan(ctx, sc, err) 745 }() 746 } 747 iter.i++ 748 if iter.i < len(iter.page.Values()) { 749 return nil 750 } 751 err = iter.page.NextWithContext(ctx) 752 if err != nil { 753 iter.i-- 754 return err 755 } 756 iter.i = 0 757 return nil 758} 759 760// Next advances to the next value. If there was an error making 761// the request the iterator does not advance and the error is returned. 762// Deprecated: Use NextWithContext() instead. 763func (iter *OperationListResultIterator) Next() error { 764 return iter.NextWithContext(context.Background()) 765} 766 767// NotDone returns true if the enumeration should be started or is not yet complete. 768func (iter OperationListResultIterator) NotDone() bool { 769 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 770} 771 772// Response returns the raw server response from the last page request. 773func (iter OperationListResultIterator) Response() OperationListResult { 774 return iter.page.Response() 775} 776 777// Value returns the current value or a zero-initialized value if the 778// iterator has advanced beyond the end of the collection. 779func (iter OperationListResultIterator) Value() Operation { 780 if !iter.page.NotDone() { 781 return Operation{} 782 } 783 return iter.page.Values()[iter.i] 784} 785 786// Creates a new instance of the OperationListResultIterator type. 787func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { 788 return OperationListResultIterator{page: page} 789} 790 791// IsEmpty returns true if the ListResult contains no values. 792func (olr OperationListResult) IsEmpty() bool { 793 return olr.Value == nil || len(*olr.Value) == 0 794} 795 796// hasNextLink returns true if the NextLink is not empty. 797func (olr OperationListResult) hasNextLink() bool { 798 return olr.NextLink != nil && len(*olr.NextLink) != 0 799} 800 801// operationListResultPreparer prepares a request to retrieve the next set of results. 802// It returns nil if no more results exist. 803func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { 804 if !olr.hasNextLink() { 805 return nil, nil 806 } 807 return autorest.Prepare((&http.Request{}).WithContext(ctx), 808 autorest.AsJSON(), 809 autorest.AsGet(), 810 autorest.WithBaseURL(to.String(olr.NextLink))) 811} 812 813// OperationListResultPage contains a page of Operation values. 814type OperationListResultPage struct { 815 fn func(context.Context, OperationListResult) (OperationListResult, error) 816 olr OperationListResult 817} 818 819// NextWithContext advances to the next page of values. If there was an error making 820// the request the page does not advance and the error is returned. 821func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { 822 if tracing.IsEnabled() { 823 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") 824 defer func() { 825 sc := -1 826 if page.Response().Response.Response != nil { 827 sc = page.Response().Response.Response.StatusCode 828 } 829 tracing.EndSpan(ctx, sc, err) 830 }() 831 } 832 for { 833 next, err := page.fn(ctx, page.olr) 834 if err != nil { 835 return err 836 } 837 page.olr = next 838 if !next.hasNextLink() || !next.IsEmpty() { 839 break 840 } 841 } 842 return nil 843} 844 845// Next advances to the next page of values. If there was an error making 846// the request the page does not advance and the error is returned. 847// Deprecated: Use NextWithContext() instead. 848func (page *OperationListResultPage) Next() error { 849 return page.NextWithContext(context.Background()) 850} 851 852// NotDone returns true if the page enumeration should be started or is not yet complete. 853func (page OperationListResultPage) NotDone() bool { 854 return !page.olr.IsEmpty() 855} 856 857// Response returns the raw server response from the last page request. 858func (page OperationListResultPage) Response() OperationListResult { 859 return page.olr 860} 861 862// Values returns the slice of values for the current page or nil if there are no values. 863func (page OperationListResultPage) Values() []Operation { 864 if page.olr.IsEmpty() { 865 return nil 866 } 867 return *page.olr.Value 868} 869 870// Creates a new instance of the OperationListResultPage type. 871func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { 872 return OperationListResultPage{ 873 fn: getNextPage, 874 olr: cur, 875 } 876} 877 878// PriceSheetModel price sheet result. It contains the pricesheet associated with billing period 879type PriceSheetModel struct { 880 // Pricesheets - READ-ONLY; Price sheet 881 Pricesheets *[]PriceSheetProperties `json:"pricesheets,omitempty"` 882 // NextLink - READ-ONLY; The link (url) to the next page of results. 883 NextLink *string `json:"nextLink,omitempty"` 884} 885 886// PriceSheetProperties the properties of the price sheet. 887type PriceSheetProperties struct { 888 // BillingPeriodID - READ-ONLY; The id of the billing period resource that the usage belongs to. 889 BillingPeriodID *string `json:"billingPeriodId,omitempty"` 890 // MeterID - READ-ONLY; The meter id 891 MeterID *string `json:"meterId,omitempty"` 892 // MeterDetails - READ-ONLY; The details about the meter. By default this is not populated, unless it's specified in $expand. 893 MeterDetails *MeterDetails `json:"meterDetails,omitempty"` 894 // UnitOfMeasure - READ-ONLY; Unit of measure 895 UnitOfMeasure *string `json:"unitOfMeasure,omitempty"` 896 // IncludedQuantity - READ-ONLY; Included quality for an offer 897 IncludedQuantity *decimal.Decimal `json:"includedQuantity,omitempty"` 898 // PartNumber - READ-ONLY; Part Number 899 PartNumber *string `json:"partNumber,omitempty"` 900 // UnitPrice - READ-ONLY; Unit Price 901 UnitPrice *decimal.Decimal `json:"unitPrice,omitempty"` 902 // CurrencyCode - READ-ONLY; Currency Code 903 CurrencyCode *string `json:"currencyCode,omitempty"` 904} 905 906// PriceSheetResult an pricesheet resource. 907type PriceSheetResult struct { 908 autorest.Response `json:"-"` 909 *PriceSheetModel `json:"properties,omitempty"` 910 // ID - READ-ONLY; Resource Id. 911 ID *string `json:"id,omitempty"` 912 // Name - READ-ONLY; Resource name. 913 Name *string `json:"name,omitempty"` 914 // Type - READ-ONLY; Resource type. 915 Type *string `json:"type,omitempty"` 916 // Tags - READ-ONLY; Resource tags. 917 Tags map[string]*string `json:"tags"` 918} 919 920// MarshalJSON is the custom marshaler for PriceSheetResult. 921func (psr PriceSheetResult) MarshalJSON() ([]byte, error) { 922 objectMap := make(map[string]interface{}) 923 if psr.PriceSheetModel != nil { 924 objectMap["properties"] = psr.PriceSheetModel 925 } 926 return json.Marshal(objectMap) 927} 928 929// UnmarshalJSON is the custom unmarshaler for PriceSheetResult struct. 930func (psr *PriceSheetResult) UnmarshalJSON(body []byte) error { 931 var m map[string]*json.RawMessage 932 err := json.Unmarshal(body, &m) 933 if err != nil { 934 return err 935 } 936 for k, v := range m { 937 switch k { 938 case "properties": 939 if v != nil { 940 var priceSheetModel PriceSheetModel 941 err = json.Unmarshal(*v, &priceSheetModel) 942 if err != nil { 943 return err 944 } 945 psr.PriceSheetModel = &priceSheetModel 946 } 947 case "id": 948 if v != nil { 949 var ID string 950 err = json.Unmarshal(*v, &ID) 951 if err != nil { 952 return err 953 } 954 psr.ID = &ID 955 } 956 case "name": 957 if v != nil { 958 var name string 959 err = json.Unmarshal(*v, &name) 960 if err != nil { 961 return err 962 } 963 psr.Name = &name 964 } 965 case "type": 966 if v != nil { 967 var typeVar string 968 err = json.Unmarshal(*v, &typeVar) 969 if err != nil { 970 return err 971 } 972 psr.Type = &typeVar 973 } 974 case "tags": 975 if v != nil { 976 var tags map[string]*string 977 err = json.Unmarshal(*v, &tags) 978 if err != nil { 979 return err 980 } 981 psr.Tags = tags 982 } 983 } 984 } 985 986 return nil 987} 988 989// ProxyResource the Resource model definition. 990type ProxyResource struct { 991 // ID - READ-ONLY; Resource Id. 992 ID *string `json:"id,omitempty"` 993 // Name - READ-ONLY; Resource name. 994 Name *string `json:"name,omitempty"` 995 // Type - READ-ONLY; Resource type. 996 Type *string `json:"type,omitempty"` 997 // ETag - eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. 998 ETag *string `json:"eTag,omitempty"` 999} 1000 1001// MarshalJSON is the custom marshaler for ProxyResource. 1002func (pr ProxyResource) MarshalJSON() ([]byte, error) { 1003 objectMap := make(map[string]interface{}) 1004 if pr.ETag != nil { 1005 objectMap["eTag"] = pr.ETag 1006 } 1007 return json.Marshal(objectMap) 1008} 1009 1010// ReservationDetails reservation details resource. 1011type ReservationDetails struct { 1012 *ReservationDetailsProperties `json:"properties,omitempty"` 1013 // ID - READ-ONLY; Resource Id. 1014 ID *string `json:"id,omitempty"` 1015 // Name - READ-ONLY; Resource name. 1016 Name *string `json:"name,omitempty"` 1017 // Type - READ-ONLY; Resource type. 1018 Type *string `json:"type,omitempty"` 1019 // Tags - READ-ONLY; Resource tags. 1020 Tags map[string]*string `json:"tags"` 1021} 1022 1023// MarshalJSON is the custom marshaler for ReservationDetails. 1024func (rd ReservationDetails) MarshalJSON() ([]byte, error) { 1025 objectMap := make(map[string]interface{}) 1026 if rd.ReservationDetailsProperties != nil { 1027 objectMap["properties"] = rd.ReservationDetailsProperties 1028 } 1029 return json.Marshal(objectMap) 1030} 1031 1032// UnmarshalJSON is the custom unmarshaler for ReservationDetails struct. 1033func (rd *ReservationDetails) UnmarshalJSON(body []byte) error { 1034 var m map[string]*json.RawMessage 1035 err := json.Unmarshal(body, &m) 1036 if err != nil { 1037 return err 1038 } 1039 for k, v := range m { 1040 switch k { 1041 case "properties": 1042 if v != nil { 1043 var reservationDetailsProperties ReservationDetailsProperties 1044 err = json.Unmarshal(*v, &reservationDetailsProperties) 1045 if err != nil { 1046 return err 1047 } 1048 rd.ReservationDetailsProperties = &reservationDetailsProperties 1049 } 1050 case "id": 1051 if v != nil { 1052 var ID string 1053 err = json.Unmarshal(*v, &ID) 1054 if err != nil { 1055 return err 1056 } 1057 rd.ID = &ID 1058 } 1059 case "name": 1060 if v != nil { 1061 var name string 1062 err = json.Unmarshal(*v, &name) 1063 if err != nil { 1064 return err 1065 } 1066 rd.Name = &name 1067 } 1068 case "type": 1069 if v != nil { 1070 var typeVar string 1071 err = json.Unmarshal(*v, &typeVar) 1072 if err != nil { 1073 return err 1074 } 1075 rd.Type = &typeVar 1076 } 1077 case "tags": 1078 if v != nil { 1079 var tags map[string]*string 1080 err = json.Unmarshal(*v, &tags) 1081 if err != nil { 1082 return err 1083 } 1084 rd.Tags = tags 1085 } 1086 } 1087 } 1088 1089 return nil 1090} 1091 1092// ReservationDetailsListResult result of listing reservation details. 1093type ReservationDetailsListResult struct { 1094 autorest.Response `json:"-"` 1095 // Value - READ-ONLY; The list of reservation details. 1096 Value *[]ReservationDetails `json:"value,omitempty"` 1097 // NextLink - READ-ONLY; The link (url) to the next page of results. 1098 NextLink *string `json:"nextLink,omitempty"` 1099} 1100 1101// ReservationDetailsListResultIterator provides access to a complete listing of ReservationDetails values. 1102type ReservationDetailsListResultIterator struct { 1103 i int 1104 page ReservationDetailsListResultPage 1105} 1106 1107// NextWithContext advances to the next value. If there was an error making 1108// the request the iterator does not advance and the error is returned. 1109func (iter *ReservationDetailsListResultIterator) NextWithContext(ctx context.Context) (err error) { 1110 if tracing.IsEnabled() { 1111 ctx = tracing.StartSpan(ctx, fqdn+"/ReservationDetailsListResultIterator.NextWithContext") 1112 defer func() { 1113 sc := -1 1114 if iter.Response().Response.Response != nil { 1115 sc = iter.Response().Response.Response.StatusCode 1116 } 1117 tracing.EndSpan(ctx, sc, err) 1118 }() 1119 } 1120 iter.i++ 1121 if iter.i < len(iter.page.Values()) { 1122 return nil 1123 } 1124 err = iter.page.NextWithContext(ctx) 1125 if err != nil { 1126 iter.i-- 1127 return err 1128 } 1129 iter.i = 0 1130 return nil 1131} 1132 1133// Next advances to the next value. If there was an error making 1134// the request the iterator does not advance and the error is returned. 1135// Deprecated: Use NextWithContext() instead. 1136func (iter *ReservationDetailsListResultIterator) Next() error { 1137 return iter.NextWithContext(context.Background()) 1138} 1139 1140// NotDone returns true if the enumeration should be started or is not yet complete. 1141func (iter ReservationDetailsListResultIterator) NotDone() bool { 1142 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1143} 1144 1145// Response returns the raw server response from the last page request. 1146func (iter ReservationDetailsListResultIterator) Response() ReservationDetailsListResult { 1147 return iter.page.Response() 1148} 1149 1150// Value returns the current value or a zero-initialized value if the 1151// iterator has advanced beyond the end of the collection. 1152func (iter ReservationDetailsListResultIterator) Value() ReservationDetails { 1153 if !iter.page.NotDone() { 1154 return ReservationDetails{} 1155 } 1156 return iter.page.Values()[iter.i] 1157} 1158 1159// Creates a new instance of the ReservationDetailsListResultIterator type. 1160func NewReservationDetailsListResultIterator(page ReservationDetailsListResultPage) ReservationDetailsListResultIterator { 1161 return ReservationDetailsListResultIterator{page: page} 1162} 1163 1164// IsEmpty returns true if the ListResult contains no values. 1165func (rdlr ReservationDetailsListResult) IsEmpty() bool { 1166 return rdlr.Value == nil || len(*rdlr.Value) == 0 1167} 1168 1169// hasNextLink returns true if the NextLink is not empty. 1170func (rdlr ReservationDetailsListResult) hasNextLink() bool { 1171 return rdlr.NextLink != nil && len(*rdlr.NextLink) != 0 1172} 1173 1174// reservationDetailsListResultPreparer prepares a request to retrieve the next set of results. 1175// It returns nil if no more results exist. 1176func (rdlr ReservationDetailsListResult) reservationDetailsListResultPreparer(ctx context.Context) (*http.Request, error) { 1177 if !rdlr.hasNextLink() { 1178 return nil, nil 1179 } 1180 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1181 autorest.AsJSON(), 1182 autorest.AsGet(), 1183 autorest.WithBaseURL(to.String(rdlr.NextLink))) 1184} 1185 1186// ReservationDetailsListResultPage contains a page of ReservationDetails values. 1187type ReservationDetailsListResultPage struct { 1188 fn func(context.Context, ReservationDetailsListResult) (ReservationDetailsListResult, error) 1189 rdlr ReservationDetailsListResult 1190} 1191 1192// NextWithContext advances to the next page of values. If there was an error making 1193// the request the page does not advance and the error is returned. 1194func (page *ReservationDetailsListResultPage) NextWithContext(ctx context.Context) (err error) { 1195 if tracing.IsEnabled() { 1196 ctx = tracing.StartSpan(ctx, fqdn+"/ReservationDetailsListResultPage.NextWithContext") 1197 defer func() { 1198 sc := -1 1199 if page.Response().Response.Response != nil { 1200 sc = page.Response().Response.Response.StatusCode 1201 } 1202 tracing.EndSpan(ctx, sc, err) 1203 }() 1204 } 1205 for { 1206 next, err := page.fn(ctx, page.rdlr) 1207 if err != nil { 1208 return err 1209 } 1210 page.rdlr = next 1211 if !next.hasNextLink() || !next.IsEmpty() { 1212 break 1213 } 1214 } 1215 return nil 1216} 1217 1218// Next advances to the next page of values. If there was an error making 1219// the request the page does not advance and the error is returned. 1220// Deprecated: Use NextWithContext() instead. 1221func (page *ReservationDetailsListResultPage) Next() error { 1222 return page.NextWithContext(context.Background()) 1223} 1224 1225// NotDone returns true if the page enumeration should be started or is not yet complete. 1226func (page ReservationDetailsListResultPage) NotDone() bool { 1227 return !page.rdlr.IsEmpty() 1228} 1229 1230// Response returns the raw server response from the last page request. 1231func (page ReservationDetailsListResultPage) Response() ReservationDetailsListResult { 1232 return page.rdlr 1233} 1234 1235// Values returns the slice of values for the current page or nil if there are no values. 1236func (page ReservationDetailsListResultPage) Values() []ReservationDetails { 1237 if page.rdlr.IsEmpty() { 1238 return nil 1239 } 1240 return *page.rdlr.Value 1241} 1242 1243// Creates a new instance of the ReservationDetailsListResultPage type. 1244func NewReservationDetailsListResultPage(cur ReservationDetailsListResult, getNextPage func(context.Context, ReservationDetailsListResult) (ReservationDetailsListResult, error)) ReservationDetailsListResultPage { 1245 return ReservationDetailsListResultPage{ 1246 fn: getNextPage, 1247 rdlr: cur, 1248 } 1249} 1250 1251// ReservationDetailsProperties the properties of the reservation details. 1252type ReservationDetailsProperties struct { 1253 // ReservationOrderID - READ-ONLY; The reservation order ID is the identifier for a reservation purchase. Each reservation order ID represents a single purchase transaction. A reservation order contains reservations. The reservation order specifies the VM size and region for the reservations. 1254 ReservationOrderID *string `json:"reservationOrderId,omitempty"` 1255 // ReservationID - READ-ONLY; The reservation ID is the identifier of a reservation within a reservation order. Each reservation is the grouping for applying the benefit scope and also specifies the number of instances to which the reservation benefit can be applied to. 1256 ReservationID *string `json:"reservationId,omitempty"` 1257 // SkuName - READ-ONLY; This is the ARM Sku name. It can be used to join with the serviceType field in additional info in usage records. 1258 SkuName *string `json:"skuName,omitempty"` 1259 // ReservedHours - READ-ONLY; This is the total hours reserved for the day. E.g. if reservation for 1 instance was made on 1 PM, this will be 11 hours for that day and 24 hours from subsequent days. 1260 ReservedHours *decimal.Decimal `json:"reservedHours,omitempty"` 1261 // UsageDate - READ-ONLY; The date on which consumption occurred. 1262 UsageDate *date.Time `json:"usageDate,omitempty"` 1263 // UsedHours - READ-ONLY; This is the total hours used by the instance. 1264 UsedHours *decimal.Decimal `json:"usedHours,omitempty"` 1265 // InstanceID - READ-ONLY; This identifier is the name of the resource or the fully qualified Resource ID. 1266 InstanceID *string `json:"instanceId,omitempty"` 1267 // TotalReservedQuantity - READ-ONLY; This is the total count of instances that are reserved for the reservationId. 1268 TotalReservedQuantity *decimal.Decimal `json:"totalReservedQuantity,omitempty"` 1269} 1270 1271// ReservationSummaries reservation summaries resource. 1272type ReservationSummaries struct { 1273 *ReservationSummariesProperties `json:"properties,omitempty"` 1274 // ID - READ-ONLY; Resource Id. 1275 ID *string `json:"id,omitempty"` 1276 // Name - READ-ONLY; Resource name. 1277 Name *string `json:"name,omitempty"` 1278 // Type - READ-ONLY; Resource type. 1279 Type *string `json:"type,omitempty"` 1280 // Tags - READ-ONLY; Resource tags. 1281 Tags map[string]*string `json:"tags"` 1282} 1283 1284// MarshalJSON is the custom marshaler for ReservationSummaries. 1285func (rs ReservationSummaries) MarshalJSON() ([]byte, error) { 1286 objectMap := make(map[string]interface{}) 1287 if rs.ReservationSummariesProperties != nil { 1288 objectMap["properties"] = rs.ReservationSummariesProperties 1289 } 1290 return json.Marshal(objectMap) 1291} 1292 1293// UnmarshalJSON is the custom unmarshaler for ReservationSummaries struct. 1294func (rs *ReservationSummaries) UnmarshalJSON(body []byte) error { 1295 var m map[string]*json.RawMessage 1296 err := json.Unmarshal(body, &m) 1297 if err != nil { 1298 return err 1299 } 1300 for k, v := range m { 1301 switch k { 1302 case "properties": 1303 if v != nil { 1304 var reservationSummariesProperties ReservationSummariesProperties 1305 err = json.Unmarshal(*v, &reservationSummariesProperties) 1306 if err != nil { 1307 return err 1308 } 1309 rs.ReservationSummariesProperties = &reservationSummariesProperties 1310 } 1311 case "id": 1312 if v != nil { 1313 var ID string 1314 err = json.Unmarshal(*v, &ID) 1315 if err != nil { 1316 return err 1317 } 1318 rs.ID = &ID 1319 } 1320 case "name": 1321 if v != nil { 1322 var name string 1323 err = json.Unmarshal(*v, &name) 1324 if err != nil { 1325 return err 1326 } 1327 rs.Name = &name 1328 } 1329 case "type": 1330 if v != nil { 1331 var typeVar string 1332 err = json.Unmarshal(*v, &typeVar) 1333 if err != nil { 1334 return err 1335 } 1336 rs.Type = &typeVar 1337 } 1338 case "tags": 1339 if v != nil { 1340 var tags map[string]*string 1341 err = json.Unmarshal(*v, &tags) 1342 if err != nil { 1343 return err 1344 } 1345 rs.Tags = tags 1346 } 1347 } 1348 } 1349 1350 return nil 1351} 1352 1353// ReservationSummariesListResult result of listing reservation summaries. 1354type ReservationSummariesListResult struct { 1355 autorest.Response `json:"-"` 1356 // Value - READ-ONLY; The list of reservation summaries. 1357 Value *[]ReservationSummaries `json:"value,omitempty"` 1358 // NextLink - READ-ONLY; The link (url) to the next page of results. 1359 NextLink *string `json:"nextLink,omitempty"` 1360} 1361 1362// ReservationSummariesListResultIterator provides access to a complete listing of ReservationSummaries 1363// values. 1364type ReservationSummariesListResultIterator struct { 1365 i int 1366 page ReservationSummariesListResultPage 1367} 1368 1369// NextWithContext advances to the next value. If there was an error making 1370// the request the iterator does not advance and the error is returned. 1371func (iter *ReservationSummariesListResultIterator) NextWithContext(ctx context.Context) (err error) { 1372 if tracing.IsEnabled() { 1373 ctx = tracing.StartSpan(ctx, fqdn+"/ReservationSummariesListResultIterator.NextWithContext") 1374 defer func() { 1375 sc := -1 1376 if iter.Response().Response.Response != nil { 1377 sc = iter.Response().Response.Response.StatusCode 1378 } 1379 tracing.EndSpan(ctx, sc, err) 1380 }() 1381 } 1382 iter.i++ 1383 if iter.i < len(iter.page.Values()) { 1384 return nil 1385 } 1386 err = iter.page.NextWithContext(ctx) 1387 if err != nil { 1388 iter.i-- 1389 return err 1390 } 1391 iter.i = 0 1392 return nil 1393} 1394 1395// Next advances to the next value. If there was an error making 1396// the request the iterator does not advance and the error is returned. 1397// Deprecated: Use NextWithContext() instead. 1398func (iter *ReservationSummariesListResultIterator) Next() error { 1399 return iter.NextWithContext(context.Background()) 1400} 1401 1402// NotDone returns true if the enumeration should be started or is not yet complete. 1403func (iter ReservationSummariesListResultIterator) NotDone() bool { 1404 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1405} 1406 1407// Response returns the raw server response from the last page request. 1408func (iter ReservationSummariesListResultIterator) Response() ReservationSummariesListResult { 1409 return iter.page.Response() 1410} 1411 1412// Value returns the current value or a zero-initialized value if the 1413// iterator has advanced beyond the end of the collection. 1414func (iter ReservationSummariesListResultIterator) Value() ReservationSummaries { 1415 if !iter.page.NotDone() { 1416 return ReservationSummaries{} 1417 } 1418 return iter.page.Values()[iter.i] 1419} 1420 1421// Creates a new instance of the ReservationSummariesListResultIterator type. 1422func NewReservationSummariesListResultIterator(page ReservationSummariesListResultPage) ReservationSummariesListResultIterator { 1423 return ReservationSummariesListResultIterator{page: page} 1424} 1425 1426// IsEmpty returns true if the ListResult contains no values. 1427func (rslr ReservationSummariesListResult) IsEmpty() bool { 1428 return rslr.Value == nil || len(*rslr.Value) == 0 1429} 1430 1431// hasNextLink returns true if the NextLink is not empty. 1432func (rslr ReservationSummariesListResult) hasNextLink() bool { 1433 return rslr.NextLink != nil && len(*rslr.NextLink) != 0 1434} 1435 1436// reservationSummariesListResultPreparer prepares a request to retrieve the next set of results. 1437// It returns nil if no more results exist. 1438func (rslr ReservationSummariesListResult) reservationSummariesListResultPreparer(ctx context.Context) (*http.Request, error) { 1439 if !rslr.hasNextLink() { 1440 return nil, nil 1441 } 1442 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1443 autorest.AsJSON(), 1444 autorest.AsGet(), 1445 autorest.WithBaseURL(to.String(rslr.NextLink))) 1446} 1447 1448// ReservationSummariesListResultPage contains a page of ReservationSummaries values. 1449type ReservationSummariesListResultPage struct { 1450 fn func(context.Context, ReservationSummariesListResult) (ReservationSummariesListResult, error) 1451 rslr ReservationSummariesListResult 1452} 1453 1454// NextWithContext advances to the next page of values. If there was an error making 1455// the request the page does not advance and the error is returned. 1456func (page *ReservationSummariesListResultPage) NextWithContext(ctx context.Context) (err error) { 1457 if tracing.IsEnabled() { 1458 ctx = tracing.StartSpan(ctx, fqdn+"/ReservationSummariesListResultPage.NextWithContext") 1459 defer func() { 1460 sc := -1 1461 if page.Response().Response.Response != nil { 1462 sc = page.Response().Response.Response.StatusCode 1463 } 1464 tracing.EndSpan(ctx, sc, err) 1465 }() 1466 } 1467 for { 1468 next, err := page.fn(ctx, page.rslr) 1469 if err != nil { 1470 return err 1471 } 1472 page.rslr = next 1473 if !next.hasNextLink() || !next.IsEmpty() { 1474 break 1475 } 1476 } 1477 return nil 1478} 1479 1480// Next advances to the next page of values. If there was an error making 1481// the request the page does not advance and the error is returned. 1482// Deprecated: Use NextWithContext() instead. 1483func (page *ReservationSummariesListResultPage) Next() error { 1484 return page.NextWithContext(context.Background()) 1485} 1486 1487// NotDone returns true if the page enumeration should be started or is not yet complete. 1488func (page ReservationSummariesListResultPage) NotDone() bool { 1489 return !page.rslr.IsEmpty() 1490} 1491 1492// Response returns the raw server response from the last page request. 1493func (page ReservationSummariesListResultPage) Response() ReservationSummariesListResult { 1494 return page.rslr 1495} 1496 1497// Values returns the slice of values for the current page or nil if there are no values. 1498func (page ReservationSummariesListResultPage) Values() []ReservationSummaries { 1499 if page.rslr.IsEmpty() { 1500 return nil 1501 } 1502 return *page.rslr.Value 1503} 1504 1505// Creates a new instance of the ReservationSummariesListResultPage type. 1506func NewReservationSummariesListResultPage(cur ReservationSummariesListResult, getNextPage func(context.Context, ReservationSummariesListResult) (ReservationSummariesListResult, error)) ReservationSummariesListResultPage { 1507 return ReservationSummariesListResultPage{ 1508 fn: getNextPage, 1509 rslr: cur, 1510 } 1511} 1512 1513// ReservationSummariesProperties the properties of the reservation summaries. 1514type ReservationSummariesProperties struct { 1515 // ReservationOrderID - READ-ONLY; The reservation order ID is the identifier for a reservation purchase. Each reservation order ID represents a single purchase transaction. A reservation order contains reservations. The reservation order specifies the VM size and region for the reservations. 1516 ReservationOrderID *string `json:"reservationOrderId,omitempty"` 1517 // ReservationID - READ-ONLY; The reservation ID is the identifier of a reservation within a reservation order. Each reservation is the grouping for applying the benefit scope and also specifies the number of instances to which the reservation benefit can be applied to. 1518 ReservationID *string `json:"reservationId,omitempty"` 1519 // SkuName - READ-ONLY; This is the ARM Sku name. It can be used to join with the serviceType field in additional info in usage records. 1520 SkuName *string `json:"skuName,omitempty"` 1521 // ReservedHours - READ-ONLY; This is the total hours reserved. E.g. if reservation for 1 instance was made on 1 PM, this will be 11 hours for that day and 24 hours from subsequent days 1522 ReservedHours *decimal.Decimal `json:"reservedHours,omitempty"` 1523 // UsageDate - READ-ONLY; Data corresponding to the utilization record. If the grain of data is monthly, it will be first day of month. 1524 UsageDate *date.Time `json:"usageDate,omitempty"` 1525 // UsedHours - READ-ONLY; Total used hours by the reservation 1526 UsedHours *decimal.Decimal `json:"usedHours,omitempty"` 1527 // MinUtilizationPercentage - READ-ONLY; This is the minimum hourly utilization in the usage time (day or month). E.g. if usage record corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was 10%, this field will return 10% for that day 1528 MinUtilizationPercentage *decimal.Decimal `json:"minUtilizationPercentage,omitempty"` 1529 // AvgUtilizationPercentage - READ-ONLY; This is average utilization for the entire time range. (day or month depending on the grain) 1530 AvgUtilizationPercentage *decimal.Decimal `json:"avgUtilizationPercentage,omitempty"` 1531 // MaxUtilizationPercentage - READ-ONLY; This is the maximum hourly utilization in the usage time (day or month). E.g. if usage record corresponds to 12/10/2017 and on that for hour 4 and 5, utilization was 100%, this field will return 100% for that day. 1532 MaxUtilizationPercentage *decimal.Decimal `json:"maxUtilizationPercentage,omitempty"` 1533} 1534 1535// Resource the Resource model definition. 1536type Resource struct { 1537 // ID - READ-ONLY; Resource Id. 1538 ID *string `json:"id,omitempty"` 1539 // Name - READ-ONLY; Resource name. 1540 Name *string `json:"name,omitempty"` 1541 // Type - READ-ONLY; Resource type. 1542 Type *string `json:"type,omitempty"` 1543 // Tags - READ-ONLY; Resource tags. 1544 Tags map[string]*string `json:"tags"` 1545} 1546 1547// MarshalJSON is the custom marshaler for Resource. 1548func (r Resource) MarshalJSON() ([]byte, error) { 1549 objectMap := make(map[string]interface{}) 1550 return json.Marshal(objectMap) 1551} 1552 1553// UsageDetail an usage detail resource. 1554type UsageDetail struct { 1555 *UsageDetailProperties `json:"properties,omitempty"` 1556 // ID - READ-ONLY; Resource Id. 1557 ID *string `json:"id,omitempty"` 1558 // Name - READ-ONLY; Resource name. 1559 Name *string `json:"name,omitempty"` 1560 // Type - READ-ONLY; Resource type. 1561 Type *string `json:"type,omitempty"` 1562 // Tags - READ-ONLY; Resource tags. 1563 Tags map[string]*string `json:"tags"` 1564} 1565 1566// MarshalJSON is the custom marshaler for UsageDetail. 1567func (ud UsageDetail) MarshalJSON() ([]byte, error) { 1568 objectMap := make(map[string]interface{}) 1569 if ud.UsageDetailProperties != nil { 1570 objectMap["properties"] = ud.UsageDetailProperties 1571 } 1572 return json.Marshal(objectMap) 1573} 1574 1575// UnmarshalJSON is the custom unmarshaler for UsageDetail struct. 1576func (ud *UsageDetail) UnmarshalJSON(body []byte) error { 1577 var m map[string]*json.RawMessage 1578 err := json.Unmarshal(body, &m) 1579 if err != nil { 1580 return err 1581 } 1582 for k, v := range m { 1583 switch k { 1584 case "properties": 1585 if v != nil { 1586 var usageDetailProperties UsageDetailProperties 1587 err = json.Unmarshal(*v, &usageDetailProperties) 1588 if err != nil { 1589 return err 1590 } 1591 ud.UsageDetailProperties = &usageDetailProperties 1592 } 1593 case "id": 1594 if v != nil { 1595 var ID string 1596 err = json.Unmarshal(*v, &ID) 1597 if err != nil { 1598 return err 1599 } 1600 ud.ID = &ID 1601 } 1602 case "name": 1603 if v != nil { 1604 var name string 1605 err = json.Unmarshal(*v, &name) 1606 if err != nil { 1607 return err 1608 } 1609 ud.Name = &name 1610 } 1611 case "type": 1612 if v != nil { 1613 var typeVar string 1614 err = json.Unmarshal(*v, &typeVar) 1615 if err != nil { 1616 return err 1617 } 1618 ud.Type = &typeVar 1619 } 1620 case "tags": 1621 if v != nil { 1622 var tags map[string]*string 1623 err = json.Unmarshal(*v, &tags) 1624 if err != nil { 1625 return err 1626 } 1627 ud.Tags = tags 1628 } 1629 } 1630 } 1631 1632 return nil 1633} 1634 1635// UsageDetailProperties the properties of the usage detail. 1636type UsageDetailProperties struct { 1637 // BillingPeriodID - READ-ONLY; The id of the billing period resource that the usage belongs to. 1638 BillingPeriodID *string `json:"billingPeriodId,omitempty"` 1639 // InvoiceID - READ-ONLY; The id of the invoice resource that the usage belongs to. 1640 InvoiceID *string `json:"invoiceId,omitempty"` 1641 // UsageStart - READ-ONLY; The start of the date time range covered by the usage detail. 1642 UsageStart *date.Time `json:"usageStart,omitempty"` 1643 // UsageEnd - READ-ONLY; The end of the date time range covered by the usage detail. 1644 UsageEnd *date.Time `json:"usageEnd,omitempty"` 1645 // InstanceName - READ-ONLY; The name of the resource instance that the usage is about. 1646 InstanceName *string `json:"instanceName,omitempty"` 1647 // InstanceID - READ-ONLY; The uri of the resource instance that the usage is about. 1648 InstanceID *string `json:"instanceId,omitempty"` 1649 // InstanceLocation - READ-ONLY; The location of the resource instance that the usage is about. 1650 InstanceLocation *string `json:"instanceLocation,omitempty"` 1651 // Currency - READ-ONLY; The ISO currency in which the meter is charged, for example, USD. 1652 Currency *string `json:"currency,omitempty"` 1653 // UsageQuantity - READ-ONLY; The quantity of usage. 1654 UsageQuantity *decimal.Decimal `json:"usageQuantity,omitempty"` 1655 // BillableQuantity - READ-ONLY; The billable usage quantity. 1656 BillableQuantity *decimal.Decimal `json:"billableQuantity,omitempty"` 1657 // PretaxCost - READ-ONLY; The amount of cost before tax. 1658 PretaxCost *decimal.Decimal `json:"pretaxCost,omitempty"` 1659 // IsEstimated - READ-ONLY; The estimated usage is subject to change. 1660 IsEstimated *bool `json:"isEstimated,omitempty"` 1661 // MeterID - READ-ONLY; The meter id. 1662 MeterID *string `json:"meterId,omitempty"` 1663 // MeterDetails - READ-ONLY; The details about the meter. By default this is not populated, unless it's specified in $expand. 1664 MeterDetails *MeterDetails `json:"meterDetails,omitempty"` 1665 // SubscriptionGUID - READ-ONLY; Subscription guid. 1666 SubscriptionGUID *string `json:"subscriptionGuid,omitempty"` 1667 // SubscriptionName - READ-ONLY; Subscription name. 1668 SubscriptionName *string `json:"subscriptionName,omitempty"` 1669 // AccountName - READ-ONLY; Account name. 1670 AccountName *string `json:"accountName,omitempty"` 1671 // DepartmentName - READ-ONLY; Department name. 1672 DepartmentName *string `json:"departmentName,omitempty"` 1673 // Product - READ-ONLY; Product name. 1674 Product *string `json:"product,omitempty"` 1675 // ConsumedService - READ-ONLY; Consumed service name. 1676 ConsumedService *string `json:"consumedService,omitempty"` 1677 // CostCenter - READ-ONLY; The cost center of this department if it is a department and a costcenter exists 1678 CostCenter *string `json:"costCenter,omitempty"` 1679 // AdditionalProperties - READ-ONLY; Additional details of this usage item. By default this is not populated, unless it's specified in $expand. 1680 AdditionalProperties *string `json:"additionalProperties,omitempty"` 1681} 1682 1683// UsageDetailsListResult result of listing usage details. It contains a list of available usage details in 1684// reverse chronological order by billing period. 1685type UsageDetailsListResult struct { 1686 autorest.Response `json:"-"` 1687 // Value - READ-ONLY; The list of usage details. 1688 Value *[]UsageDetail `json:"value,omitempty"` 1689 // NextLink - READ-ONLY; The link (url) to the next page of results. 1690 NextLink *string `json:"nextLink,omitempty"` 1691} 1692 1693// UsageDetailsListResultIterator provides access to a complete listing of UsageDetail values. 1694type UsageDetailsListResultIterator struct { 1695 i int 1696 page UsageDetailsListResultPage 1697} 1698 1699// NextWithContext advances to the next value. If there was an error making 1700// the request the iterator does not advance and the error is returned. 1701func (iter *UsageDetailsListResultIterator) NextWithContext(ctx context.Context) (err error) { 1702 if tracing.IsEnabled() { 1703 ctx = tracing.StartSpan(ctx, fqdn+"/UsageDetailsListResultIterator.NextWithContext") 1704 defer func() { 1705 sc := -1 1706 if iter.Response().Response.Response != nil { 1707 sc = iter.Response().Response.Response.StatusCode 1708 } 1709 tracing.EndSpan(ctx, sc, err) 1710 }() 1711 } 1712 iter.i++ 1713 if iter.i < len(iter.page.Values()) { 1714 return nil 1715 } 1716 err = iter.page.NextWithContext(ctx) 1717 if err != nil { 1718 iter.i-- 1719 return err 1720 } 1721 iter.i = 0 1722 return nil 1723} 1724 1725// Next advances to the next value. If there was an error making 1726// the request the iterator does not advance and the error is returned. 1727// Deprecated: Use NextWithContext() instead. 1728func (iter *UsageDetailsListResultIterator) Next() error { 1729 return iter.NextWithContext(context.Background()) 1730} 1731 1732// NotDone returns true if the enumeration should be started or is not yet complete. 1733func (iter UsageDetailsListResultIterator) NotDone() bool { 1734 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1735} 1736 1737// Response returns the raw server response from the last page request. 1738func (iter UsageDetailsListResultIterator) Response() UsageDetailsListResult { 1739 return iter.page.Response() 1740} 1741 1742// Value returns the current value or a zero-initialized value if the 1743// iterator has advanced beyond the end of the collection. 1744func (iter UsageDetailsListResultIterator) Value() UsageDetail { 1745 if !iter.page.NotDone() { 1746 return UsageDetail{} 1747 } 1748 return iter.page.Values()[iter.i] 1749} 1750 1751// Creates a new instance of the UsageDetailsListResultIterator type. 1752func NewUsageDetailsListResultIterator(page UsageDetailsListResultPage) UsageDetailsListResultIterator { 1753 return UsageDetailsListResultIterator{page: page} 1754} 1755 1756// IsEmpty returns true if the ListResult contains no values. 1757func (udlr UsageDetailsListResult) IsEmpty() bool { 1758 return udlr.Value == nil || len(*udlr.Value) == 0 1759} 1760 1761// hasNextLink returns true if the NextLink is not empty. 1762func (udlr UsageDetailsListResult) hasNextLink() bool { 1763 return udlr.NextLink != nil && len(*udlr.NextLink) != 0 1764} 1765 1766// usageDetailsListResultPreparer prepares a request to retrieve the next set of results. 1767// It returns nil if no more results exist. 1768func (udlr UsageDetailsListResult) usageDetailsListResultPreparer(ctx context.Context) (*http.Request, error) { 1769 if !udlr.hasNextLink() { 1770 return nil, nil 1771 } 1772 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1773 autorest.AsJSON(), 1774 autorest.AsGet(), 1775 autorest.WithBaseURL(to.String(udlr.NextLink))) 1776} 1777 1778// UsageDetailsListResultPage contains a page of UsageDetail values. 1779type UsageDetailsListResultPage struct { 1780 fn func(context.Context, UsageDetailsListResult) (UsageDetailsListResult, error) 1781 udlr UsageDetailsListResult 1782} 1783 1784// NextWithContext advances to the next page of values. If there was an error making 1785// the request the page does not advance and the error is returned. 1786func (page *UsageDetailsListResultPage) NextWithContext(ctx context.Context) (err error) { 1787 if tracing.IsEnabled() { 1788 ctx = tracing.StartSpan(ctx, fqdn+"/UsageDetailsListResultPage.NextWithContext") 1789 defer func() { 1790 sc := -1 1791 if page.Response().Response.Response != nil { 1792 sc = page.Response().Response.Response.StatusCode 1793 } 1794 tracing.EndSpan(ctx, sc, err) 1795 }() 1796 } 1797 for { 1798 next, err := page.fn(ctx, page.udlr) 1799 if err != nil { 1800 return err 1801 } 1802 page.udlr = next 1803 if !next.hasNextLink() || !next.IsEmpty() { 1804 break 1805 } 1806 } 1807 return nil 1808} 1809 1810// Next advances to the next page of values. If there was an error making 1811// the request the page does not advance and the error is returned. 1812// Deprecated: Use NextWithContext() instead. 1813func (page *UsageDetailsListResultPage) Next() error { 1814 return page.NextWithContext(context.Background()) 1815} 1816 1817// NotDone returns true if the page enumeration should be started or is not yet complete. 1818func (page UsageDetailsListResultPage) NotDone() bool { 1819 return !page.udlr.IsEmpty() 1820} 1821 1822// Response returns the raw server response from the last page request. 1823func (page UsageDetailsListResultPage) Response() UsageDetailsListResult { 1824 return page.udlr 1825} 1826 1827// Values returns the slice of values for the current page or nil if there are no values. 1828func (page UsageDetailsListResultPage) Values() []UsageDetail { 1829 if page.udlr.IsEmpty() { 1830 return nil 1831 } 1832 return *page.udlr.Value 1833} 1834 1835// Creates a new instance of the UsageDetailsListResultPage type. 1836func NewUsageDetailsListResultPage(cur UsageDetailsListResult, getNextPage func(context.Context, UsageDetailsListResult) (UsageDetailsListResult, error)) UsageDetailsListResultPage { 1837 return UsageDetailsListResultPage{ 1838 fn: getNextPage, 1839 udlr: cur, 1840 } 1841} 1842