1package commerce 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/satori/go.uuid" 28 "github.com/shopspring/decimal" 29 "net/http" 30) 31 32// The package's fully qualified name. 33const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/commerce/mgmt/2015-06-01-preview/commerce" 34 35// AggregationGranularity enumerates the values for aggregation granularity. 36type AggregationGranularity string 37 38const ( 39 // Daily ... 40 Daily AggregationGranularity = "Daily" 41 // Hourly ... 42 Hourly AggregationGranularity = "Hourly" 43) 44 45// PossibleAggregationGranularityValues returns an array of possible values for the AggregationGranularity const type. 46func PossibleAggregationGranularityValues() []AggregationGranularity { 47 return []AggregationGranularity{Daily, Hourly} 48} 49 50// Name enumerates the values for name. 51type Name string 52 53const ( 54 // NameMonetaryCommitment ... 55 NameMonetaryCommitment Name = "Monetary Commitment" 56 // NameMonetaryCredit ... 57 NameMonetaryCredit Name = "Monetary Credit" 58 // NameOfferTermInfo ... 59 NameOfferTermInfo Name = "OfferTermInfo" 60 // NameRecurringCharge ... 61 NameRecurringCharge Name = "Recurring Charge" 62) 63 64// PossibleNameValues returns an array of possible values for the Name const type. 65func PossibleNameValues() []Name { 66 return []Name{NameMonetaryCommitment, NameMonetaryCredit, NameOfferTermInfo, NameRecurringCharge} 67} 68 69// ErrorResponse describes the format of Error response. 70type ErrorResponse struct { 71 // Code - Error code 72 Code *string `json:"code,omitempty"` 73 // Message - Error message indicating why the operation failed. 74 Message *string `json:"message,omitempty"` 75} 76 77// InfoField key-value pairs of instance details in the legacy format. 78type InfoField struct { 79 // Project - Identifies the name of the instance provisioned by the user. 80 Project *string `json:"project,omitempty"` 81} 82 83// MeterInfo detailed information about the meter. 84type MeterInfo struct { 85 // MeterID - The unique identifier of the resource. 86 MeterID *uuid.UUID `json:"MeterId,omitempty"` 87 // MeterName - The name of the meter, within the given meter category 88 MeterName *string `json:"MeterName,omitempty"` 89 // MeterCategory - The category of the meter, e.g., 'Cloud services', 'Networking', etc.. 90 MeterCategory *string `json:"MeterCategory,omitempty"` 91 // MeterSubCategory - The subcategory of the meter, e.g., 'A6 Cloud services', 'ExpressRoute (IXP)', etc.. 92 MeterSubCategory *string `json:"MeterSubCategory,omitempty"` 93 // Unit - The unit in which the meter consumption is charged, e.g., 'Hours', 'GB', etc. 94 Unit *string `json:"Unit,omitempty"` 95 // MeterTags - Provides additional meter data. 'Third Party' indicates a meter with no discount. Blanks indicate First Party. 96 MeterTags *[]string `json:"MeterTags,omitempty"` 97 // MeterRegion - The region in which the Azure service is available. 98 MeterRegion *string `json:"MeterRegion,omitempty"` 99 // MeterRates - The list of key/value pairs for the meter rates, in the format 'key':'value' where key = the meter quantity, and value = the corresponding price 100 MeterRates map[string]*float64 `json:"MeterRates"` 101 // EffectiveDate - Indicates the date from which the meter rate is effective. 102 EffectiveDate *date.Time `json:"EffectiveDate,omitempty"` 103 // IncludedQuantity - The resource quantity that is included in the offer at no cost. Consumption beyond this quantity will be charged. 104 IncludedQuantity *float64 `json:"IncludedQuantity,omitempty"` 105} 106 107// MarshalJSON is the custom marshaler for MeterInfo. 108func (mi MeterInfo) MarshalJSON() ([]byte, error) { 109 objectMap := make(map[string]interface{}) 110 if mi.MeterID != nil { 111 objectMap["MeterId"] = mi.MeterID 112 } 113 if mi.MeterName != nil { 114 objectMap["MeterName"] = mi.MeterName 115 } 116 if mi.MeterCategory != nil { 117 objectMap["MeterCategory"] = mi.MeterCategory 118 } 119 if mi.MeterSubCategory != nil { 120 objectMap["MeterSubCategory"] = mi.MeterSubCategory 121 } 122 if mi.Unit != nil { 123 objectMap["Unit"] = mi.Unit 124 } 125 if mi.MeterTags != nil { 126 objectMap["MeterTags"] = mi.MeterTags 127 } 128 if mi.MeterRegion != nil { 129 objectMap["MeterRegion"] = mi.MeterRegion 130 } 131 if mi.MeterRates != nil { 132 objectMap["MeterRates"] = mi.MeterRates 133 } 134 if mi.EffectiveDate != nil { 135 objectMap["EffectiveDate"] = mi.EffectiveDate 136 } 137 if mi.IncludedQuantity != nil { 138 objectMap["IncludedQuantity"] = mi.IncludedQuantity 139 } 140 return json.Marshal(objectMap) 141} 142 143// MonetaryCommitment indicates that a monetary commitment is required for this offer 144type MonetaryCommitment struct { 145 // TieredDiscount - The list of key/value pairs for the tiered meter rates, in the format 'key':'value' where key = price, and value = the corresponding discount percentage. This field is used only by offer terms of type 'Monetary Commitment'. 146 TieredDiscount map[string]*decimal.Decimal `json:"TieredDiscount"` 147 // ExcludedMeterIds - An array of meter ids that are excluded from the given offer terms. 148 ExcludedMeterIds *[]uuid.UUID `json:"ExcludedMeterIds,omitempty"` 149 // EffectiveDate - Indicates the date from which the offer term is effective. 150 EffectiveDate *date.Time `json:"EffectiveDate,omitempty"` 151 // Name - Possible values include: 'NameOfferTermInfo', 'NameMonetaryCredit', 'NameMonetaryCommitment', 'NameRecurringCharge' 152 Name Name `json:"Name,omitempty"` 153} 154 155// MarshalJSON is the custom marshaler for MonetaryCommitment. 156func (mc MonetaryCommitment) MarshalJSON() ([]byte, error) { 157 mc.Name = NameMonetaryCommitment 158 objectMap := make(map[string]interface{}) 159 if mc.TieredDiscount != nil { 160 objectMap["TieredDiscount"] = mc.TieredDiscount 161 } 162 if mc.ExcludedMeterIds != nil { 163 objectMap["ExcludedMeterIds"] = mc.ExcludedMeterIds 164 } 165 if mc.EffectiveDate != nil { 166 objectMap["EffectiveDate"] = mc.EffectiveDate 167 } 168 if mc.Name != "" { 169 objectMap["Name"] = mc.Name 170 } 171 return json.Marshal(objectMap) 172} 173 174// AsMonetaryCredit is the BasicOfferTermInfo implementation for MonetaryCommitment. 175func (mc MonetaryCommitment) AsMonetaryCredit() (*MonetaryCredit, bool) { 176 return nil, false 177} 178 179// AsMonetaryCommitment is the BasicOfferTermInfo implementation for MonetaryCommitment. 180func (mc MonetaryCommitment) AsMonetaryCommitment() (*MonetaryCommitment, bool) { 181 return &mc, true 182} 183 184// AsRecurringCharge is the BasicOfferTermInfo implementation for MonetaryCommitment. 185func (mc MonetaryCommitment) AsRecurringCharge() (*RecurringCharge, bool) { 186 return nil, false 187} 188 189// AsOfferTermInfo is the BasicOfferTermInfo implementation for MonetaryCommitment. 190func (mc MonetaryCommitment) AsOfferTermInfo() (*OfferTermInfo, bool) { 191 return nil, false 192} 193 194// AsBasicOfferTermInfo is the BasicOfferTermInfo implementation for MonetaryCommitment. 195func (mc MonetaryCommitment) AsBasicOfferTermInfo() (BasicOfferTermInfo, bool) { 196 return &mc, true 197} 198 199// MonetaryCredit indicates that this is a monetary credit offer. 200type MonetaryCredit struct { 201 // Credit - The amount of credit provided under the terms of the given offer level. 202 Credit *decimal.Decimal `json:"Credit,omitempty"` 203 // ExcludedMeterIds - An array of meter ids that are excluded from the given offer terms. 204 ExcludedMeterIds *[]uuid.UUID `json:"ExcludedMeterIds,omitempty"` 205 // EffectiveDate - Indicates the date from which the offer term is effective. 206 EffectiveDate *date.Time `json:"EffectiveDate,omitempty"` 207 // Name - Possible values include: 'NameOfferTermInfo', 'NameMonetaryCredit', 'NameMonetaryCommitment', 'NameRecurringCharge' 208 Name Name `json:"Name,omitempty"` 209} 210 211// MarshalJSON is the custom marshaler for MonetaryCredit. 212func (mc MonetaryCredit) MarshalJSON() ([]byte, error) { 213 mc.Name = NameMonetaryCredit 214 objectMap := make(map[string]interface{}) 215 if mc.Credit != nil { 216 objectMap["Credit"] = mc.Credit 217 } 218 if mc.ExcludedMeterIds != nil { 219 objectMap["ExcludedMeterIds"] = mc.ExcludedMeterIds 220 } 221 if mc.EffectiveDate != nil { 222 objectMap["EffectiveDate"] = mc.EffectiveDate 223 } 224 if mc.Name != "" { 225 objectMap["Name"] = mc.Name 226 } 227 return json.Marshal(objectMap) 228} 229 230// AsMonetaryCredit is the BasicOfferTermInfo implementation for MonetaryCredit. 231func (mc MonetaryCredit) AsMonetaryCredit() (*MonetaryCredit, bool) { 232 return &mc, true 233} 234 235// AsMonetaryCommitment is the BasicOfferTermInfo implementation for MonetaryCredit. 236func (mc MonetaryCredit) AsMonetaryCommitment() (*MonetaryCommitment, bool) { 237 return nil, false 238} 239 240// AsRecurringCharge is the BasicOfferTermInfo implementation for MonetaryCredit. 241func (mc MonetaryCredit) AsRecurringCharge() (*RecurringCharge, bool) { 242 return nil, false 243} 244 245// AsOfferTermInfo is the BasicOfferTermInfo implementation for MonetaryCredit. 246func (mc MonetaryCredit) AsOfferTermInfo() (*OfferTermInfo, bool) { 247 return nil, false 248} 249 250// AsBasicOfferTermInfo is the BasicOfferTermInfo implementation for MonetaryCredit. 251func (mc MonetaryCredit) AsBasicOfferTermInfo() (BasicOfferTermInfo, bool) { 252 return &mc, true 253} 254 255// BasicOfferTermInfo describes the offer term. 256type BasicOfferTermInfo interface { 257 AsMonetaryCredit() (*MonetaryCredit, bool) 258 AsMonetaryCommitment() (*MonetaryCommitment, bool) 259 AsRecurringCharge() (*RecurringCharge, bool) 260 AsOfferTermInfo() (*OfferTermInfo, bool) 261} 262 263// OfferTermInfo describes the offer term. 264type OfferTermInfo struct { 265 // EffectiveDate - Indicates the date from which the offer term is effective. 266 EffectiveDate *date.Time `json:"EffectiveDate,omitempty"` 267 // Name - Possible values include: 'NameOfferTermInfo', 'NameMonetaryCredit', 'NameMonetaryCommitment', 'NameRecurringCharge' 268 Name Name `json:"Name,omitempty"` 269} 270 271func unmarshalBasicOfferTermInfo(body []byte) (BasicOfferTermInfo, error) { 272 var m map[string]interface{} 273 err := json.Unmarshal(body, &m) 274 if err != nil { 275 return nil, err 276 } 277 278 switch m["Name"] { 279 case string(NameMonetaryCredit): 280 var mc MonetaryCredit 281 err := json.Unmarshal(body, &mc) 282 return mc, err 283 case string(NameMonetaryCommitment): 284 var mc MonetaryCommitment 285 err := json.Unmarshal(body, &mc) 286 return mc, err 287 case string(NameRecurringCharge): 288 var rc RecurringCharge 289 err := json.Unmarshal(body, &rc) 290 return rc, err 291 default: 292 var oti OfferTermInfo 293 err := json.Unmarshal(body, &oti) 294 return oti, err 295 } 296} 297func unmarshalBasicOfferTermInfoArray(body []byte) ([]BasicOfferTermInfo, error) { 298 var rawMessages []*json.RawMessage 299 err := json.Unmarshal(body, &rawMessages) 300 if err != nil { 301 return nil, err 302 } 303 304 otiArray := make([]BasicOfferTermInfo, len(rawMessages)) 305 306 for index, rawMessage := range rawMessages { 307 oti, err := unmarshalBasicOfferTermInfo(*rawMessage) 308 if err != nil { 309 return nil, err 310 } 311 otiArray[index] = oti 312 } 313 return otiArray, nil 314} 315 316// MarshalJSON is the custom marshaler for OfferTermInfo. 317func (oti OfferTermInfo) MarshalJSON() ([]byte, error) { 318 oti.Name = NameOfferTermInfo 319 objectMap := make(map[string]interface{}) 320 if oti.EffectiveDate != nil { 321 objectMap["EffectiveDate"] = oti.EffectiveDate 322 } 323 if oti.Name != "" { 324 objectMap["Name"] = oti.Name 325 } 326 return json.Marshal(objectMap) 327} 328 329// AsMonetaryCredit is the BasicOfferTermInfo implementation for OfferTermInfo. 330func (oti OfferTermInfo) AsMonetaryCredit() (*MonetaryCredit, bool) { 331 return nil, false 332} 333 334// AsMonetaryCommitment is the BasicOfferTermInfo implementation for OfferTermInfo. 335func (oti OfferTermInfo) AsMonetaryCommitment() (*MonetaryCommitment, bool) { 336 return nil, false 337} 338 339// AsRecurringCharge is the BasicOfferTermInfo implementation for OfferTermInfo. 340func (oti OfferTermInfo) AsRecurringCharge() (*RecurringCharge, bool) { 341 return nil, false 342} 343 344// AsOfferTermInfo is the BasicOfferTermInfo implementation for OfferTermInfo. 345func (oti OfferTermInfo) AsOfferTermInfo() (*OfferTermInfo, bool) { 346 return &oti, true 347} 348 349// AsBasicOfferTermInfo is the BasicOfferTermInfo implementation for OfferTermInfo. 350func (oti OfferTermInfo) AsBasicOfferTermInfo() (BasicOfferTermInfo, bool) { 351 return &oti, true 352} 353 354// RateCardQueryParameters parameters that are used in the odata $filter query parameter for providing 355// RateCard information. 356type RateCardQueryParameters struct { 357 // OfferDurableID - The Offer ID parameter consists of the 'MS-AZR-' prefix, plus the Offer ID number (e.g., MS-AZR-0026P). See https://azure.microsoft.com/en-us/support/legal/offer-details/ for more information on the list of available Offer IDs, country/region availability, and billing currency. 358 OfferDurableID *string `json:"OfferDurableId,omitempty"` 359 // Currency - The currency in which the rates need to be provided. 360 Currency *string `json:"Currency,omitempty"` 361 // Locale - The culture in which the resource metadata needs to be localized. 362 Locale *string `json:"Locale,omitempty"` 363 // RegionInfo - 2 letter ISO code where the offer was purchased. 364 RegionInfo *string `json:"RegionInfo,omitempty"` 365} 366 367// RecurringCharge indicates a recurring charge is present for this offer. 368type RecurringCharge struct { 369 // RecurringCharge - The amount of recurring charge as per the offer term. 370 RecurringCharge *int32 `json:"RecurringCharge,omitempty"` 371 // EffectiveDate - Indicates the date from which the offer term is effective. 372 EffectiveDate *date.Time `json:"EffectiveDate,omitempty"` 373 // Name - Possible values include: 'NameOfferTermInfo', 'NameMonetaryCredit', 'NameMonetaryCommitment', 'NameRecurringCharge' 374 Name Name `json:"Name,omitempty"` 375} 376 377// MarshalJSON is the custom marshaler for RecurringCharge. 378func (rc RecurringCharge) MarshalJSON() ([]byte, error) { 379 rc.Name = NameRecurringCharge 380 objectMap := make(map[string]interface{}) 381 if rc.RecurringCharge != nil { 382 objectMap["RecurringCharge"] = rc.RecurringCharge 383 } 384 if rc.EffectiveDate != nil { 385 objectMap["EffectiveDate"] = rc.EffectiveDate 386 } 387 if rc.Name != "" { 388 objectMap["Name"] = rc.Name 389 } 390 return json.Marshal(objectMap) 391} 392 393// AsMonetaryCredit is the BasicOfferTermInfo implementation for RecurringCharge. 394func (rc RecurringCharge) AsMonetaryCredit() (*MonetaryCredit, bool) { 395 return nil, false 396} 397 398// AsMonetaryCommitment is the BasicOfferTermInfo implementation for RecurringCharge. 399func (rc RecurringCharge) AsMonetaryCommitment() (*MonetaryCommitment, bool) { 400 return nil, false 401} 402 403// AsRecurringCharge is the BasicOfferTermInfo implementation for RecurringCharge. 404func (rc RecurringCharge) AsRecurringCharge() (*RecurringCharge, bool) { 405 return &rc, true 406} 407 408// AsOfferTermInfo is the BasicOfferTermInfo implementation for RecurringCharge. 409func (rc RecurringCharge) AsOfferTermInfo() (*OfferTermInfo, bool) { 410 return nil, false 411} 412 413// AsBasicOfferTermInfo is the BasicOfferTermInfo implementation for RecurringCharge. 414func (rc RecurringCharge) AsBasicOfferTermInfo() (BasicOfferTermInfo, bool) { 415 return &rc, true 416} 417 418// ResourceRateCardInfo price and Metadata information for resources 419type ResourceRateCardInfo struct { 420 autorest.Response `json:"-"` 421 // Currency - The currency in which the rates are provided. 422 Currency *string `json:"Currency,omitempty"` 423 // Locale - The culture in which the resource information is localized. 424 Locale *string `json:"Locale,omitempty"` 425 // IsTaxIncluded - All rates are pretax, so this will always be returned as 'false'. 426 IsTaxIncluded *bool `json:"IsTaxIncluded,omitempty"` 427 // OfferTerms - A list of offer terms. 428 OfferTerms *[]BasicOfferTermInfo `json:"OfferTerms,omitempty"` 429 // Meters - A list of meters. 430 Meters *[]MeterInfo `json:"Meters,omitempty"` 431} 432 433// UnmarshalJSON is the custom unmarshaler for ResourceRateCardInfo struct. 434func (rrci *ResourceRateCardInfo) UnmarshalJSON(body []byte) error { 435 var m map[string]*json.RawMessage 436 err := json.Unmarshal(body, &m) 437 if err != nil { 438 return err 439 } 440 for k, v := range m { 441 switch k { 442 case "Currency": 443 if v != nil { 444 var currency string 445 err = json.Unmarshal(*v, ¤cy) 446 if err != nil { 447 return err 448 } 449 rrci.Currency = ¤cy 450 } 451 case "Locale": 452 if v != nil { 453 var locale string 454 err = json.Unmarshal(*v, &locale) 455 if err != nil { 456 return err 457 } 458 rrci.Locale = &locale 459 } 460 case "IsTaxIncluded": 461 if v != nil { 462 var isTaxIncluded bool 463 err = json.Unmarshal(*v, &isTaxIncluded) 464 if err != nil { 465 return err 466 } 467 rrci.IsTaxIncluded = &isTaxIncluded 468 } 469 case "OfferTerms": 470 if v != nil { 471 offerTerms, err := unmarshalBasicOfferTermInfoArray(*v) 472 if err != nil { 473 return err 474 } 475 rrci.OfferTerms = &offerTerms 476 } 477 case "Meters": 478 if v != nil { 479 var meters []MeterInfo 480 err = json.Unmarshal(*v, &meters) 481 if err != nil { 482 return err 483 } 484 rrci.Meters = &meters 485 } 486 } 487 } 488 489 return nil 490} 491 492// UsageAggregation describes the usageAggregation. 493type UsageAggregation struct { 494 // ID - Unique Id for the usage aggregate. 495 ID *string `json:"id,omitempty"` 496 // Name - Name of the usage aggregate. 497 Name *string `json:"name,omitempty"` 498 // Type - Type of the resource being returned. 499 Type *string `json:"type,omitempty"` 500 // UsageSample - Usage data. 501 *UsageSample `json:"properties,omitempty"` 502} 503 504// MarshalJSON is the custom marshaler for UsageAggregation. 505func (ua UsageAggregation) MarshalJSON() ([]byte, error) { 506 objectMap := make(map[string]interface{}) 507 if ua.ID != nil { 508 objectMap["id"] = ua.ID 509 } 510 if ua.Name != nil { 511 objectMap["name"] = ua.Name 512 } 513 if ua.Type != nil { 514 objectMap["type"] = ua.Type 515 } 516 if ua.UsageSample != nil { 517 objectMap["properties"] = ua.UsageSample 518 } 519 return json.Marshal(objectMap) 520} 521 522// UnmarshalJSON is the custom unmarshaler for UsageAggregation struct. 523func (ua *UsageAggregation) UnmarshalJSON(body []byte) error { 524 var m map[string]*json.RawMessage 525 err := json.Unmarshal(body, &m) 526 if err != nil { 527 return err 528 } 529 for k, v := range m { 530 switch k { 531 case "id": 532 if v != nil { 533 var ID string 534 err = json.Unmarshal(*v, &ID) 535 if err != nil { 536 return err 537 } 538 ua.ID = &ID 539 } 540 case "name": 541 if v != nil { 542 var name string 543 err = json.Unmarshal(*v, &name) 544 if err != nil { 545 return err 546 } 547 ua.Name = &name 548 } 549 case "type": 550 if v != nil { 551 var typeVar string 552 err = json.Unmarshal(*v, &typeVar) 553 if err != nil { 554 return err 555 } 556 ua.Type = &typeVar 557 } 558 case "properties": 559 if v != nil { 560 var usageSample UsageSample 561 err = json.Unmarshal(*v, &usageSample) 562 if err != nil { 563 return err 564 } 565 ua.UsageSample = &usageSample 566 } 567 } 568 } 569 570 return nil 571} 572 573// UsageAggregationListResult the Get UsageAggregates operation response. 574type UsageAggregationListResult struct { 575 autorest.Response `json:"-"` 576 // Value - Gets or sets details for the requested aggregation. 577 Value *[]UsageAggregation `json:"value,omitempty"` 578 // NextLink - Gets or sets the link to the next set of results. 579 NextLink *string `json:"nextLink,omitempty"` 580} 581 582// UsageAggregationListResultIterator provides access to a complete listing of UsageAggregation values. 583type UsageAggregationListResultIterator struct { 584 i int 585 page UsageAggregationListResultPage 586} 587 588// NextWithContext advances to the next value. If there was an error making 589// the request the iterator does not advance and the error is returned. 590func (iter *UsageAggregationListResultIterator) NextWithContext(ctx context.Context) (err error) { 591 if tracing.IsEnabled() { 592 ctx = tracing.StartSpan(ctx, fqdn+"/UsageAggregationListResultIterator.NextWithContext") 593 defer func() { 594 sc := -1 595 if iter.Response().Response.Response != nil { 596 sc = iter.Response().Response.Response.StatusCode 597 } 598 tracing.EndSpan(ctx, sc, err) 599 }() 600 } 601 iter.i++ 602 if iter.i < len(iter.page.Values()) { 603 return nil 604 } 605 err = iter.page.NextWithContext(ctx) 606 if err != nil { 607 iter.i-- 608 return err 609 } 610 iter.i = 0 611 return nil 612} 613 614// Next advances to the next value. If there was an error making 615// the request the iterator does not advance and the error is returned. 616// Deprecated: Use NextWithContext() instead. 617func (iter *UsageAggregationListResultIterator) Next() error { 618 return iter.NextWithContext(context.Background()) 619} 620 621// NotDone returns true if the enumeration should be started or is not yet complete. 622func (iter UsageAggregationListResultIterator) NotDone() bool { 623 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 624} 625 626// Response returns the raw server response from the last page request. 627func (iter UsageAggregationListResultIterator) Response() UsageAggregationListResult { 628 return iter.page.Response() 629} 630 631// Value returns the current value or a zero-initialized value if the 632// iterator has advanced beyond the end of the collection. 633func (iter UsageAggregationListResultIterator) Value() UsageAggregation { 634 if !iter.page.NotDone() { 635 return UsageAggregation{} 636 } 637 return iter.page.Values()[iter.i] 638} 639 640// Creates a new instance of the UsageAggregationListResultIterator type. 641func NewUsageAggregationListResultIterator(page UsageAggregationListResultPage) UsageAggregationListResultIterator { 642 return UsageAggregationListResultIterator{page: page} 643} 644 645// IsEmpty returns true if the ListResult contains no values. 646func (ualr UsageAggregationListResult) IsEmpty() bool { 647 return ualr.Value == nil || len(*ualr.Value) == 0 648} 649 650// usageAggregationListResultPreparer prepares a request to retrieve the next set of results. 651// It returns nil if no more results exist. 652func (ualr UsageAggregationListResult) usageAggregationListResultPreparer(ctx context.Context) (*http.Request, error) { 653 if ualr.NextLink == nil || len(to.String(ualr.NextLink)) < 1 { 654 return nil, nil 655 } 656 return autorest.Prepare((&http.Request{}).WithContext(ctx), 657 autorest.AsJSON(), 658 autorest.AsGet(), 659 autorest.WithBaseURL(to.String(ualr.NextLink))) 660} 661 662// UsageAggregationListResultPage contains a page of UsageAggregation values. 663type UsageAggregationListResultPage struct { 664 fn func(context.Context, UsageAggregationListResult) (UsageAggregationListResult, error) 665 ualr UsageAggregationListResult 666} 667 668// NextWithContext advances to the next page of values. If there was an error making 669// the request the page does not advance and the error is returned. 670func (page *UsageAggregationListResultPage) NextWithContext(ctx context.Context) (err error) { 671 if tracing.IsEnabled() { 672 ctx = tracing.StartSpan(ctx, fqdn+"/UsageAggregationListResultPage.NextWithContext") 673 defer func() { 674 sc := -1 675 if page.Response().Response.Response != nil { 676 sc = page.Response().Response.Response.StatusCode 677 } 678 tracing.EndSpan(ctx, sc, err) 679 }() 680 } 681 next, err := page.fn(ctx, page.ualr) 682 if err != nil { 683 return err 684 } 685 page.ualr = next 686 return nil 687} 688 689// Next advances to the next page of values. If there was an error making 690// the request the page does not advance and the error is returned. 691// Deprecated: Use NextWithContext() instead. 692func (page *UsageAggregationListResultPage) Next() error { 693 return page.NextWithContext(context.Background()) 694} 695 696// NotDone returns true if the page enumeration should be started or is not yet complete. 697func (page UsageAggregationListResultPage) NotDone() bool { 698 return !page.ualr.IsEmpty() 699} 700 701// Response returns the raw server response from the last page request. 702func (page UsageAggregationListResultPage) Response() UsageAggregationListResult { 703 return page.ualr 704} 705 706// Values returns the slice of values for the current page or nil if there are no values. 707func (page UsageAggregationListResultPage) Values() []UsageAggregation { 708 if page.ualr.IsEmpty() { 709 return nil 710 } 711 return *page.ualr.Value 712} 713 714// Creates a new instance of the UsageAggregationListResultPage type. 715func NewUsageAggregationListResultPage(getNextPage func(context.Context, UsageAggregationListResult) (UsageAggregationListResult, error)) UsageAggregationListResultPage { 716 return UsageAggregationListResultPage{fn: getNextPage} 717} 718 719// UsageSample describes a sample of the usageAggregation. 720type UsageSample struct { 721 // SubscriptionID - The subscription identifier for the Azure user. 722 SubscriptionID *uuid.UUID `json:"subscriptionId,omitempty"` 723 // MeterID - Unique ID for the resource that was consumed (aka ResourceID). 724 MeterID *string `json:"meterId,omitempty"` 725 // UsageStartTime - UTC start time for the usage bucket to which this usage aggregate belongs. 726 UsageStartTime *date.Time `json:"usageStartTime,omitempty"` 727 // UsageEndTime - UTC end time for the usage bucket to which this usage aggregate belongs. 728 UsageEndTime *date.Time `json:"usageEndTime,omitempty"` 729 // Quantity - The amount of the resource consumption that occurred in this time frame. 730 Quantity *float64 `json:"quantity,omitempty"` 731 // Unit - The unit in which the usage for this resource is being counted, e.g. Hours, GB. 732 Unit *string `json:"unit,omitempty"` 733 // MeterName - Friendly name of the resource being consumed. 734 MeterName *string `json:"meterName,omitempty"` 735 // MeterCategory - Category of the consumed resource. 736 MeterCategory *string `json:"meterCategory,omitempty"` 737 // MeterSubCategory - Sub-category of the consumed resource. 738 MeterSubCategory *string `json:"meterSubCategory,omitempty"` 739 // MeterRegion - Region of the meterId used for billing purposes 740 MeterRegion *string `json:"meterRegion,omitempty"` 741 // InfoFields - Key-value pairs of instance details (legacy format). 742 InfoFields *InfoField `json:"infoFields,omitempty"` 743 // InstanceData - Key-value pairs of instance details represented as a string. 744 InstanceData *string `json:"instanceData,omitempty"` 745} 746