1package costmanagement
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	"net/http"
28)
29
30// The package's fully qualified name.
31const fqdn = "github.com/Azure/azure-sdk-for-go/services/costmanagement/mgmt/2019-01-01/costmanagement"
32
33// ExecutionStatus enumerates the values for execution status.
34type ExecutionStatus string
35
36const (
37	// Completed ...
38	Completed ExecutionStatus = "Completed"
39	// DataNotAvailable ...
40	DataNotAvailable ExecutionStatus = "DataNotAvailable"
41	// Failed ...
42	Failed ExecutionStatus = "Failed"
43	// InProgress ...
44	InProgress ExecutionStatus = "InProgress"
45	// NewDataNotAvailable ...
46	NewDataNotAvailable ExecutionStatus = "NewDataNotAvailable"
47	// Queued ...
48	Queued ExecutionStatus = "Queued"
49	// Timeout ...
50	Timeout ExecutionStatus = "Timeout"
51)
52
53// PossibleExecutionStatusValues returns an array of possible values for the ExecutionStatus const type.
54func PossibleExecutionStatusValues() []ExecutionStatus {
55	return []ExecutionStatus{Completed, DataNotAvailable, Failed, InProgress, NewDataNotAvailable, Queued, Timeout}
56}
57
58// ExecutionType enumerates the values for execution type.
59type ExecutionType string
60
61const (
62	// OnDemand ...
63	OnDemand ExecutionType = "OnDemand"
64	// Scheduled ...
65	Scheduled ExecutionType = "Scheduled"
66)
67
68// PossibleExecutionTypeValues returns an array of possible values for the ExecutionType const type.
69func PossibleExecutionTypeValues() []ExecutionType {
70	return []ExecutionType{OnDemand, Scheduled}
71}
72
73// FormatType enumerates the values for format type.
74type FormatType string
75
76const (
77	// Csv ...
78	Csv FormatType = "Csv"
79)
80
81// PossibleFormatTypeValues returns an array of possible values for the FormatType const type.
82func PossibleFormatTypeValues() []FormatType {
83	return []FormatType{Csv}
84}
85
86// GranularityType enumerates the values for granularity type.
87type GranularityType string
88
89const (
90	// Daily ...
91	Daily GranularityType = "Daily"
92	// Hourly ...
93	Hourly GranularityType = "Hourly"
94)
95
96// PossibleGranularityTypeValues returns an array of possible values for the GranularityType const type.
97func PossibleGranularityTypeValues() []GranularityType {
98	return []GranularityType{Daily, Hourly}
99}
100
101// QueryColumnType enumerates the values for query column type.
102type QueryColumnType string
103
104const (
105	// QueryColumnTypeDimension ...
106	QueryColumnTypeDimension QueryColumnType = "Dimension"
107	// QueryColumnTypeTag ...
108	QueryColumnTypeTag QueryColumnType = "Tag"
109)
110
111// PossibleQueryColumnTypeValues returns an array of possible values for the QueryColumnType const type.
112func PossibleQueryColumnTypeValues() []QueryColumnType {
113	return []QueryColumnType{QueryColumnTypeDimension, QueryColumnTypeTag}
114}
115
116// RecurrenceType enumerates the values for recurrence type.
117type RecurrenceType string
118
119const (
120	// RecurrenceTypeAnnually ...
121	RecurrenceTypeAnnually RecurrenceType = "Annually"
122	// RecurrenceTypeDaily ...
123	RecurrenceTypeDaily RecurrenceType = "Daily"
124	// RecurrenceTypeMonthly ...
125	RecurrenceTypeMonthly RecurrenceType = "Monthly"
126	// RecurrenceTypeWeekly ...
127	RecurrenceTypeWeekly RecurrenceType = "Weekly"
128)
129
130// PossibleRecurrenceTypeValues returns an array of possible values for the RecurrenceType const type.
131func PossibleRecurrenceTypeValues() []RecurrenceType {
132	return []RecurrenceType{RecurrenceTypeAnnually, RecurrenceTypeDaily, RecurrenceTypeMonthly, RecurrenceTypeWeekly}
133}
134
135// SortDirection enumerates the values for sort direction.
136type SortDirection string
137
138const (
139	// Ascending ...
140	Ascending SortDirection = "Ascending"
141	// Descending ...
142	Descending SortDirection = "Descending"
143)
144
145// PossibleSortDirectionValues returns an array of possible values for the SortDirection const type.
146func PossibleSortDirectionValues() []SortDirection {
147	return []SortDirection{Ascending, Descending}
148}
149
150// StatusType enumerates the values for status type.
151type StatusType string
152
153const (
154	// Active ...
155	Active StatusType = "Active"
156	// Inactive ...
157	Inactive StatusType = "Inactive"
158)
159
160// PossibleStatusTypeValues returns an array of possible values for the StatusType const type.
161func PossibleStatusTypeValues() []StatusType {
162	return []StatusType{Active, Inactive}
163}
164
165// TimeframeType enumerates the values for timeframe type.
166type TimeframeType string
167
168const (
169	// BillingMonthToDate ...
170	BillingMonthToDate TimeframeType = "BillingMonthToDate"
171	// Custom ...
172	Custom TimeframeType = "Custom"
173	// MonthToDate ...
174	MonthToDate TimeframeType = "MonthToDate"
175	// TheLastBillingMonth ...
176	TheLastBillingMonth TimeframeType = "TheLastBillingMonth"
177	// TheLastMonth ...
178	TheLastMonth TimeframeType = "TheLastMonth"
179	// TheLastWeek ...
180	TheLastWeek TimeframeType = "TheLastWeek"
181	// TheLastYear ...
182	TheLastYear TimeframeType = "TheLastYear"
183	// WeekToDate ...
184	WeekToDate TimeframeType = "WeekToDate"
185	// YearToDate ...
186	YearToDate TimeframeType = "YearToDate"
187)
188
189// PossibleTimeframeTypeValues returns an array of possible values for the TimeframeType const type.
190func PossibleTimeframeTypeValues() []TimeframeType {
191	return []TimeframeType{BillingMonthToDate, Custom, MonthToDate, TheLastBillingMonth, TheLastMonth, TheLastWeek, TheLastYear, WeekToDate, YearToDate}
192}
193
194// CommonExportProperties the common properties of the export.
195type CommonExportProperties struct {
196	// Format - The format of the export being delivered. Possible values include: 'Csv'
197	Format FormatType `json:"format,omitempty"`
198	// DeliveryInfo - Has delivery information for the export.
199	DeliveryInfo *ExportDeliveryInfo `json:"deliveryInfo,omitempty"`
200	// Definition - Has definition for the export.
201	Definition *QueryDefinition `json:"definition,omitempty"`
202}
203
204// Dimension ...
205type Dimension struct {
206	*DimensionProperties `json:"properties,omitempty"`
207	// ID - READ-ONLY; Resource Id.
208	ID *string `json:"id,omitempty"`
209	// Name - READ-ONLY; Resource name.
210	Name *string `json:"name,omitempty"`
211	// Type - READ-ONLY; Resource type.
212	Type *string `json:"type,omitempty"`
213	// Tags - READ-ONLY; Resource tags.
214	Tags map[string]*string `json:"tags"`
215}
216
217// MarshalJSON is the custom marshaler for Dimension.
218func (d Dimension) MarshalJSON() ([]byte, error) {
219	objectMap := make(map[string]interface{})
220	if d.DimensionProperties != nil {
221		objectMap["properties"] = d.DimensionProperties
222	}
223	return json.Marshal(objectMap)
224}
225
226// UnmarshalJSON is the custom unmarshaler for Dimension struct.
227func (d *Dimension) UnmarshalJSON(body []byte) error {
228	var m map[string]*json.RawMessage
229	err := json.Unmarshal(body, &m)
230	if err != nil {
231		return err
232	}
233	for k, v := range m {
234		switch k {
235		case "properties":
236			if v != nil {
237				var dimensionProperties DimensionProperties
238				err = json.Unmarshal(*v, &dimensionProperties)
239				if err != nil {
240					return err
241				}
242				d.DimensionProperties = &dimensionProperties
243			}
244		case "id":
245			if v != nil {
246				var ID string
247				err = json.Unmarshal(*v, &ID)
248				if err != nil {
249					return err
250				}
251				d.ID = &ID
252			}
253		case "name":
254			if v != nil {
255				var name string
256				err = json.Unmarshal(*v, &name)
257				if err != nil {
258					return err
259				}
260				d.Name = &name
261			}
262		case "type":
263			if v != nil {
264				var typeVar string
265				err = json.Unmarshal(*v, &typeVar)
266				if err != nil {
267					return err
268				}
269				d.Type = &typeVar
270			}
271		case "tags":
272			if v != nil {
273				var tags map[string]*string
274				err = json.Unmarshal(*v, &tags)
275				if err != nil {
276					return err
277				}
278				d.Tags = tags
279			}
280		}
281	}
282
283	return nil
284}
285
286// DimensionProperties ...
287type DimensionProperties struct {
288	Description     *string    `json:"description,omitempty"`
289	FilterEnabled   *bool      `json:"filterEnabled,omitempty"`
290	GroupingEnabled *bool      `json:"groupingEnabled,omitempty"`
291	Data            *[]string  `json:"data,omitempty"`
292	Total           *int32     `json:"total,omitempty"`
293	Category        *string    `json:"category,omitempty"`
294	UsageStart      *date.Time `json:"usageStart,omitempty"`
295	UsageEnd        *date.Time `json:"usageEnd,omitempty"`
296	NextLink        *string    `json:"nextLink,omitempty"`
297}
298
299// DimensionsListResult result of listing dimensions. It contains a list of available dimensions.
300type DimensionsListResult struct {
301	autorest.Response `json:"-"`
302	// Value - READ-ONLY; The list of dimensions.
303	Value *[]Dimension `json:"value,omitempty"`
304}
305
306// ErrorDetails the details of the error.
307type ErrorDetails struct {
308	// Code - READ-ONLY; Error code.
309	Code *string `json:"code,omitempty"`
310	// Message - READ-ONLY; Error message indicating why the operation failed.
311	Message *string `json:"message,omitempty"`
312}
313
314// ErrorResponse error response indicates that the service is not able to process the incoming request. The
315// reason is provided in the error message.
316type ErrorResponse struct {
317	// Error - The details of the error.
318	Error *ErrorDetails `json:"error,omitempty"`
319}
320
321// Export a export resource.
322type Export struct {
323	autorest.Response `json:"-"`
324	*ExportProperties `json:"properties,omitempty"`
325	// ID - READ-ONLY; Resource Id.
326	ID *string `json:"id,omitempty"`
327	// Name - READ-ONLY; Resource name.
328	Name *string `json:"name,omitempty"`
329	// Type - READ-ONLY; Resource type.
330	Type *string `json:"type,omitempty"`
331	// Tags - READ-ONLY; Resource tags.
332	Tags map[string]*string `json:"tags"`
333}
334
335// MarshalJSON is the custom marshaler for Export.
336func (e Export) MarshalJSON() ([]byte, error) {
337	objectMap := make(map[string]interface{})
338	if e.ExportProperties != nil {
339		objectMap["properties"] = e.ExportProperties
340	}
341	return json.Marshal(objectMap)
342}
343
344// UnmarshalJSON is the custom unmarshaler for Export struct.
345func (e *Export) UnmarshalJSON(body []byte) error {
346	var m map[string]*json.RawMessage
347	err := json.Unmarshal(body, &m)
348	if err != nil {
349		return err
350	}
351	for k, v := range m {
352		switch k {
353		case "properties":
354			if v != nil {
355				var exportProperties ExportProperties
356				err = json.Unmarshal(*v, &exportProperties)
357				if err != nil {
358					return err
359				}
360				e.ExportProperties = &exportProperties
361			}
362		case "id":
363			if v != nil {
364				var ID string
365				err = json.Unmarshal(*v, &ID)
366				if err != nil {
367					return err
368				}
369				e.ID = &ID
370			}
371		case "name":
372			if v != nil {
373				var name string
374				err = json.Unmarshal(*v, &name)
375				if err != nil {
376					return err
377				}
378				e.Name = &name
379			}
380		case "type":
381			if v != nil {
382				var typeVar string
383				err = json.Unmarshal(*v, &typeVar)
384				if err != nil {
385					return err
386				}
387				e.Type = &typeVar
388			}
389		case "tags":
390			if v != nil {
391				var tags map[string]*string
392				err = json.Unmarshal(*v, &tags)
393				if err != nil {
394					return err
395				}
396				e.Tags = tags
397			}
398		}
399	}
400
401	return nil
402}
403
404// ExportDeliveryDestination the destination information for the delivery of the export. To allow access to
405// a storage account, you must register the account's subscription with the Microsoft.CostManagementExports
406// resource provider. This is required once per subscription. When creating an export in the Azure portal,
407// it is done automatically. However, API users need to register the subscription. For more information see
408// https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services .
409type ExportDeliveryDestination struct {
410	// ResourceID - The resource id of the storage account where exports will be delivered.
411	ResourceID *string `json:"resourceId,omitempty"`
412	// Container - The name of the container where exports will be uploaded.
413	Container *string `json:"container,omitempty"`
414	// RootFolderPath - The name of the directory where exports will be uploaded.
415	RootFolderPath *string `json:"rootFolderPath,omitempty"`
416}
417
418// ExportDeliveryInfo the delivery information associated with a export.
419type ExportDeliveryInfo struct {
420	// Destination - Has destination for the export being delivered.
421	Destination *ExportDeliveryDestination `json:"destination,omitempty"`
422}
423
424// ExportExecution a export execution.
425type ExportExecution struct {
426	*ExportExecutionProperties `json:"properties,omitempty"`
427	// ID - READ-ONLY; Resource Id.
428	ID *string `json:"id,omitempty"`
429	// Name - READ-ONLY; Resource name.
430	Name *string `json:"name,omitempty"`
431	// Type - READ-ONLY; Resource type.
432	Type *string `json:"type,omitempty"`
433	// Tags - READ-ONLY; Resource tags.
434	Tags map[string]*string `json:"tags"`
435}
436
437// MarshalJSON is the custom marshaler for ExportExecution.
438func (ee ExportExecution) MarshalJSON() ([]byte, error) {
439	objectMap := make(map[string]interface{})
440	if ee.ExportExecutionProperties != nil {
441		objectMap["properties"] = ee.ExportExecutionProperties
442	}
443	return json.Marshal(objectMap)
444}
445
446// UnmarshalJSON is the custom unmarshaler for ExportExecution struct.
447func (ee *ExportExecution) UnmarshalJSON(body []byte) error {
448	var m map[string]*json.RawMessage
449	err := json.Unmarshal(body, &m)
450	if err != nil {
451		return err
452	}
453	for k, v := range m {
454		switch k {
455		case "properties":
456			if v != nil {
457				var exportExecutionProperties ExportExecutionProperties
458				err = json.Unmarshal(*v, &exportExecutionProperties)
459				if err != nil {
460					return err
461				}
462				ee.ExportExecutionProperties = &exportExecutionProperties
463			}
464		case "id":
465			if v != nil {
466				var ID string
467				err = json.Unmarshal(*v, &ID)
468				if err != nil {
469					return err
470				}
471				ee.ID = &ID
472			}
473		case "name":
474			if v != nil {
475				var name string
476				err = json.Unmarshal(*v, &name)
477				if err != nil {
478					return err
479				}
480				ee.Name = &name
481			}
482		case "type":
483			if v != nil {
484				var typeVar string
485				err = json.Unmarshal(*v, &typeVar)
486				if err != nil {
487					return err
488				}
489				ee.Type = &typeVar
490			}
491		case "tags":
492			if v != nil {
493				var tags map[string]*string
494				err = json.Unmarshal(*v, &tags)
495				if err != nil {
496					return err
497				}
498				ee.Tags = tags
499			}
500		}
501	}
502
503	return nil
504}
505
506// ExportExecutionListResult result of listing exports execution history of a export by name
507type ExportExecutionListResult struct {
508	autorest.Response `json:"-"`
509	// Value - READ-ONLY; The list of export executions.
510	Value *[]ExportExecution `json:"value,omitempty"`
511}
512
513// ExportExecutionProperties the properties of the export execution.
514type ExportExecutionProperties struct {
515	// ExecutionType - The type of the export execution. Possible values include: 'OnDemand', 'Scheduled'
516	ExecutionType ExecutionType `json:"executionType,omitempty"`
517	// Status - The status of the export execution. Possible values include: 'Queued', 'InProgress', 'Completed', 'Failed', 'Timeout', 'NewDataNotAvailable', 'DataNotAvailable'
518	Status ExecutionStatus `json:"status,omitempty"`
519	// SubmittedBy - The identifier for the entity that executed the export. For OnDemand executions, it is the email id. For Scheduled executions, it is the constant value - System.
520	SubmittedBy *string `json:"submittedBy,omitempty"`
521	// SubmittedTime - The time when export was queued to be executed.
522	SubmittedTime *date.Time `json:"submittedTime,omitempty"`
523	// ProcessingStartTime - The time when export was picked up to be executed.
524	ProcessingStartTime *date.Time `json:"processingStartTime,omitempty"`
525	// ProcessingEndTime - The time when export execution finished.
526	ProcessingEndTime *date.Time `json:"processingEndTime,omitempty"`
527	// FileName - The name of the file export got written to.
528	FileName    *string                 `json:"fileName,omitempty"`
529	RunSettings *CommonExportProperties `json:"runSettings,omitempty"`
530}
531
532// ExportListResult result of listing exports. It contains a list of available exports in the scope
533// provided.
534type ExportListResult struct {
535	autorest.Response `json:"-"`
536	// Value - READ-ONLY; The list of exports.
537	Value *[]Export `json:"value,omitempty"`
538}
539
540// ExportProperties the properties of the export.
541type ExportProperties struct {
542	// Schedule - Has schedule information for the export.
543	Schedule *ExportSchedule `json:"schedule,omitempty"`
544	// Format - The format of the export being delivered. Possible values include: 'Csv'
545	Format FormatType `json:"format,omitempty"`
546	// DeliveryInfo - Has delivery information for the export.
547	DeliveryInfo *ExportDeliveryInfo `json:"deliveryInfo,omitempty"`
548	// Definition - Has definition for the export.
549	Definition *QueryDefinition `json:"definition,omitempty"`
550}
551
552// ExportRecurrencePeriod the start and end date for recurrence schedule.
553type ExportRecurrencePeriod struct {
554	// From - The start date of recurrence.
555	From *date.Time `json:"from,omitempty"`
556	// To - The end date of recurrence.
557	To *date.Time `json:"to,omitempty"`
558}
559
560// ExportSchedule the schedule associated with a export.
561type ExportSchedule struct {
562	// Status - The status of the schedule. Whether active or not. If inactive, the export's scheduled execution is paused. Possible values include: 'Active', 'Inactive'
563	Status StatusType `json:"status,omitempty"`
564	// Recurrence - The schedule recurrence. Possible values include: 'RecurrenceTypeDaily', 'RecurrenceTypeWeekly', 'RecurrenceTypeMonthly', 'RecurrenceTypeAnnually'
565	Recurrence RecurrenceType `json:"recurrence,omitempty"`
566	// RecurrencePeriod - Has start and end date of the recurrence. The start date must be in future. If present, the end date must be greater than start date.
567	RecurrencePeriod *ExportRecurrencePeriod `json:"recurrencePeriod,omitempty"`
568}
569
570// Operation a Cost management REST API operation.
571type Operation struct {
572	// Name - READ-ONLY; Operation name: {provider}/{resource}/{operation}.
573	Name *string `json:"name,omitempty"`
574	// Display - The object that represents the operation.
575	Display *OperationDisplay `json:"display,omitempty"`
576}
577
578// OperationDisplay the object that represents the operation.
579type OperationDisplay struct {
580	// Provider - READ-ONLY; Service provider: Microsoft.CostManagement.
581	Provider *string `json:"provider,omitempty"`
582	// Resource - READ-ONLY; Resource on which the operation is performed: Dimensions, Query.
583	Resource *string `json:"resource,omitempty"`
584	// Operation - READ-ONLY; Operation type: Read, write, delete, etc.
585	Operation *string `json:"operation,omitempty"`
586}
587
588// OperationListResult result of listing cost management operations. It contains a list of operations and a
589// URL link to get the next set of results.
590type OperationListResult struct {
591	autorest.Response `json:"-"`
592	// Value - READ-ONLY; List of cost management operations supported by the Microsoft.CostManagement resource provider.
593	Value *[]Operation `json:"value,omitempty"`
594	// NextLink - READ-ONLY; URL to get the next set of operation list results if there are any.
595	NextLink *string `json:"nextLink,omitempty"`
596}
597
598// OperationListResultIterator provides access to a complete listing of Operation values.
599type OperationListResultIterator struct {
600	i    int
601	page OperationListResultPage
602}
603
604// NextWithContext advances to the next value.  If there was an error making
605// the request the iterator does not advance and the error is returned.
606func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) {
607	if tracing.IsEnabled() {
608		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext")
609		defer func() {
610			sc := -1
611			if iter.Response().Response.Response != nil {
612				sc = iter.Response().Response.Response.StatusCode
613			}
614			tracing.EndSpan(ctx, sc, err)
615		}()
616	}
617	iter.i++
618	if iter.i < len(iter.page.Values()) {
619		return nil
620	}
621	err = iter.page.NextWithContext(ctx)
622	if err != nil {
623		iter.i--
624		return err
625	}
626	iter.i = 0
627	return nil
628}
629
630// Next advances to the next value.  If there was an error making
631// the request the iterator does not advance and the error is returned.
632// Deprecated: Use NextWithContext() instead.
633func (iter *OperationListResultIterator) Next() error {
634	return iter.NextWithContext(context.Background())
635}
636
637// NotDone returns true if the enumeration should be started or is not yet complete.
638func (iter OperationListResultIterator) NotDone() bool {
639	return iter.page.NotDone() && iter.i < len(iter.page.Values())
640}
641
642// Response returns the raw server response from the last page request.
643func (iter OperationListResultIterator) Response() OperationListResult {
644	return iter.page.Response()
645}
646
647// Value returns the current value or a zero-initialized value if the
648// iterator has advanced beyond the end of the collection.
649func (iter OperationListResultIterator) Value() Operation {
650	if !iter.page.NotDone() {
651		return Operation{}
652	}
653	return iter.page.Values()[iter.i]
654}
655
656// Creates a new instance of the OperationListResultIterator type.
657func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
658	return OperationListResultIterator{page: page}
659}
660
661// IsEmpty returns true if the ListResult contains no values.
662func (olr OperationListResult) IsEmpty() bool {
663	return olr.Value == nil || len(*olr.Value) == 0
664}
665
666// operationListResultPreparer prepares a request to retrieve the next set of results.
667// It returns nil if no more results exist.
668func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) {
669	if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 {
670		return nil, nil
671	}
672	return autorest.Prepare((&http.Request{}).WithContext(ctx),
673		autorest.AsJSON(),
674		autorest.AsGet(),
675		autorest.WithBaseURL(to.String(olr.NextLink)))
676}
677
678// OperationListResultPage contains a page of Operation values.
679type OperationListResultPage struct {
680	fn  func(context.Context, OperationListResult) (OperationListResult, error)
681	olr OperationListResult
682}
683
684// NextWithContext advances to the next page of values.  If there was an error making
685// the request the page does not advance and the error is returned.
686func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) {
687	if tracing.IsEnabled() {
688		ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext")
689		defer func() {
690			sc := -1
691			if page.Response().Response.Response != nil {
692				sc = page.Response().Response.Response.StatusCode
693			}
694			tracing.EndSpan(ctx, sc, err)
695		}()
696	}
697	next, err := page.fn(ctx, page.olr)
698	if err != nil {
699		return err
700	}
701	page.olr = next
702	return nil
703}
704
705// Next advances to the next page of values.  If there was an error making
706// the request the page does not advance and the error is returned.
707// Deprecated: Use NextWithContext() instead.
708func (page *OperationListResultPage) Next() error {
709	return page.NextWithContext(context.Background())
710}
711
712// NotDone returns true if the page enumeration should be started or is not yet complete.
713func (page OperationListResultPage) NotDone() bool {
714	return !page.olr.IsEmpty()
715}
716
717// Response returns the raw server response from the last page request.
718func (page OperationListResultPage) Response() OperationListResult {
719	return page.olr
720}
721
722// Values returns the slice of values for the current page or nil if there are no values.
723func (page OperationListResultPage) Values() []Operation {
724	if page.olr.IsEmpty() {
725		return nil
726	}
727	return *page.olr.Value
728}
729
730// Creates a new instance of the OperationListResultPage type.
731func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
732	return OperationListResultPage{fn: getNextPage}
733}
734
735// Query ...
736type Query struct {
737	*QueryProperties `json:"properties,omitempty"`
738	// ID - READ-ONLY; Resource Id.
739	ID *string `json:"id,omitempty"`
740	// Name - READ-ONLY; Resource name.
741	Name *string `json:"name,omitempty"`
742	// Type - READ-ONLY; Resource type.
743	Type *string `json:"type,omitempty"`
744	// Tags - READ-ONLY; Resource tags.
745	Tags map[string]*string `json:"tags"`
746}
747
748// MarshalJSON is the custom marshaler for Query.
749func (q Query) MarshalJSON() ([]byte, error) {
750	objectMap := make(map[string]interface{})
751	if q.QueryProperties != nil {
752		objectMap["properties"] = q.QueryProperties
753	}
754	return json.Marshal(objectMap)
755}
756
757// UnmarshalJSON is the custom unmarshaler for Query struct.
758func (q *Query) UnmarshalJSON(body []byte) error {
759	var m map[string]*json.RawMessage
760	err := json.Unmarshal(body, &m)
761	if err != nil {
762		return err
763	}
764	for k, v := range m {
765		switch k {
766		case "properties":
767			if v != nil {
768				var queryProperties QueryProperties
769				err = json.Unmarshal(*v, &queryProperties)
770				if err != nil {
771					return err
772				}
773				q.QueryProperties = &queryProperties
774			}
775		case "id":
776			if v != nil {
777				var ID string
778				err = json.Unmarshal(*v, &ID)
779				if err != nil {
780					return err
781				}
782				q.ID = &ID
783			}
784		case "name":
785			if v != nil {
786				var name string
787				err = json.Unmarshal(*v, &name)
788				if err != nil {
789					return err
790				}
791				q.Name = &name
792			}
793		case "type":
794			if v != nil {
795				var typeVar string
796				err = json.Unmarshal(*v, &typeVar)
797				if err != nil {
798					return err
799				}
800				q.Type = &typeVar
801			}
802		case "tags":
803			if v != nil {
804				var tags map[string]*string
805				err = json.Unmarshal(*v, &tags)
806				if err != nil {
807					return err
808				}
809				q.Tags = tags
810			}
811		}
812	}
813
814	return nil
815}
816
817// QueryAggregation the aggregation expression to be used in the query.
818type QueryAggregation struct {
819	// Name - The name of the column to aggregate.
820	Name *string `json:"name,omitempty"`
821	// Function - The name of the aggregation function to use.
822	Function *string `json:"function,omitempty"`
823}
824
825// QueryColumn ...
826type QueryColumn struct {
827	Name *string `json:"name,omitempty"`
828	Type *string `json:"type,omitempty"`
829}
830
831// QueryComparisonExpression the comparison expression to be used in the query.
832type QueryComparisonExpression struct {
833	// Name - The name of the column to use in comparison.
834	Name *string `json:"name,omitempty"`
835	// Operator - The operator to use for comparison.
836	Operator *string `json:"operator,omitempty"`
837	// Values - Array of values to use for comparison
838	Values *[]string `json:"values,omitempty"`
839}
840
841// QueryDataset the definition of data present in the query.
842type QueryDataset struct {
843	// Granularity - The granularity of rows in the query. Possible values include: 'Daily', 'Hourly'
844	Granularity GranularityType `json:"granularity,omitempty"`
845	// Configuration - Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping are provided.
846	Configuration *QueryDatasetConfiguration `json:"configuration,omitempty"`
847	// Aggregation - Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the aggregated column. Query can have up to 2 aggregation clauses.
848	Aggregation map[string]*QueryAggregation `json:"aggregation"`
849	// Grouping - Array of group by expression to use in the query. Query can have up to 2 group by clauses.
850	Grouping *[]QueryGrouping `json:"grouping,omitempty"`
851	// Sorting - Array of sorting by columns in query.
852	Sorting *[]QuerySortingConfiguration `json:"sorting,omitempty"`
853	// Filter - Has filter expression to use in the query.
854	Filter *QueryFilter `json:"filter,omitempty"`
855}
856
857// MarshalJSON is the custom marshaler for QueryDataset.
858func (qd QueryDataset) MarshalJSON() ([]byte, error) {
859	objectMap := make(map[string]interface{})
860	if qd.Granularity != "" {
861		objectMap["granularity"] = qd.Granularity
862	}
863	if qd.Configuration != nil {
864		objectMap["configuration"] = qd.Configuration
865	}
866	if qd.Aggregation != nil {
867		objectMap["aggregation"] = qd.Aggregation
868	}
869	if qd.Grouping != nil {
870		objectMap["grouping"] = qd.Grouping
871	}
872	if qd.Sorting != nil {
873		objectMap["sorting"] = qd.Sorting
874	}
875	if qd.Filter != nil {
876		objectMap["filter"] = qd.Filter
877	}
878	return json.Marshal(objectMap)
879}
880
881// QueryDatasetConfiguration the configuration of dataset in the query.
882type QueryDatasetConfiguration struct {
883	// Columns - Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query includes all columns.
884	Columns *[]string `json:"columns,omitempty"`
885}
886
887// QueryDefinition the definition of a query.
888type QueryDefinition struct {
889	// Type - The type of the query.
890	Type *string `json:"type,omitempty"`
891	// Timeframe - The time frame for pulling data for the query. If custom, then a specific time period must be provided. Possible values include: 'WeekToDate', 'MonthToDate', 'YearToDate', 'TheLastWeek', 'TheLastMonth', 'TheLastYear', 'Custom', 'BillingMonthToDate', 'TheLastBillingMonth'
892	Timeframe TimeframeType `json:"timeframe,omitempty"`
893	// TimePeriod - Has time period for pulling data for the query.
894	TimePeriod *QueryTimePeriod `json:"timePeriod,omitempty"`
895	// Dataset - Has definition for data in this query.
896	Dataset *QueryDataset `json:"dataset,omitempty"`
897}
898
899// QueryFilter the filter expression to be used in the export.
900type QueryFilter struct {
901	// And - The logical "AND" expression. Must have at least 2 items.
902	And *[]QueryFilter `json:"and,omitempty"`
903	// Or - The logical "OR" expression. Must have at least 2 items.
904	Or *[]QueryFilter `json:"or,omitempty"`
905	// Not - The logical "NOT" expression.
906	Not *QueryFilter `json:"not,omitempty"`
907	// Dimension - Has comparison expression for a dimension
908	Dimension *QueryComparisonExpression `json:"dimension,omitempty"`
909	// Tag - Has comparison expression for a tag
910	Tag *QueryComparisonExpression `json:"tag,omitempty"`
911}
912
913// QueryGrouping the group by expression to be used in the query.
914type QueryGrouping struct {
915	// Type - Has type of the column to group. Possible values include: 'QueryColumnTypeTag', 'QueryColumnTypeDimension'
916	Type QueryColumnType `json:"type,omitempty"`
917	// Name - The name of the column to group.
918	Name *string `json:"name,omitempty"`
919}
920
921// QueryProperties ...
922type QueryProperties struct {
923	NextLink *string `json:"nextLink,omitempty"`
924	// Columns - Array of columns
925	Columns *[]QueryColumn   `json:"columns,omitempty"`
926	Rows    *[][]interface{} `json:"rows,omitempty"`
927}
928
929// QueryResult result of query. It contains all columns listed under groupings and aggregation.
930type QueryResult struct {
931	autorest.Response `json:"-"`
932	// Value - READ-ONLY; The list of usage data.
933	Value *[]Query `json:"value,omitempty"`
934}
935
936// QuerySortingConfiguration the configuration for sorting in the query.
937type QuerySortingConfiguration struct {
938	// QuerySortingDirection - The sorting direction. Possible values include: 'Ascending', 'Descending'
939	QuerySortingDirection SortDirection `json:"querySortingDirection,omitempty"`
940	// Name - The name of the column to use in sorting.
941	Name *string `json:"name,omitempty"`
942}
943
944// QueryTimePeriod the start and end date for pulling data for the query.
945type QueryTimePeriod struct {
946	// From - The start date to pull data from.
947	From *date.Time `json:"from,omitempty"`
948	// To - The end date to pull data to.
949	To *date.Time `json:"to,omitempty"`
950}
951
952// Resource the Resource model definition.
953type Resource struct {
954	// ID - READ-ONLY; Resource Id.
955	ID *string `json:"id,omitempty"`
956	// Name - READ-ONLY; Resource name.
957	Name *string `json:"name,omitempty"`
958	// Type - READ-ONLY; Resource type.
959	Type *string `json:"type,omitempty"`
960	// Tags - READ-ONLY; Resource tags.
961	Tags map[string]*string `json:"tags"`
962}
963
964// MarshalJSON is the custom marshaler for Resource.
965func (r Resource) MarshalJSON() ([]byte, error) {
966	objectMap := make(map[string]interface{})
967	return json.Marshal(objectMap)
968}
969