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