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/preview/costmanagement/mgmt/2019-10-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	// Custom ...
170	Custom TimeframeType = "Custom"
171	// MonthToDate ...
172	MonthToDate TimeframeType = "MonthToDate"
173	// TheLastMonth ...
174	TheLastMonth TimeframeType = "TheLastMonth"
175	// TheLastWeek ...
176	TheLastWeek TimeframeType = "TheLastWeek"
177	// TheLastYear ...
178	TheLastYear TimeframeType = "TheLastYear"
179	// WeekToDate ...
180	WeekToDate TimeframeType = "WeekToDate"
181	// YearToDate ...
182	YearToDate TimeframeType = "YearToDate"
183)
184
185// PossibleTimeframeTypeValues returns an array of possible values for the TimeframeType const type.
186func PossibleTimeframeTypeValues() []TimeframeType {
187	return []TimeframeType{Custom, MonthToDate, TheLastMonth, TheLastWeek, TheLastYear, WeekToDate, YearToDate}
188}
189
190// CommonExportProperties the common properties of the export.
191type CommonExportProperties struct {
192	// Format - The format of the export being delivered. Possible values include: 'Csv'
193	Format FormatType `json:"format,omitempty"`
194	// DeliveryInfo - Has delivery information for the export.
195	DeliveryInfo *ExportDeliveryInfo `json:"deliveryInfo,omitempty"`
196	// Definition - Has definition for the export.
197	Definition *QueryDefinition `json:"definition,omitempty"`
198}
199
200// Dimension ...
201type Dimension struct {
202	*DimensionProperties `json:"properties,omitempty"`
203	// ID - READ-ONLY; Resource Id.
204	ID *string `json:"id,omitempty"`
205	// Name - READ-ONLY; Resource name.
206	Name *string `json:"name,omitempty"`
207	// Type - READ-ONLY; Resource type.
208	Type *string `json:"type,omitempty"`
209	// Tags - READ-ONLY; Resource tags.
210	Tags map[string]*string `json:"tags"`
211}
212
213// MarshalJSON is the custom marshaler for Dimension.
214func (d Dimension) MarshalJSON() ([]byte, error) {
215	objectMap := make(map[string]interface{})
216	if d.DimensionProperties != nil {
217		objectMap["properties"] = d.DimensionProperties
218	}
219	return json.Marshal(objectMap)
220}
221
222// UnmarshalJSON is the custom unmarshaler for Dimension struct.
223func (d *Dimension) UnmarshalJSON(body []byte) error {
224	var m map[string]*json.RawMessage
225	err := json.Unmarshal(body, &m)
226	if err != nil {
227		return err
228	}
229	for k, v := range m {
230		switch k {
231		case "properties":
232			if v != nil {
233				var dimensionProperties DimensionProperties
234				err = json.Unmarshal(*v, &dimensionProperties)
235				if err != nil {
236					return err
237				}
238				d.DimensionProperties = &dimensionProperties
239			}
240		case "id":
241			if v != nil {
242				var ID string
243				err = json.Unmarshal(*v, &ID)
244				if err != nil {
245					return err
246				}
247				d.ID = &ID
248			}
249		case "name":
250			if v != nil {
251				var name string
252				err = json.Unmarshal(*v, &name)
253				if err != nil {
254					return err
255				}
256				d.Name = &name
257			}
258		case "type":
259			if v != nil {
260				var typeVar string
261				err = json.Unmarshal(*v, &typeVar)
262				if err != nil {
263					return err
264				}
265				d.Type = &typeVar
266			}
267		case "tags":
268			if v != nil {
269				var tags map[string]*string
270				err = json.Unmarshal(*v, &tags)
271				if err != nil {
272					return err
273				}
274				d.Tags = tags
275			}
276		}
277	}
278
279	return nil
280}
281
282// DimensionProperties ...
283type DimensionProperties struct {
284	// Description - READ-ONLY; Dimension description.
285	Description *string `json:"description,omitempty"`
286	// FilterEnabled - READ-ONLY; Filter enabled.
287	FilterEnabled *bool `json:"filterEnabled,omitempty"`
288	// GroupingEnabled - READ-ONLY; Grouping enabled.
289	GroupingEnabled *bool     `json:"groupingEnabled,omitempty"`
290	Data            *[]string `json:"data,omitempty"`
291	// Total - READ-ONLY; Total number of data for the dimension.
292	Total *int32 `json:"total,omitempty"`
293	// Category - READ-ONLY; Dimension category.
294	Category *string `json:"category,omitempty"`
295	// UsageStart - READ-ONLY; Usage start.
296	UsageStart *date.Time `json:"usageStart,omitempty"`
297	// UsageEnd - READ-ONLY; Usage end.
298	UsageEnd *date.Time `json:"usageEnd,omitempty"`
299	// NextLink - READ-ONLY; The link (url) to the next page of results.
300	NextLink *string `json:"nextLink,omitempty"`
301}
302
303// DimensionsListResult result of listing dimensions. It contains a list of available dimensions.
304type DimensionsListResult struct {
305	autorest.Response `json:"-"`
306	// Value - READ-ONLY; The list of dimensions.
307	Value *[]Dimension `json:"value,omitempty"`
308}
309
310// ErrorDetails the details of the error.
311type ErrorDetails struct {
312	// Code - READ-ONLY; Error code.
313	Code *string `json:"code,omitempty"`
314	// Message - READ-ONLY; Error message indicating why the operation failed.
315	Message *string `json:"message,omitempty"`
316}
317
318// ErrorResponse error response indicates that the service is not able to process the incoming request. The
319// reason is provided in the error message.
320type ErrorResponse struct {
321	// Error - The details of the error.
322	Error *ErrorDetails `json:"error,omitempty"`
323}
324
325// Export a export resource.
326type Export struct {
327	autorest.Response `json:"-"`
328	*ExportProperties `json:"properties,omitempty"`
329	// ID - READ-ONLY; Resource Id.
330	ID *string `json:"id,omitempty"`
331	// Name - READ-ONLY; Resource name.
332	Name *string `json:"name,omitempty"`
333	// Type - READ-ONLY; Resource type.
334	Type *string `json:"type,omitempty"`
335	// Tags - READ-ONLY; Resource tags.
336	Tags map[string]*string `json:"tags"`
337}
338
339// MarshalJSON is the custom marshaler for Export.
340func (e Export) MarshalJSON() ([]byte, error) {
341	objectMap := make(map[string]interface{})
342	if e.ExportProperties != nil {
343		objectMap["properties"] = e.ExportProperties
344	}
345	return json.Marshal(objectMap)
346}
347
348// UnmarshalJSON is the custom unmarshaler for Export struct.
349func (e *Export) UnmarshalJSON(body []byte) error {
350	var m map[string]*json.RawMessage
351	err := json.Unmarshal(body, &m)
352	if err != nil {
353		return err
354	}
355	for k, v := range m {
356		switch k {
357		case "properties":
358			if v != nil {
359				var exportProperties ExportProperties
360				err = json.Unmarshal(*v, &exportProperties)
361				if err != nil {
362					return err
363				}
364				e.ExportProperties = &exportProperties
365			}
366		case "id":
367			if v != nil {
368				var ID string
369				err = json.Unmarshal(*v, &ID)
370				if err != nil {
371					return err
372				}
373				e.ID = &ID
374			}
375		case "name":
376			if v != nil {
377				var name string
378				err = json.Unmarshal(*v, &name)
379				if err != nil {
380					return err
381				}
382				e.Name = &name
383			}
384		case "type":
385			if v != nil {
386				var typeVar string
387				err = json.Unmarshal(*v, &typeVar)
388				if err != nil {
389					return err
390				}
391				e.Type = &typeVar
392			}
393		case "tags":
394			if v != nil {
395				var tags map[string]*string
396				err = json.Unmarshal(*v, &tags)
397				if err != nil {
398					return err
399				}
400				e.Tags = tags
401			}
402		}
403	}
404
405	return nil
406}
407
408// ExportDeliveryDestination the destination information for the delivery of the export.
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// QueryAggregation the aggregation expression to be used in the query.
736type QueryAggregation struct {
737	// Name - The name of the column to aggregate.
738	Name *string `json:"name,omitempty"`
739	// Function - The name of the aggregation function to use.
740	Function *string `json:"function,omitempty"`
741}
742
743// QueryColumn ...
744type QueryColumn struct {
745	// Name - The name of column.
746	Name *string `json:"name,omitempty"`
747	// Type - The type of column.
748	Type *string `json:"type,omitempty"`
749}
750
751// QueryComparisonExpression the comparison expression to be used in the query.
752type QueryComparisonExpression struct {
753	// Name - The name of the column to use in comparison.
754	Name *string `json:"name,omitempty"`
755	// Operator - The operator to use for comparison.
756	Operator *string `json:"operator,omitempty"`
757	// Values - Array of values to use for comparison
758	Values *[]string `json:"values,omitempty"`
759}
760
761// QueryDataset the definition of data present in the query.
762type QueryDataset struct {
763	// Granularity - The granularity of rows in the query. Possible values include: 'Daily', 'Hourly'
764	Granularity GranularityType `json:"granularity,omitempty"`
765	// Configuration - Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping are provided.
766	Configuration *QueryDatasetConfiguration `json:"configuration,omitempty"`
767	// 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.
768	Aggregation map[string]*QueryAggregation `json:"aggregation"`
769	// Grouping - Array of group by expression to use in the query. Query can have up to 2 group by clauses.
770	Grouping *[]QueryGrouping `json:"grouping,omitempty"`
771	// Sorting - Array of sorting by columns in query.
772	Sorting *[]QuerySortingConfiguration `json:"sorting,omitempty"`
773	// Filter - Has filter expression to use in the query.
774	Filter *QueryFilter `json:"filter,omitempty"`
775}
776
777// MarshalJSON is the custom marshaler for QueryDataset.
778func (qd QueryDataset) MarshalJSON() ([]byte, error) {
779	objectMap := make(map[string]interface{})
780	if qd.Granularity != "" {
781		objectMap["granularity"] = qd.Granularity
782	}
783	if qd.Configuration != nil {
784		objectMap["configuration"] = qd.Configuration
785	}
786	if qd.Aggregation != nil {
787		objectMap["aggregation"] = qd.Aggregation
788	}
789	if qd.Grouping != nil {
790		objectMap["grouping"] = qd.Grouping
791	}
792	if qd.Sorting != nil {
793		objectMap["sorting"] = qd.Sorting
794	}
795	if qd.Filter != nil {
796		objectMap["filter"] = qd.Filter
797	}
798	return json.Marshal(objectMap)
799}
800
801// QueryDatasetConfiguration the configuration of dataset in the query.
802type QueryDatasetConfiguration struct {
803	// 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.
804	Columns *[]string `json:"columns,omitempty"`
805}
806
807// QueryDefinition the definition of a query.
808type QueryDefinition struct {
809	// Type - The type of the query.
810	Type *string `json:"type,omitempty"`
811	// 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'
812	Timeframe TimeframeType `json:"timeframe,omitempty"`
813	// TimePeriod - Has time period for pulling data for the query.
814	TimePeriod *QueryTimePeriod `json:"timePeriod,omitempty"`
815	// Dataset - Has definition for data in this query.
816	Dataset *QueryDataset `json:"dataset,omitempty"`
817}
818
819// QueryFilter the filter expression to be used in the export.
820type QueryFilter struct {
821	// And - The logical "AND" expression. Must have at least 2 items.
822	And *[]QueryFilter `json:"and,omitempty"`
823	// Or - The logical "OR" expression. Must have at least 2 items.
824	Or *[]QueryFilter `json:"or,omitempty"`
825	// Not - The logical "NOT" expression.
826	Not *QueryFilter `json:"not,omitempty"`
827	// Dimension - Has comparison expression for a dimension
828	Dimension *QueryComparisonExpression `json:"dimension,omitempty"`
829	// Tag - Has comparison expression for a tag
830	Tag *QueryComparisonExpression `json:"tag,omitempty"`
831}
832
833// QueryGrouping the group by expression to be used in the query.
834type QueryGrouping struct {
835	// Type - Has type of the column to group. Possible values include: 'QueryColumnTypeTag', 'QueryColumnTypeDimension'
836	Type QueryColumnType `json:"type,omitempty"`
837	// Name - The name of the column to group.
838	Name *string `json:"name,omitempty"`
839}
840
841// QueryProperties ...
842type QueryProperties struct {
843	// NextLink - The link (url) to the next page of results.
844	NextLink *string `json:"nextLink,omitempty"`
845	// Columns - Array of columns
846	Columns *[]QueryColumn `json:"columns,omitempty"`
847	// Rows - Array of rows
848	Rows *[][]interface{} `json:"rows,omitempty"`
849}
850
851// QueryResult result of query. It contains all columns listed under groupings and aggregation.
852type QueryResult struct {
853	autorest.Response `json:"-"`
854	*QueryProperties  `json:"properties,omitempty"`
855	// ID - READ-ONLY; Resource Id.
856	ID *string `json:"id,omitempty"`
857	// Name - READ-ONLY; Resource name.
858	Name *string `json:"name,omitempty"`
859	// Type - READ-ONLY; Resource type.
860	Type *string `json:"type,omitempty"`
861	// Tags - READ-ONLY; Resource tags.
862	Tags map[string]*string `json:"tags"`
863}
864
865// MarshalJSON is the custom marshaler for QueryResult.
866func (qr QueryResult) MarshalJSON() ([]byte, error) {
867	objectMap := make(map[string]interface{})
868	if qr.QueryProperties != nil {
869		objectMap["properties"] = qr.QueryProperties
870	}
871	return json.Marshal(objectMap)
872}
873
874// UnmarshalJSON is the custom unmarshaler for QueryResult struct.
875func (qr *QueryResult) UnmarshalJSON(body []byte) error {
876	var m map[string]*json.RawMessage
877	err := json.Unmarshal(body, &m)
878	if err != nil {
879		return err
880	}
881	for k, v := range m {
882		switch k {
883		case "properties":
884			if v != nil {
885				var queryProperties QueryProperties
886				err = json.Unmarshal(*v, &queryProperties)
887				if err != nil {
888					return err
889				}
890				qr.QueryProperties = &queryProperties
891			}
892		case "id":
893			if v != nil {
894				var ID string
895				err = json.Unmarshal(*v, &ID)
896				if err != nil {
897					return err
898				}
899				qr.ID = &ID
900			}
901		case "name":
902			if v != nil {
903				var name string
904				err = json.Unmarshal(*v, &name)
905				if err != nil {
906					return err
907				}
908				qr.Name = &name
909			}
910		case "type":
911			if v != nil {
912				var typeVar string
913				err = json.Unmarshal(*v, &typeVar)
914				if err != nil {
915					return err
916				}
917				qr.Type = &typeVar
918			}
919		case "tags":
920			if v != nil {
921				var tags map[string]*string
922				err = json.Unmarshal(*v, &tags)
923				if err != nil {
924					return err
925				}
926				qr.Tags = tags
927			}
928		}
929	}
930
931	return nil
932}
933
934// QuerySortingConfiguration the configuration for sorting in the query.
935type QuerySortingConfiguration struct {
936	// QuerySortingDirection - The sorting direction. Possible values include: 'Ascending', 'Descending'
937	QuerySortingDirection SortDirection `json:"querySortingDirection,omitempty"`
938	// Name - The name of the column to use in sorting.
939	Name *string `json:"name,omitempty"`
940}
941
942// QueryTimePeriod the start and end date for pulling data for the query.
943type QueryTimePeriod struct {
944	// From - The start date to pull data from.
945	From *date.Time `json:"from,omitempty"`
946	// To - The end date to pull data to.
947	To *date.Time `json:"to,omitempty"`
948}
949
950// Resource the Resource model definition.
951type Resource struct {
952	// ID - READ-ONLY; Resource Id.
953	ID *string `json:"id,omitempty"`
954	// Name - READ-ONLY; Resource name.
955	Name *string `json:"name,omitempty"`
956	// Type - READ-ONLY; Resource type.
957	Type *string `json:"type,omitempty"`
958	// Tags - READ-ONLY; Resource tags.
959	Tags map[string]*string `json:"tags"`
960}
961
962// MarshalJSON is the custom marshaler for Resource.
963func (r Resource) MarshalJSON() ([]byte, error) {
964	objectMap := make(map[string]interface{})
965	return json.Marshal(objectMap)
966}
967