1package workloadmonitor 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/preview/workloadmonitor/mgmt/2018-08-31-preview/workloadmonitor" 21 22// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. 23type AzureEntityResource struct { 24 // Etag - READ-ONLY; Resource Etag. 25 Etag *string `json:"etag,omitempty"` 26 // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 27 ID *string `json:"id,omitempty"` 28 // Name - READ-ONLY; The name of the resource 29 Name *string `json:"name,omitempty"` 30 // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" 31 Type *string `json:"type,omitempty"` 32} 33 34// MarshalJSON is the custom marshaler for AzureEntityResource. 35func (aer AzureEntityResource) MarshalJSON() ([]byte, error) { 36 objectMap := make(map[string]interface{}) 37 return json.Marshal(objectMap) 38} 39 40// Component model for component. 41type Component struct { 42 autorest.Response `json:"-"` 43 // Etag - READ-ONLY; For optimistic concurrency control. 44 Etag *string `json:"etag,omitempty"` 45 // ComponentProperties - READ-ONLY; Properties of the component. 46 *ComponentProperties `json:"properties,omitempty"` 47 // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 48 ID *string `json:"id,omitempty"` 49 // Name - READ-ONLY; The name of the resource 50 Name *string `json:"name,omitempty"` 51 // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" 52 Type *string `json:"type,omitempty"` 53} 54 55// MarshalJSON is the custom marshaler for Component. 56func (c Component) MarshalJSON() ([]byte, error) { 57 objectMap := make(map[string]interface{}) 58 return json.Marshal(objectMap) 59} 60 61// UnmarshalJSON is the custom unmarshaler for Component struct. 62func (c *Component) UnmarshalJSON(body []byte) error { 63 var m map[string]*json.RawMessage 64 err := json.Unmarshal(body, &m) 65 if err != nil { 66 return err 67 } 68 for k, v := range m { 69 switch k { 70 case "etag": 71 if v != nil { 72 var etag string 73 err = json.Unmarshal(*v, &etag) 74 if err != nil { 75 return err 76 } 77 c.Etag = &etag 78 } 79 case "properties": 80 if v != nil { 81 var componentProperties ComponentProperties 82 err = json.Unmarshal(*v, &componentProperties) 83 if err != nil { 84 return err 85 } 86 c.ComponentProperties = &componentProperties 87 } 88 case "id": 89 if v != nil { 90 var ID string 91 err = json.Unmarshal(*v, &ID) 92 if err != nil { 93 return err 94 } 95 c.ID = &ID 96 } 97 case "name": 98 if v != nil { 99 var name string 100 err = json.Unmarshal(*v, &name) 101 if err != nil { 102 return err 103 } 104 c.Name = &name 105 } 106 case "type": 107 if v != nil { 108 var typeVar string 109 err = json.Unmarshal(*v, &typeVar) 110 if err != nil { 111 return err 112 } 113 c.Type = &typeVar 114 } 115 } 116 } 117 118 return nil 119} 120 121// ComponentProperties model for properties of a component. 122type ComponentProperties struct { 123 // WorkspaceID - READ-ONLY; ID of the workspace. 124 WorkspaceID *string `json:"workspaceId,omitempty"` 125 // SolutionID - READ-ONLY; ID of the OMS solution this component belong to. 126 SolutionID *string `json:"solutionId,omitempty"` 127 // WorkloadType - READ-ONLY; Type of the workload. Possible values include: 'BaseOS', 'SQL', 'IIS', 'Apache' 128 WorkloadType WorkloadType `json:"workloadType,omitempty"` 129 // ComponentName - READ-ONLY; Name of the component. 130 ComponentName *string `json:"componentName,omitempty"` 131 // ComponentTypeID - READ-ONLY; ID of the component type. 132 ComponentTypeID *string `json:"componentTypeId,omitempty"` 133 // ComponentTypeName - READ-ONLY; Name of the component type. Qualifies the type of component such as whether it is a SQL database, logical disk, website, etc. 134 ComponentTypeName *string `json:"componentTypeName,omitempty"` 135 // ComponentTypeGroupCategory - READ-ONLY; Component type group category. Classification of component type groups into a logical category. e.g. Network, Disk, Memory, CPU. 136 ComponentTypeGroupCategory *string `json:"componentTypeGroupCategory,omitempty"` 137 // HealthState - READ-ONLY; Health state of the component. Possible values include: 'Error', 'Warning', 'Success', 'Unknown', 'Uninitialized' 138 HealthState HealthState `json:"healthState,omitempty"` 139 // HealthStateCategory - READ-ONLY; Category of component's health state. Possible values include: 'Identity', 'CustomGroup' 140 HealthStateCategory HealthStateCategory `json:"healthStateCategory,omitempty"` 141 // HealthStateChangesStartTime - READ-ONLY; Start time for health state changes. 142 HealthStateChangesStartTime *date.Time `json:"healthStateChangesStartTime,omitempty"` 143 // HealthStateChangesEndTime - READ-ONLY; End time for health state changes. 144 HealthStateChangesEndTime *date.Time `json:"healthStateChangesEndTime,omitempty"` 145 // LastHealthStateChangeTime - READ-ONLY; Time of last health state change. 146 LastHealthStateChangeTime *date.Time `json:"lastHealthStateChangeTime,omitempty"` 147 // VMID - READ-ONLY; ID of the VM this component belongs to. 148 VMID *string `json:"vmId,omitempty"` 149 // VMName - READ-ONLY; Name of the VM this component belongs to. 150 VMName *string `json:"vmName,omitempty"` 151 // VMTags - READ-ONLY; Tags on the VM this component belongs to. 152 VMTags map[string]*string `json:"vmTags"` 153 // AggregateProperties - READ-ONLY; Properties requested in aggregation queries. 154 AggregateProperties map[string]*string `json:"aggregateProperties"` 155 // Children - READ-ONLY; component children. 156 Children *[]Component `json:"children,omitempty"` 157} 158 159// MarshalJSON is the custom marshaler for ComponentProperties. 160func (cp ComponentProperties) MarshalJSON() ([]byte, error) { 161 objectMap := make(map[string]interface{}) 162 return json.Marshal(objectMap) 163} 164 165// ComponentsCollection model for collection of components. 166type ComponentsCollection struct { 167 autorest.Response `json:"-"` 168 // NextLink - READ-ONLY; URL to the next set of results. 169 NextLink *string `json:"nextLink,omitempty"` 170 // Value - READ-ONLY; Collection of components. 171 Value *[]Component `json:"value,omitempty"` 172} 173 174// MarshalJSON is the custom marshaler for ComponentsCollection. 175func (cc ComponentsCollection) MarshalJSON() ([]byte, error) { 176 objectMap := make(map[string]interface{}) 177 return json.Marshal(objectMap) 178} 179 180// ComponentsCollectionIterator provides access to a complete listing of Component values. 181type ComponentsCollectionIterator struct { 182 i int 183 page ComponentsCollectionPage 184} 185 186// NextWithContext advances to the next value. If there was an error making 187// the request the iterator does not advance and the error is returned. 188func (iter *ComponentsCollectionIterator) NextWithContext(ctx context.Context) (err error) { 189 if tracing.IsEnabled() { 190 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsCollectionIterator.NextWithContext") 191 defer func() { 192 sc := -1 193 if iter.Response().Response.Response != nil { 194 sc = iter.Response().Response.Response.StatusCode 195 } 196 tracing.EndSpan(ctx, sc, err) 197 }() 198 } 199 iter.i++ 200 if iter.i < len(iter.page.Values()) { 201 return nil 202 } 203 err = iter.page.NextWithContext(ctx) 204 if err != nil { 205 iter.i-- 206 return err 207 } 208 iter.i = 0 209 return nil 210} 211 212// Next advances to the next value. If there was an error making 213// the request the iterator does not advance and the error is returned. 214// Deprecated: Use NextWithContext() instead. 215func (iter *ComponentsCollectionIterator) Next() error { 216 return iter.NextWithContext(context.Background()) 217} 218 219// NotDone returns true if the enumeration should be started or is not yet complete. 220func (iter ComponentsCollectionIterator) NotDone() bool { 221 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 222} 223 224// Response returns the raw server response from the last page request. 225func (iter ComponentsCollectionIterator) Response() ComponentsCollection { 226 return iter.page.Response() 227} 228 229// Value returns the current value or a zero-initialized value if the 230// iterator has advanced beyond the end of the collection. 231func (iter ComponentsCollectionIterator) Value() Component { 232 if !iter.page.NotDone() { 233 return Component{} 234 } 235 return iter.page.Values()[iter.i] 236} 237 238// Creates a new instance of the ComponentsCollectionIterator type. 239func NewComponentsCollectionIterator(page ComponentsCollectionPage) ComponentsCollectionIterator { 240 return ComponentsCollectionIterator{page: page} 241} 242 243// IsEmpty returns true if the ListResult contains no values. 244func (cc ComponentsCollection) IsEmpty() bool { 245 return cc.Value == nil || len(*cc.Value) == 0 246} 247 248// hasNextLink returns true if the NextLink is not empty. 249func (cc ComponentsCollection) hasNextLink() bool { 250 return cc.NextLink != nil && len(*cc.NextLink) != 0 251} 252 253// componentsCollectionPreparer prepares a request to retrieve the next set of results. 254// It returns nil if no more results exist. 255func (cc ComponentsCollection) componentsCollectionPreparer(ctx context.Context) (*http.Request, error) { 256 if !cc.hasNextLink() { 257 return nil, nil 258 } 259 return autorest.Prepare((&http.Request{}).WithContext(ctx), 260 autorest.AsJSON(), 261 autorest.AsGet(), 262 autorest.WithBaseURL(to.String(cc.NextLink))) 263} 264 265// ComponentsCollectionPage contains a page of Component values. 266type ComponentsCollectionPage struct { 267 fn func(context.Context, ComponentsCollection) (ComponentsCollection, error) 268 cc ComponentsCollection 269} 270 271// NextWithContext advances to the next page of values. If there was an error making 272// the request the page does not advance and the error is returned. 273func (page *ComponentsCollectionPage) NextWithContext(ctx context.Context) (err error) { 274 if tracing.IsEnabled() { 275 ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsCollectionPage.NextWithContext") 276 defer func() { 277 sc := -1 278 if page.Response().Response.Response != nil { 279 sc = page.Response().Response.Response.StatusCode 280 } 281 tracing.EndSpan(ctx, sc, err) 282 }() 283 } 284 for { 285 next, err := page.fn(ctx, page.cc) 286 if err != nil { 287 return err 288 } 289 page.cc = next 290 if !next.hasNextLink() || !next.IsEmpty() { 291 break 292 } 293 } 294 return nil 295} 296 297// Next advances to the next page of values. If there was an error making 298// the request the page does not advance and the error is returned. 299// Deprecated: Use NextWithContext() instead. 300func (page *ComponentsCollectionPage) Next() error { 301 return page.NextWithContext(context.Background()) 302} 303 304// NotDone returns true if the page enumeration should be started or is not yet complete. 305func (page ComponentsCollectionPage) NotDone() bool { 306 return !page.cc.IsEmpty() 307} 308 309// Response returns the raw server response from the last page request. 310func (page ComponentsCollectionPage) Response() ComponentsCollection { 311 return page.cc 312} 313 314// Values returns the slice of values for the current page or nil if there are no values. 315func (page ComponentsCollectionPage) Values() []Component { 316 if page.cc.IsEmpty() { 317 return nil 318 } 319 return *page.cc.Value 320} 321 322// Creates a new instance of the ComponentsCollectionPage type. 323func NewComponentsCollectionPage(cur ComponentsCollection, getNextPage func(context.Context, ComponentsCollection) (ComponentsCollection, error)) ComponentsCollectionPage { 324 return ComponentsCollectionPage{ 325 fn: getNextPage, 326 cc: cur, 327 } 328} 329 330// ErrorFieldContract error field contract. 331type ErrorFieldContract struct { 332 // Code - Property level error code. 333 Code *string `json:"code,omitempty"` 334 // Message - Human-readable representation of property-level error. 335 Message *string `json:"message,omitempty"` 336 // Target - Property name. 337 Target *string `json:"target,omitempty"` 338} 339 340// ErrorResponse error body contract. 341type ErrorResponse struct { 342 // Code - Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. 343 Code *string `json:"code,omitempty"` 344 // Message - Human-readable representation of the error. 345 Message *string `json:"message,omitempty"` 346 // Details - The list of invalid fields send in request, in case of validation error. 347 Details *[]ErrorFieldContract `json:"details,omitempty"` 348} 349 350// HealthStateChange model for health state change 351type HealthStateChange struct { 352 // HealthState - READ-ONLY; Health state of monitor instance. Possible values include: 'Error', 'Warning', 'Success', 'Unknown', 'Uninitialized' 353 HealthState HealthState `json:"healthState,omitempty"` 354 // HealthStateChangeTime - READ-ONLY; Time at which this Health state was reached. 355 HealthStateChangeTime *date.Time `json:"healthStateChangeTime,omitempty"` 356} 357 358// MarshalJSON is the custom marshaler for HealthStateChange. 359func (hsc HealthStateChange) MarshalJSON() ([]byte, error) { 360 objectMap := make(map[string]interface{}) 361 return json.Marshal(objectMap) 362} 363 364// Monitor model for Monitor 365type Monitor struct { 366 autorest.Response `json:"-"` 367 // Etag - READ-ONLY; For optimistic concurrency control. 368 Etag *string `json:"etag,omitempty"` 369 // MonitorProperties - READ-ONLY; Properties of monitor instance 370 *MonitorProperties `json:"properties,omitempty"` 371 // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 372 ID *string `json:"id,omitempty"` 373 // Name - READ-ONLY; The name of the resource 374 Name *string `json:"name,omitempty"` 375 // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" 376 Type *string `json:"type,omitempty"` 377} 378 379// MarshalJSON is the custom marshaler for Monitor. 380func (mVar Monitor) MarshalJSON() ([]byte, error) { 381 objectMap := make(map[string]interface{}) 382 return json.Marshal(objectMap) 383} 384 385// UnmarshalJSON is the custom unmarshaler for Monitor struct. 386func (mVar *Monitor) UnmarshalJSON(body []byte) error { 387 var m map[string]*json.RawMessage 388 err := json.Unmarshal(body, &m) 389 if err != nil { 390 return err 391 } 392 for k, v := range m { 393 switch k { 394 case "etag": 395 if v != nil { 396 var etag string 397 err = json.Unmarshal(*v, &etag) 398 if err != nil { 399 return err 400 } 401 mVar.Etag = &etag 402 } 403 case "properties": 404 if v != nil { 405 var monitorProperties MonitorProperties 406 err = json.Unmarshal(*v, &monitorProperties) 407 if err != nil { 408 return err 409 } 410 mVar.MonitorProperties = &monitorProperties 411 } 412 case "id": 413 if v != nil { 414 var ID string 415 err = json.Unmarshal(*v, &ID) 416 if err != nil { 417 return err 418 } 419 mVar.ID = &ID 420 } 421 case "name": 422 if v != nil { 423 var name string 424 err = json.Unmarshal(*v, &name) 425 if err != nil { 426 return err 427 } 428 mVar.Name = &name 429 } 430 case "type": 431 if v != nil { 432 var typeVar string 433 err = json.Unmarshal(*v, &typeVar) 434 if err != nil { 435 return err 436 } 437 mVar.Type = &typeVar 438 } 439 } 440 } 441 442 return nil 443} 444 445// MonitorCriteria criteria for monitor configuration 446type MonitorCriteria struct { 447 // HealthState - READ-ONLY; Target health state of the criteria. Possible values include: 'Error', 'Warning', 'Success', 'Unknown', 'Uninitialized' 448 HealthState HealthState `json:"healthState,omitempty"` 449 // Threshold - READ-ONLY; Threshold value for this criteria 450 Threshold *float64 `json:"threshold,omitempty"` 451 // ComparisonOperator - READ-ONLY; Comparison enum on threshold of this criteria. Possible values include: 'Equals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual', 'NotEquals' 452 ComparisonOperator Operator `json:"comparisonOperator,omitempty"` 453} 454 455// MarshalJSON is the custom marshaler for MonitorCriteria. 456func (mc MonitorCriteria) MarshalJSON() ([]byte, error) { 457 objectMap := make(map[string]interface{}) 458 return json.Marshal(objectMap) 459} 460 461// MonitorInstance model for monitor instance. 462type MonitorInstance struct { 463 autorest.Response `json:"-"` 464 // Etag - READ-ONLY; For optimistic concurrency control. 465 Etag *string `json:"etag,omitempty"` 466 // MonitorInstanceProperties - READ-ONLY; Properties of the monitor instance. 467 *MonitorInstanceProperties `json:"properties,omitempty"` 468 // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 469 ID *string `json:"id,omitempty"` 470 // Name - READ-ONLY; The name of the resource 471 Name *string `json:"name,omitempty"` 472 // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" 473 Type *string `json:"type,omitempty"` 474} 475 476// MarshalJSON is the custom marshaler for MonitorInstance. 477func (mi MonitorInstance) MarshalJSON() ([]byte, error) { 478 objectMap := make(map[string]interface{}) 479 return json.Marshal(objectMap) 480} 481 482// UnmarshalJSON is the custom unmarshaler for MonitorInstance struct. 483func (mi *MonitorInstance) UnmarshalJSON(body []byte) error { 484 var m map[string]*json.RawMessage 485 err := json.Unmarshal(body, &m) 486 if err != nil { 487 return err 488 } 489 for k, v := range m { 490 switch k { 491 case "etag": 492 if v != nil { 493 var etag string 494 err = json.Unmarshal(*v, &etag) 495 if err != nil { 496 return err 497 } 498 mi.Etag = &etag 499 } 500 case "properties": 501 if v != nil { 502 var monitorInstanceProperties MonitorInstanceProperties 503 err = json.Unmarshal(*v, &monitorInstanceProperties) 504 if err != nil { 505 return err 506 } 507 mi.MonitorInstanceProperties = &monitorInstanceProperties 508 } 509 case "id": 510 if v != nil { 511 var ID string 512 err = json.Unmarshal(*v, &ID) 513 if err != nil { 514 return err 515 } 516 mi.ID = &ID 517 } 518 case "name": 519 if v != nil { 520 var name string 521 err = json.Unmarshal(*v, &name) 522 if err != nil { 523 return err 524 } 525 mi.Name = &name 526 } 527 case "type": 528 if v != nil { 529 var typeVar string 530 err = json.Unmarshal(*v, &typeVar) 531 if err != nil { 532 return err 533 } 534 mi.Type = &typeVar 535 } 536 } 537 } 538 539 return nil 540} 541 542// MonitorInstanceProperties model for properties of a monitor instance. 543type MonitorInstanceProperties struct { 544 // WorkspaceID - READ-ONLY; ID of the workspace. 545 WorkspaceID *string `json:"workspaceId,omitempty"` 546 // SolutionID - READ-ONLY; ID of the OMS solution this health instance belong to. 547 SolutionID *string `json:"solutionId,omitempty"` 548 // WorkloadType - READ-ONLY; Type of the workload. Possible values include: 'BaseOS', 'SQL', 'IIS', 'Apache' 549 WorkloadType WorkloadType `json:"workloadType,omitempty"` 550 // ComponentID - READ-ONLY; ID of the component. 551 ComponentID *string `json:"componentId,omitempty"` 552 // ComponentName - READ-ONLY; Name of the component. 553 ComponentName *string `json:"componentName,omitempty"` 554 // ComponentTypeID - READ-ONLY; ID of the component type. 555 ComponentTypeID *string `json:"componentTypeId,omitempty"` 556 // ComponentTypeName - READ-ONLY; Name of the component type. Qualifies the type of component such as whether it is a SQL database, logical disk, website, etc. 557 ComponentTypeName *string `json:"componentTypeName,omitempty"` 558 // MonitorID - READ-ONLY; ID of the monitor instance. 559 MonitorID *string `json:"monitorId,omitempty"` 560 // MonitorName - READ-ONLY; Name of the monitor. 561 MonitorName *string `json:"monitorName,omitempty"` 562 // MonitorType - READ-ONLY; Type of the monitor. The qualifier for the health criteria depending on the functionality it performs such as Unit, Aggregate, Dependency. Possible values include: 'Aggregate', 'Dependency', 'Unit' 563 MonitorType MonitorType `json:"monitorType,omitempty"` 564 // MonitorCategory - READ-ONLY; Monitor type category. Indicates the attribute of the component that the health criteria monitors such as Performance, Availability, etc. Possible values include: 'AvailabilityHealth', 'Configuration', 'EntityHealth', 'PerformanceHealth', 'Security' 565 MonitorCategory MonitorCategory `json:"monitorCategory,omitempty"` 566 // HealthState - READ-ONLY; Health state of monitor instance. Possible values include: 'Error', 'Warning', 'Success', 'Unknown', 'Uninitialized' 567 HealthState HealthState `json:"healthState,omitempty"` 568 // HealthStateCategory - READ-ONLY; Category of monitor instance's health state. Possible values include: 'Identity', 'CustomGroup' 569 HealthStateCategory HealthStateCategory `json:"healthStateCategory,omitempty"` 570 // HealthStateChanges - READ-ONLY; Health state changes. 571 HealthStateChanges *[]HealthStateChange `json:"healthStateChanges,omitempty"` 572 // HealthStateChangesStartTime - READ-ONLY; Start time for health state changes. 573 HealthStateChangesStartTime *date.Time `json:"healthStateChangesStartTime,omitempty"` 574 // HealthStateChangesEndTime - READ-ONLY; End time for health state changes. 575 HealthStateChangesEndTime *date.Time `json:"healthStateChangesEndTime,omitempty"` 576 // LastHealthStateChangeTime - READ-ONLY; Time of last health state change. 577 LastHealthStateChangeTime *date.Time `json:"lastHealthStateChangeTime,omitempty"` 578 // AlertGeneration - READ-ONLY; Generates alert or not. Possible values include: 'Enabled', 'Disabled' 579 AlertGeneration AlertGeneration `json:"alertGeneration,omitempty"` 580 // AggregateProperties - READ-ONLY; Properties requested in aggregation queries. 581 AggregateProperties map[string]*string `json:"aggregateProperties"` 582 // Children - READ-ONLY; Health instance children. 583 Children *[]MonitorInstance `json:"children,omitempty"` 584} 585 586// MarshalJSON is the custom marshaler for MonitorInstanceProperties. 587func (mip MonitorInstanceProperties) MarshalJSON() ([]byte, error) { 588 objectMap := make(map[string]interface{}) 589 return json.Marshal(objectMap) 590} 591 592// MonitorInstancesCollection model for collection of health instances. 593type MonitorInstancesCollection struct { 594 autorest.Response `json:"-"` 595 // NextLink - READ-ONLY; URL to the next set of results. 596 NextLink *string `json:"nextLink,omitempty"` 597 // Value - READ-ONLY; Collection of health instances. 598 Value *[]MonitorInstance `json:"value,omitempty"` 599} 600 601// MarshalJSON is the custom marshaler for MonitorInstancesCollection. 602func (mic MonitorInstancesCollection) MarshalJSON() ([]byte, error) { 603 objectMap := make(map[string]interface{}) 604 return json.Marshal(objectMap) 605} 606 607// MonitorInstancesCollectionIterator provides access to a complete listing of MonitorInstance values. 608type MonitorInstancesCollectionIterator struct { 609 i int 610 page MonitorInstancesCollectionPage 611} 612 613// NextWithContext advances to the next value. If there was an error making 614// the request the iterator does not advance and the error is returned. 615func (iter *MonitorInstancesCollectionIterator) NextWithContext(ctx context.Context) (err error) { 616 if tracing.IsEnabled() { 617 ctx = tracing.StartSpan(ctx, fqdn+"/MonitorInstancesCollectionIterator.NextWithContext") 618 defer func() { 619 sc := -1 620 if iter.Response().Response.Response != nil { 621 sc = iter.Response().Response.Response.StatusCode 622 } 623 tracing.EndSpan(ctx, sc, err) 624 }() 625 } 626 iter.i++ 627 if iter.i < len(iter.page.Values()) { 628 return nil 629 } 630 err = iter.page.NextWithContext(ctx) 631 if err != nil { 632 iter.i-- 633 return err 634 } 635 iter.i = 0 636 return nil 637} 638 639// Next advances to the next value. If there was an error making 640// the request the iterator does not advance and the error is returned. 641// Deprecated: Use NextWithContext() instead. 642func (iter *MonitorInstancesCollectionIterator) Next() error { 643 return iter.NextWithContext(context.Background()) 644} 645 646// NotDone returns true if the enumeration should be started or is not yet complete. 647func (iter MonitorInstancesCollectionIterator) NotDone() bool { 648 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 649} 650 651// Response returns the raw server response from the last page request. 652func (iter MonitorInstancesCollectionIterator) Response() MonitorInstancesCollection { 653 return iter.page.Response() 654} 655 656// Value returns the current value or a zero-initialized value if the 657// iterator has advanced beyond the end of the collection. 658func (iter MonitorInstancesCollectionIterator) Value() MonitorInstance { 659 if !iter.page.NotDone() { 660 return MonitorInstance{} 661 } 662 return iter.page.Values()[iter.i] 663} 664 665// Creates a new instance of the MonitorInstancesCollectionIterator type. 666func NewMonitorInstancesCollectionIterator(page MonitorInstancesCollectionPage) MonitorInstancesCollectionIterator { 667 return MonitorInstancesCollectionIterator{page: page} 668} 669 670// IsEmpty returns true if the ListResult contains no values. 671func (mic MonitorInstancesCollection) IsEmpty() bool { 672 return mic.Value == nil || len(*mic.Value) == 0 673} 674 675// hasNextLink returns true if the NextLink is not empty. 676func (mic MonitorInstancesCollection) hasNextLink() bool { 677 return mic.NextLink != nil && len(*mic.NextLink) != 0 678} 679 680// monitorInstancesCollectionPreparer prepares a request to retrieve the next set of results. 681// It returns nil if no more results exist. 682func (mic MonitorInstancesCollection) monitorInstancesCollectionPreparer(ctx context.Context) (*http.Request, error) { 683 if !mic.hasNextLink() { 684 return nil, nil 685 } 686 return autorest.Prepare((&http.Request{}).WithContext(ctx), 687 autorest.AsJSON(), 688 autorest.AsGet(), 689 autorest.WithBaseURL(to.String(mic.NextLink))) 690} 691 692// MonitorInstancesCollectionPage contains a page of MonitorInstance values. 693type MonitorInstancesCollectionPage struct { 694 fn func(context.Context, MonitorInstancesCollection) (MonitorInstancesCollection, error) 695 mic MonitorInstancesCollection 696} 697 698// NextWithContext advances to the next page of values. If there was an error making 699// the request the page does not advance and the error is returned. 700func (page *MonitorInstancesCollectionPage) NextWithContext(ctx context.Context) (err error) { 701 if tracing.IsEnabled() { 702 ctx = tracing.StartSpan(ctx, fqdn+"/MonitorInstancesCollectionPage.NextWithContext") 703 defer func() { 704 sc := -1 705 if page.Response().Response.Response != nil { 706 sc = page.Response().Response.Response.StatusCode 707 } 708 tracing.EndSpan(ctx, sc, err) 709 }() 710 } 711 for { 712 next, err := page.fn(ctx, page.mic) 713 if err != nil { 714 return err 715 } 716 page.mic = next 717 if !next.hasNextLink() || !next.IsEmpty() { 718 break 719 } 720 } 721 return nil 722} 723 724// Next advances to the next page of values. If there was an error making 725// the request the page does not advance and the error is returned. 726// Deprecated: Use NextWithContext() instead. 727func (page *MonitorInstancesCollectionPage) Next() error { 728 return page.NextWithContext(context.Background()) 729} 730 731// NotDone returns true if the page enumeration should be started or is not yet complete. 732func (page MonitorInstancesCollectionPage) NotDone() bool { 733 return !page.mic.IsEmpty() 734} 735 736// Response returns the raw server response from the last page request. 737func (page MonitorInstancesCollectionPage) Response() MonitorInstancesCollection { 738 return page.mic 739} 740 741// Values returns the slice of values for the current page or nil if there are no values. 742func (page MonitorInstancesCollectionPage) Values() []MonitorInstance { 743 if page.mic.IsEmpty() { 744 return nil 745 } 746 return *page.mic.Value 747} 748 749// Creates a new instance of the MonitorInstancesCollectionPage type. 750func NewMonitorInstancesCollectionPage(cur MonitorInstancesCollection, getNextPage func(context.Context, MonitorInstancesCollection) (MonitorInstancesCollection, error)) MonitorInstancesCollectionPage { 751 return MonitorInstancesCollectionPage{ 752 fn: getNextPage, 753 mic: cur, 754 } 755} 756 757// MonitorProperties model for properties of a Monitor. 758type MonitorProperties struct { 759 // Description - READ-ONLY; Description of the monitor 760 Description *string `json:"description,omitempty"` 761 // MonitorID - READ-ONLY; ID of the monitor 762 MonitorID *string `json:"monitorId,omitempty"` 763 // MonitorName - READ-ONLY; Name of the monitor 764 MonitorName *string `json:"monitorName,omitempty"` 765 // MonitorDisplayName - READ-ONLY; User friendly display name of the monitor 766 MonitorDisplayName *string `json:"monitorDisplayName,omitempty"` 767 // ParentMonitorName - READ-ONLY; Name of the parent monitor 768 ParentMonitorName *string `json:"parentMonitorName,omitempty"` 769 // ParentMonitorDisplayName - READ-ONLY; User friendly display name of the parent monitor 770 ParentMonitorDisplayName *string `json:"parentMonitorDisplayName,omitempty"` 771 // MonitorType - READ-ONLY; Type of the monitor. Possible values include: 'Aggregate', 'Dependency', 'Unit' 772 MonitorType MonitorType `json:"monitorType,omitempty"` 773 // MonitorCategory - READ-ONLY; Category of the monitor. Possible values include: 'AvailabilityHealth', 'Configuration', 'EntityHealth', 'PerformanceHealth', 'Security' 774 MonitorCategory MonitorCategory `json:"monitorCategory,omitempty"` 775 // ComponentTypeID - READ-ONLY; Component Type Id of monitor 776 ComponentTypeID *string `json:"componentTypeId,omitempty"` 777 // ComponentTypeName - READ-ONLY; Component Type Name of monitor 778 ComponentTypeName *string `json:"componentTypeName,omitempty"` 779 // ComponentTypeDisplayName - READ-ONLY; Component Type Display Name of the monitor 780 ComponentTypeDisplayName *string `json:"componentTypeDisplayName,omitempty"` 781 // MonitorState - READ-ONLY; Is the monitor state enabled or disabled. Possible values include: 'MonitorStateEnabled', 'MonitorStateDisabled' 782 MonitorState MonitorState `json:"monitorState,omitempty"` 783 // Criteria - READ-ONLY; Collection of MonitorCriteria. For PATCH calls, instead of partial list, complete list of expected criteria should be passed for proper updating. 784 Criteria *[]MonitorCriteria `json:"criteria,omitempty"` 785 // AlertGeneration - READ-ONLY; Generates alerts or not. Possible values include: 'Enabled', 'Disabled' 786 AlertGeneration AlertGeneration `json:"alertGeneration,omitempty"` 787 // Frequency - READ-ONLY; Frequency at which monitor condition is evaluated 788 Frequency *int32 `json:"frequency,omitempty"` 789 // LookbackDuration - READ-ONLY; The duration in minutes in the past during which the monitor is evaluated 790 LookbackDuration *int32 `json:"lookbackDuration,omitempty"` 791 // DocumentationURL - READ-ONLY; URL pointing to the documentation of the monitor 792 DocumentationURL *string `json:"documentationURL,omitempty"` 793 // SignalName - READ-ONLY; Name of the signal on which this monitor is configured. 794 SignalName *string `json:"signalName,omitempty"` 795 // SignalType - READ-ONLY; Type of the signal on which this monitor is configured. 796 SignalType *string `json:"signalType,omitempty"` 797} 798 799// MarshalJSON is the custom marshaler for MonitorProperties. 800func (mp MonitorProperties) MarshalJSON() ([]byte, error) { 801 objectMap := make(map[string]interface{}) 802 return json.Marshal(objectMap) 803} 804 805// MonitorsCollection model for collection of Monitor. 806type MonitorsCollection struct { 807 autorest.Response `json:"-"` 808 // NextLink - READ-ONLY; URL for next set of results. 809 NextLink *string `json:"nextLink,omitempty"` 810 // Value - READ-ONLY; Collection of Monitor. 811 Value *[]Monitor `json:"value,omitempty"` 812} 813 814// MarshalJSON is the custom marshaler for MonitorsCollection. 815func (mc MonitorsCollection) MarshalJSON() ([]byte, error) { 816 objectMap := make(map[string]interface{}) 817 return json.Marshal(objectMap) 818} 819 820// MonitorsCollectionIterator provides access to a complete listing of Monitor values. 821type MonitorsCollectionIterator struct { 822 i int 823 page MonitorsCollectionPage 824} 825 826// NextWithContext advances to the next value. If there was an error making 827// the request the iterator does not advance and the error is returned. 828func (iter *MonitorsCollectionIterator) NextWithContext(ctx context.Context) (err error) { 829 if tracing.IsEnabled() { 830 ctx = tracing.StartSpan(ctx, fqdn+"/MonitorsCollectionIterator.NextWithContext") 831 defer func() { 832 sc := -1 833 if iter.Response().Response.Response != nil { 834 sc = iter.Response().Response.Response.StatusCode 835 } 836 tracing.EndSpan(ctx, sc, err) 837 }() 838 } 839 iter.i++ 840 if iter.i < len(iter.page.Values()) { 841 return nil 842 } 843 err = iter.page.NextWithContext(ctx) 844 if err != nil { 845 iter.i-- 846 return err 847 } 848 iter.i = 0 849 return nil 850} 851 852// Next advances to the next value. If there was an error making 853// the request the iterator does not advance and the error is returned. 854// Deprecated: Use NextWithContext() instead. 855func (iter *MonitorsCollectionIterator) Next() error { 856 return iter.NextWithContext(context.Background()) 857} 858 859// NotDone returns true if the enumeration should be started or is not yet complete. 860func (iter MonitorsCollectionIterator) NotDone() bool { 861 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 862} 863 864// Response returns the raw server response from the last page request. 865func (iter MonitorsCollectionIterator) Response() MonitorsCollection { 866 return iter.page.Response() 867} 868 869// Value returns the current value or a zero-initialized value if the 870// iterator has advanced beyond the end of the collection. 871func (iter MonitorsCollectionIterator) Value() Monitor { 872 if !iter.page.NotDone() { 873 return Monitor{} 874 } 875 return iter.page.Values()[iter.i] 876} 877 878// Creates a new instance of the MonitorsCollectionIterator type. 879func NewMonitorsCollectionIterator(page MonitorsCollectionPage) MonitorsCollectionIterator { 880 return MonitorsCollectionIterator{page: page} 881} 882 883// IsEmpty returns true if the ListResult contains no values. 884func (mc MonitorsCollection) IsEmpty() bool { 885 return mc.Value == nil || len(*mc.Value) == 0 886} 887 888// hasNextLink returns true if the NextLink is not empty. 889func (mc MonitorsCollection) hasNextLink() bool { 890 return mc.NextLink != nil && len(*mc.NextLink) != 0 891} 892 893// monitorsCollectionPreparer prepares a request to retrieve the next set of results. 894// It returns nil if no more results exist. 895func (mc MonitorsCollection) monitorsCollectionPreparer(ctx context.Context) (*http.Request, error) { 896 if !mc.hasNextLink() { 897 return nil, nil 898 } 899 return autorest.Prepare((&http.Request{}).WithContext(ctx), 900 autorest.AsJSON(), 901 autorest.AsGet(), 902 autorest.WithBaseURL(to.String(mc.NextLink))) 903} 904 905// MonitorsCollectionPage contains a page of Monitor values. 906type MonitorsCollectionPage struct { 907 fn func(context.Context, MonitorsCollection) (MonitorsCollection, error) 908 mc MonitorsCollection 909} 910 911// NextWithContext advances to the next page of values. If there was an error making 912// the request the page does not advance and the error is returned. 913func (page *MonitorsCollectionPage) NextWithContext(ctx context.Context) (err error) { 914 if tracing.IsEnabled() { 915 ctx = tracing.StartSpan(ctx, fqdn+"/MonitorsCollectionPage.NextWithContext") 916 defer func() { 917 sc := -1 918 if page.Response().Response.Response != nil { 919 sc = page.Response().Response.Response.StatusCode 920 } 921 tracing.EndSpan(ctx, sc, err) 922 }() 923 } 924 for { 925 next, err := page.fn(ctx, page.mc) 926 if err != nil { 927 return err 928 } 929 page.mc = next 930 if !next.hasNextLink() || !next.IsEmpty() { 931 break 932 } 933 } 934 return nil 935} 936 937// Next advances to the next page of values. If there was an error making 938// the request the page does not advance and the error is returned. 939// Deprecated: Use NextWithContext() instead. 940func (page *MonitorsCollectionPage) Next() error { 941 return page.NextWithContext(context.Background()) 942} 943 944// NotDone returns true if the page enumeration should be started or is not yet complete. 945func (page MonitorsCollectionPage) NotDone() bool { 946 return !page.mc.IsEmpty() 947} 948 949// Response returns the raw server response from the last page request. 950func (page MonitorsCollectionPage) Response() MonitorsCollection { 951 return page.mc 952} 953 954// Values returns the slice of values for the current page or nil if there are no values. 955func (page MonitorsCollectionPage) Values() []Monitor { 956 if page.mc.IsEmpty() { 957 return nil 958 } 959 return *page.mc.Value 960} 961 962// Creates a new instance of the MonitorsCollectionPage type. 963func NewMonitorsCollectionPage(cur MonitorsCollection, getNextPage func(context.Context, MonitorsCollection) (MonitorsCollection, error)) MonitorsCollectionPage { 964 return MonitorsCollectionPage{ 965 fn: getNextPage, 966 mc: cur, 967 } 968} 969 970// NotificationSetting model for NotificationSetting. 971type NotificationSetting struct { 972 autorest.Response `json:"-"` 973 // Etag - READ-ONLY; For optimistic concurrency control. 974 Etag *string `json:"etag,omitempty"` 975 // NotificationSettingProperties - READ-ONLY; Properties of Notification Settings 976 *NotificationSettingProperties `json:"properties,omitempty"` 977 // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 978 ID *string `json:"id,omitempty"` 979 // Name - READ-ONLY; The name of the resource 980 Name *string `json:"name,omitempty"` 981 // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" 982 Type *string `json:"type,omitempty"` 983} 984 985// MarshalJSON is the custom marshaler for NotificationSetting. 986func (ns NotificationSetting) MarshalJSON() ([]byte, error) { 987 objectMap := make(map[string]interface{}) 988 return json.Marshal(objectMap) 989} 990 991// UnmarshalJSON is the custom unmarshaler for NotificationSetting struct. 992func (ns *NotificationSetting) UnmarshalJSON(body []byte) error { 993 var m map[string]*json.RawMessage 994 err := json.Unmarshal(body, &m) 995 if err != nil { 996 return err 997 } 998 for k, v := range m { 999 switch k { 1000 case "etag": 1001 if v != nil { 1002 var etag string 1003 err = json.Unmarshal(*v, &etag) 1004 if err != nil { 1005 return err 1006 } 1007 ns.Etag = &etag 1008 } 1009 case "properties": 1010 if v != nil { 1011 var notificationSettingProperties NotificationSettingProperties 1012 err = json.Unmarshal(*v, ¬ificationSettingProperties) 1013 if err != nil { 1014 return err 1015 } 1016 ns.NotificationSettingProperties = ¬ificationSettingProperties 1017 } 1018 case "id": 1019 if v != nil { 1020 var ID string 1021 err = json.Unmarshal(*v, &ID) 1022 if err != nil { 1023 return err 1024 } 1025 ns.ID = &ID 1026 } 1027 case "name": 1028 if v != nil { 1029 var name string 1030 err = json.Unmarshal(*v, &name) 1031 if err != nil { 1032 return err 1033 } 1034 ns.Name = &name 1035 } 1036 case "type": 1037 if v != nil { 1038 var typeVar string 1039 err = json.Unmarshal(*v, &typeVar) 1040 if err != nil { 1041 return err 1042 } 1043 ns.Type = &typeVar 1044 } 1045 } 1046 } 1047 1048 return nil 1049} 1050 1051// NotificationSettingProperties model for properties of a NotificationSetting. 1052type NotificationSettingProperties struct { 1053 // ActionGroupResourceIds - READ-ONLY; List of action group resource ids to be notified 1054 ActionGroupResourceIds *[]string `json:"actionGroupResourceIds,omitempty"` 1055} 1056 1057// MarshalJSON is the custom marshaler for NotificationSettingProperties. 1058func (nsp NotificationSettingProperties) MarshalJSON() ([]byte, error) { 1059 objectMap := make(map[string]interface{}) 1060 return json.Marshal(objectMap) 1061} 1062 1063// NotificationSettingsCollection model for collection of notificationSettings. 1064type NotificationSettingsCollection struct { 1065 autorest.Response `json:"-"` 1066 Value *[]NotificationSetting `json:"value,omitempty"` 1067 // NextLink - READ-ONLY; URL to the next set of results. 1068 NextLink *string `json:"nextLink,omitempty"` 1069} 1070 1071// MarshalJSON is the custom marshaler for NotificationSettingsCollection. 1072func (nsc NotificationSettingsCollection) MarshalJSON() ([]byte, error) { 1073 objectMap := make(map[string]interface{}) 1074 if nsc.Value != nil { 1075 objectMap["value"] = nsc.Value 1076 } 1077 return json.Marshal(objectMap) 1078} 1079 1080// NotificationSettingsCollectionIterator provides access to a complete listing of NotificationSetting 1081// values. 1082type NotificationSettingsCollectionIterator struct { 1083 i int 1084 page NotificationSettingsCollectionPage 1085} 1086 1087// NextWithContext advances to the next value. If there was an error making 1088// the request the iterator does not advance and the error is returned. 1089func (iter *NotificationSettingsCollectionIterator) NextWithContext(ctx context.Context) (err error) { 1090 if tracing.IsEnabled() { 1091 ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsCollectionIterator.NextWithContext") 1092 defer func() { 1093 sc := -1 1094 if iter.Response().Response.Response != nil { 1095 sc = iter.Response().Response.Response.StatusCode 1096 } 1097 tracing.EndSpan(ctx, sc, err) 1098 }() 1099 } 1100 iter.i++ 1101 if iter.i < len(iter.page.Values()) { 1102 return nil 1103 } 1104 err = iter.page.NextWithContext(ctx) 1105 if err != nil { 1106 iter.i-- 1107 return err 1108 } 1109 iter.i = 0 1110 return nil 1111} 1112 1113// Next advances to the next value. If there was an error making 1114// the request the iterator does not advance and the error is returned. 1115// Deprecated: Use NextWithContext() instead. 1116func (iter *NotificationSettingsCollectionIterator) Next() error { 1117 return iter.NextWithContext(context.Background()) 1118} 1119 1120// NotDone returns true if the enumeration should be started or is not yet complete. 1121func (iter NotificationSettingsCollectionIterator) NotDone() bool { 1122 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1123} 1124 1125// Response returns the raw server response from the last page request. 1126func (iter NotificationSettingsCollectionIterator) Response() NotificationSettingsCollection { 1127 return iter.page.Response() 1128} 1129 1130// Value returns the current value or a zero-initialized value if the 1131// iterator has advanced beyond the end of the collection. 1132func (iter NotificationSettingsCollectionIterator) Value() NotificationSetting { 1133 if !iter.page.NotDone() { 1134 return NotificationSetting{} 1135 } 1136 return iter.page.Values()[iter.i] 1137} 1138 1139// Creates a new instance of the NotificationSettingsCollectionIterator type. 1140func NewNotificationSettingsCollectionIterator(page NotificationSettingsCollectionPage) NotificationSettingsCollectionIterator { 1141 return NotificationSettingsCollectionIterator{page: page} 1142} 1143 1144// IsEmpty returns true if the ListResult contains no values. 1145func (nsc NotificationSettingsCollection) IsEmpty() bool { 1146 return nsc.Value == nil || len(*nsc.Value) == 0 1147} 1148 1149// hasNextLink returns true if the NextLink is not empty. 1150func (nsc NotificationSettingsCollection) hasNextLink() bool { 1151 return nsc.NextLink != nil && len(*nsc.NextLink) != 0 1152} 1153 1154// notificationSettingsCollectionPreparer prepares a request to retrieve the next set of results. 1155// It returns nil if no more results exist. 1156func (nsc NotificationSettingsCollection) notificationSettingsCollectionPreparer(ctx context.Context) (*http.Request, error) { 1157 if !nsc.hasNextLink() { 1158 return nil, nil 1159 } 1160 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1161 autorest.AsJSON(), 1162 autorest.AsGet(), 1163 autorest.WithBaseURL(to.String(nsc.NextLink))) 1164} 1165 1166// NotificationSettingsCollectionPage contains a page of NotificationSetting values. 1167type NotificationSettingsCollectionPage struct { 1168 fn func(context.Context, NotificationSettingsCollection) (NotificationSettingsCollection, error) 1169 nsc NotificationSettingsCollection 1170} 1171 1172// NextWithContext advances to the next page of values. If there was an error making 1173// the request the page does not advance and the error is returned. 1174func (page *NotificationSettingsCollectionPage) NextWithContext(ctx context.Context) (err error) { 1175 if tracing.IsEnabled() { 1176 ctx = tracing.StartSpan(ctx, fqdn+"/NotificationSettingsCollectionPage.NextWithContext") 1177 defer func() { 1178 sc := -1 1179 if page.Response().Response.Response != nil { 1180 sc = page.Response().Response.Response.StatusCode 1181 } 1182 tracing.EndSpan(ctx, sc, err) 1183 }() 1184 } 1185 for { 1186 next, err := page.fn(ctx, page.nsc) 1187 if err != nil { 1188 return err 1189 } 1190 page.nsc = next 1191 if !next.hasNextLink() || !next.IsEmpty() { 1192 break 1193 } 1194 } 1195 return nil 1196} 1197 1198// Next advances to the next page of values. If there was an error making 1199// the request the page does not advance and the error is returned. 1200// Deprecated: Use NextWithContext() instead. 1201func (page *NotificationSettingsCollectionPage) Next() error { 1202 return page.NextWithContext(context.Background()) 1203} 1204 1205// NotDone returns true if the page enumeration should be started or is not yet complete. 1206func (page NotificationSettingsCollectionPage) NotDone() bool { 1207 return !page.nsc.IsEmpty() 1208} 1209 1210// Response returns the raw server response from the last page request. 1211func (page NotificationSettingsCollectionPage) Response() NotificationSettingsCollection { 1212 return page.nsc 1213} 1214 1215// Values returns the slice of values for the current page or nil if there are no values. 1216func (page NotificationSettingsCollectionPage) Values() []NotificationSetting { 1217 if page.nsc.IsEmpty() { 1218 return nil 1219 } 1220 return *page.nsc.Value 1221} 1222 1223// Creates a new instance of the NotificationSettingsCollectionPage type. 1224func NewNotificationSettingsCollectionPage(cur NotificationSettingsCollection, getNextPage func(context.Context, NotificationSettingsCollection) (NotificationSettingsCollection, error)) NotificationSettingsCollectionPage { 1225 return NotificationSettingsCollectionPage{ 1226 fn: getNextPage, 1227 nsc: cur, 1228 } 1229} 1230 1231// Operation operation supported by the resource provider. 1232type Operation struct { 1233 // Display - READ-ONLY; The properties of the resource operation. 1234 Display *OperationProperties `json:"display,omitempty"` 1235 // Name - READ-ONLY; The name of the resource operation. 1236 Name *string `json:"name,omitempty"` 1237 // Origin - READ-ONLY; The origin of the operation. 1238 Origin *string `json:"origin,omitempty"` 1239} 1240 1241// MarshalJSON is the custom marshaler for Operation. 1242func (o Operation) MarshalJSON() ([]byte, error) { 1243 objectMap := make(map[string]interface{}) 1244 return json.Marshal(objectMap) 1245} 1246 1247// OperationListResult container for a list of operations supported by the resource provider. 1248type OperationListResult struct { 1249 autorest.Response `json:"-"` 1250 // NextLink - READ-ONLY; URL to the next set of results. 1251 NextLink *string `json:"nextLink,omitempty"` 1252 // Value - READ-ONLY; List of operations. 1253 Value *[]Operation `json:"value,omitempty"` 1254} 1255 1256// MarshalJSON is the custom marshaler for OperationListResult. 1257func (olr OperationListResult) MarshalJSON() ([]byte, error) { 1258 objectMap := make(map[string]interface{}) 1259 return json.Marshal(objectMap) 1260} 1261 1262// OperationListResultIterator provides access to a complete listing of Operation values. 1263type OperationListResultIterator struct { 1264 i int 1265 page OperationListResultPage 1266} 1267 1268// NextWithContext advances to the next value. If there was an error making 1269// the request the iterator does not advance and the error is returned. 1270func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { 1271 if tracing.IsEnabled() { 1272 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") 1273 defer func() { 1274 sc := -1 1275 if iter.Response().Response.Response != nil { 1276 sc = iter.Response().Response.Response.StatusCode 1277 } 1278 tracing.EndSpan(ctx, sc, err) 1279 }() 1280 } 1281 iter.i++ 1282 if iter.i < len(iter.page.Values()) { 1283 return nil 1284 } 1285 err = iter.page.NextWithContext(ctx) 1286 if err != nil { 1287 iter.i-- 1288 return err 1289 } 1290 iter.i = 0 1291 return nil 1292} 1293 1294// Next advances to the next value. If there was an error making 1295// the request the iterator does not advance and the error is returned. 1296// Deprecated: Use NextWithContext() instead. 1297func (iter *OperationListResultIterator) Next() error { 1298 return iter.NextWithContext(context.Background()) 1299} 1300 1301// NotDone returns true if the enumeration should be started or is not yet complete. 1302func (iter OperationListResultIterator) NotDone() bool { 1303 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1304} 1305 1306// Response returns the raw server response from the last page request. 1307func (iter OperationListResultIterator) Response() OperationListResult { 1308 return iter.page.Response() 1309} 1310 1311// Value returns the current value or a zero-initialized value if the 1312// iterator has advanced beyond the end of the collection. 1313func (iter OperationListResultIterator) Value() Operation { 1314 if !iter.page.NotDone() { 1315 return Operation{} 1316 } 1317 return iter.page.Values()[iter.i] 1318} 1319 1320// Creates a new instance of the OperationListResultIterator type. 1321func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { 1322 return OperationListResultIterator{page: page} 1323} 1324 1325// IsEmpty returns true if the ListResult contains no values. 1326func (olr OperationListResult) IsEmpty() bool { 1327 return olr.Value == nil || len(*olr.Value) == 0 1328} 1329 1330// hasNextLink returns true if the NextLink is not empty. 1331func (olr OperationListResult) hasNextLink() bool { 1332 return olr.NextLink != nil && len(*olr.NextLink) != 0 1333} 1334 1335// operationListResultPreparer prepares a request to retrieve the next set of results. 1336// It returns nil if no more results exist. 1337func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { 1338 if !olr.hasNextLink() { 1339 return nil, nil 1340 } 1341 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1342 autorest.AsJSON(), 1343 autorest.AsGet(), 1344 autorest.WithBaseURL(to.String(olr.NextLink))) 1345} 1346 1347// OperationListResultPage contains a page of Operation values. 1348type OperationListResultPage struct { 1349 fn func(context.Context, OperationListResult) (OperationListResult, error) 1350 olr OperationListResult 1351} 1352 1353// NextWithContext advances to the next page of values. If there was an error making 1354// the request the page does not advance and the error is returned. 1355func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { 1356 if tracing.IsEnabled() { 1357 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") 1358 defer func() { 1359 sc := -1 1360 if page.Response().Response.Response != nil { 1361 sc = page.Response().Response.Response.StatusCode 1362 } 1363 tracing.EndSpan(ctx, sc, err) 1364 }() 1365 } 1366 for { 1367 next, err := page.fn(ctx, page.olr) 1368 if err != nil { 1369 return err 1370 } 1371 page.olr = next 1372 if !next.hasNextLink() || !next.IsEmpty() { 1373 break 1374 } 1375 } 1376 return nil 1377} 1378 1379// Next advances to the next page of values. If there was an error making 1380// the request the page does not advance and the error is returned. 1381// Deprecated: Use NextWithContext() instead. 1382func (page *OperationListResultPage) Next() error { 1383 return page.NextWithContext(context.Background()) 1384} 1385 1386// NotDone returns true if the page enumeration should be started or is not yet complete. 1387func (page OperationListResultPage) NotDone() bool { 1388 return !page.olr.IsEmpty() 1389} 1390 1391// Response returns the raw server response from the last page request. 1392func (page OperationListResultPage) Response() OperationListResult { 1393 return page.olr 1394} 1395 1396// Values returns the slice of values for the current page or nil if there are no values. 1397func (page OperationListResultPage) Values() []Operation { 1398 if page.olr.IsEmpty() { 1399 return nil 1400 } 1401 return *page.olr.Value 1402} 1403 1404// Creates a new instance of the OperationListResultPage type. 1405func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { 1406 return OperationListResultPage{ 1407 fn: getNextPage, 1408 olr: cur, 1409 } 1410} 1411 1412// OperationProperties properties of an operation supported by the resource provider. 1413type OperationProperties struct { 1414 // Description - READ-ONLY; The description of the resource provider. 1415 Description *string `json:"description,omitempty"` 1416 // Operation - READ-ONLY; This operation name. 1417 Operation *string `json:"operation,omitempty"` 1418 // Provider - READ-ONLY; The provider name. 1419 Provider *string `json:"provider,omitempty"` 1420 // Resource - READ-ONLY; The resource name. 1421 Resource *string `json:"resource,omitempty"` 1422} 1423 1424// MarshalJSON is the custom marshaler for OperationProperties. 1425func (op OperationProperties) MarshalJSON() ([]byte, error) { 1426 objectMap := make(map[string]interface{}) 1427 return json.Marshal(objectMap) 1428} 1429 1430// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not 1431// have tags and a location 1432type ProxyResource struct { 1433 // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 1434 ID *string `json:"id,omitempty"` 1435 // Name - READ-ONLY; The name of the resource 1436 Name *string `json:"name,omitempty"` 1437 // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" 1438 Type *string `json:"type,omitempty"` 1439} 1440 1441// MarshalJSON is the custom marshaler for ProxyResource. 1442func (pr ProxyResource) MarshalJSON() ([]byte, error) { 1443 objectMap := make(map[string]interface{}) 1444 return json.Marshal(objectMap) 1445} 1446 1447// Resource common fields that are returned in the response for all Azure Resource Manager resources 1448type Resource struct { 1449 // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 1450 ID *string `json:"id,omitempty"` 1451 // Name - READ-ONLY; The name of the resource 1452 Name *string `json:"name,omitempty"` 1453 // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" 1454 Type *string `json:"type,omitempty"` 1455} 1456 1457// MarshalJSON is the custom marshaler for Resource. 1458func (r Resource) MarshalJSON() ([]byte, error) { 1459 objectMap := make(map[string]interface{}) 1460 return json.Marshal(objectMap) 1461} 1462 1463// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource 1464// which has 'tags' and a 'location' 1465type TrackedResource struct { 1466 // Tags - Resource tags. 1467 Tags map[string]*string `json:"tags"` 1468 // Location - The geo-location where the resource lives 1469 Location *string `json:"location,omitempty"` 1470 // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 1471 ID *string `json:"id,omitempty"` 1472 // Name - READ-ONLY; The name of the resource 1473 Name *string `json:"name,omitempty"` 1474 // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" 1475 Type *string `json:"type,omitempty"` 1476} 1477 1478// MarshalJSON is the custom marshaler for TrackedResource. 1479func (tr TrackedResource) MarshalJSON() ([]byte, error) { 1480 objectMap := make(map[string]interface{}) 1481 if tr.Tags != nil { 1482 objectMap["tags"] = tr.Tags 1483 } 1484 if tr.Location != nil { 1485 objectMap["location"] = tr.Location 1486 } 1487 return json.Marshal(objectMap) 1488} 1489