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