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