1package policyinsights 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/policyinsights/mgmt/2018-07-01-preview/policyinsights" 32 33// PolicyStatesResource enumerates the values for policy states resource. 34type PolicyStatesResource string 35 36const ( 37 // Default ... 38 Default PolicyStatesResource = "default" 39 // Latest ... 40 Latest PolicyStatesResource = "latest" 41) 42 43// PossiblePolicyStatesResourceValues returns an array of possible values for the PolicyStatesResource const type. 44func PossiblePolicyStatesResourceValues() []PolicyStatesResource { 45 return []PolicyStatesResource{Default, Latest} 46} 47 48// ErrorDefinition error definition. 49type ErrorDefinition struct { 50 // Code - READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. 51 Code *string `json:"code,omitempty"` 52 // Message - READ-ONLY; Description of the error. 53 Message *string `json:"message,omitempty"` 54 // Target - READ-ONLY; The target of the error. 55 Target *string `json:"target,omitempty"` 56 // Details - READ-ONLY; Internal error details. 57 Details *[]ErrorDefinition `json:"details,omitempty"` 58 // AdditionalInfo - READ-ONLY; Additional scenario specific error details. 59 AdditionalInfo *[]TypedErrorInfo `json:"additionalInfo,omitempty"` 60} 61 62// ErrorResponse error response. 63type ErrorResponse struct { 64 // Error - The error details. 65 Error *ErrorDefinition `json:"error,omitempty"` 66} 67 68// ExpressionEvaluationDetails evaluation details of policy language expressions. 69type ExpressionEvaluationDetails struct { 70 // Result - Evaluation result. 71 Result *string `json:"result,omitempty"` 72 // Expression - Expression evaluated. 73 Expression *string `json:"expression,omitempty"` 74 // Path - Property path if the expression is a field or an alias. 75 Path *string `json:"path,omitempty"` 76 // ExpressionValue - Value of the expression. 77 ExpressionValue interface{} `json:"expressionValue,omitempty"` 78 // TargetValue - Target value to be compared with the expression value. 79 TargetValue interface{} `json:"targetValue,omitempty"` 80 // Operator - Operator to compare the expression value and the target value. 81 Operator *string `json:"operator,omitempty"` 82} 83 84// IfNotExistsEvaluationDetails evaluation details of IfNotExists effect. 85type IfNotExistsEvaluationDetails struct { 86 // ResourceID - ID of the last evaluated resource for IfNotExists effect. 87 ResourceID *string `json:"resourceId,omitempty"` 88 // TotalResources - Total number of resources to which the existence condition is applicable. 89 TotalResources *int32 `json:"totalResources,omitempty"` 90} 91 92// Operation operation definition. 93type Operation struct { 94 // Name - Operation name. 95 Name *string `json:"name,omitempty"` 96 // Display - Display metadata associated with the operation. 97 Display *OperationDisplay `json:"display,omitempty"` 98} 99 100// OperationDisplay display metadata associated with the operation. 101type OperationDisplay struct { 102 // Provider - Resource provider name. 103 Provider *string `json:"provider,omitempty"` 104 // Resource - Resource name on which the operation is performed. 105 Resource *string `json:"resource,omitempty"` 106 // Operation - Operation name. 107 Operation *string `json:"operation,omitempty"` 108 // Description - Operation description. 109 Description *string `json:"description,omitempty"` 110} 111 112// OperationsListResults list of available operations. 113type OperationsListResults struct { 114 autorest.Response `json:"-"` 115 // OdataCount - OData entity count; represents the number of operations returned. 116 OdataCount *int32 `json:"@odata.count,omitempty"` 117 // Value - List of available operations. 118 Value *[]Operation `json:"value,omitempty"` 119} 120 121// PolicyAssignmentSummary policy assignment summary. 122type PolicyAssignmentSummary struct { 123 // PolicyAssignmentID - Policy assignment ID. 124 PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` 125 // PolicySetDefinitionID - Policy set definition ID, if the policy assignment is for a policy set. 126 PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty"` 127 // Results - Non-compliance summary for the policy assignment. 128 Results *SummaryResults `json:"results,omitempty"` 129 // PolicyDefinitions - Policy definitions summary. 130 PolicyDefinitions *[]PolicyDefinitionSummary `json:"policyDefinitions,omitempty"` 131} 132 133// PolicyDefinitionSummary policy definition summary. 134type PolicyDefinitionSummary struct { 135 // PolicyDefinitionID - Policy definition ID. 136 PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` 137 // PolicyDefinitionReferenceID - Policy definition reference ID. 138 PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` 139 // Effect - Policy effect, i.e. policy definition action. 140 Effect *string `json:"effect,omitempty"` 141 // Results - Non-compliance summary for the policy definition. 142 Results *SummaryResults `json:"results,omitempty"` 143} 144 145// PolicyDetails the policy details. 146type PolicyDetails struct { 147 // PolicyDefinitionID - READ-ONLY; The ID of the policy definition. 148 PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` 149 // PolicyAssignmentID - READ-ONLY; The ID of the policy assignment. 150 PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` 151 // PolicyAssignmentDisplayName - READ-ONLY; The display name of the policy assignment. 152 PolicyAssignmentDisplayName *string `json:"policyAssignmentDisplayName,omitempty"` 153 // PolicyAssignmentScope - READ-ONLY; The scope of the policy assignment. 154 PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty"` 155 // PolicySetDefinitionID - READ-ONLY; The ID of the policy set definition. 156 PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty"` 157 // PolicyDefinitionReferenceID - READ-ONLY; The policy definition reference ID within the policy set definition. 158 PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` 159} 160 161// PolicyEvaluationDetails policy evaluation details. 162type PolicyEvaluationDetails struct { 163 // EvaluatedExpressions - Details of the evaluated expressions. 164 EvaluatedExpressions *[]ExpressionEvaluationDetails `json:"evaluatedExpressions,omitempty"` 165 // IfNotExistsDetails - Evaluation details of IfNotExists effect. 166 IfNotExistsDetails *IfNotExistsEvaluationDetails `json:"ifNotExistsDetails,omitempty"` 167} 168 169// PolicyEvent policy event record. 170type PolicyEvent struct { 171 // AdditionalProperties - Unmatched properties from the message are deserialized this collection 172 AdditionalProperties map[string]interface{} `json:""` 173 // OdataID - OData entity ID; always set to null since policy event records do not have an entity ID. 174 OdataID *string `json:"@odata.id,omitempty"` 175 // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. 176 OdataContext *string `json:"@odata.context,omitempty"` 177 // Timestamp - Timestamp for the policy event record. 178 Timestamp *date.Time `json:"timestamp,omitempty"` 179 // ResourceID - Resource ID. 180 ResourceID *string `json:"resourceId,omitempty"` 181 // PolicyAssignmentID - Policy assignment ID. 182 PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` 183 // PolicyDefinitionID - Policy definition ID. 184 PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` 185 // EffectiveParameters - Effective parameters for the policy assignment. 186 EffectiveParameters *string `json:"effectiveParameters,omitempty"` 187 // IsCompliant - Flag which states whether the resource is compliant against the policy assignment it was evaluated against. 188 IsCompliant *bool `json:"isCompliant,omitempty"` 189 // SubscriptionID - Subscription ID. 190 SubscriptionID *string `json:"subscriptionId,omitempty"` 191 // ResourceType - Resource type. 192 ResourceType *string `json:"resourceType,omitempty"` 193 // ResourceLocation - Resource location. 194 ResourceLocation *string `json:"resourceLocation,omitempty"` 195 // ResourceGroup - Resource group name. 196 ResourceGroup *string `json:"resourceGroup,omitempty"` 197 // ResourceTags - List of resource tags. 198 ResourceTags *string `json:"resourceTags,omitempty"` 199 // PolicyAssignmentName - Policy assignment name. 200 PolicyAssignmentName *string `json:"policyAssignmentName,omitempty"` 201 // PolicyAssignmentOwner - Policy assignment owner. 202 PolicyAssignmentOwner *string `json:"policyAssignmentOwner,omitempty"` 203 // PolicyAssignmentParameters - Policy assignment parameters. 204 PolicyAssignmentParameters *string `json:"policyAssignmentParameters,omitempty"` 205 // PolicyAssignmentScope - Policy assignment scope. 206 PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty"` 207 // PolicyDefinitionName - Policy definition name. 208 PolicyDefinitionName *string `json:"policyDefinitionName,omitempty"` 209 // PolicyDefinitionAction - Policy definition action, i.e. effect. 210 PolicyDefinitionAction *string `json:"policyDefinitionAction,omitempty"` 211 // PolicyDefinitionCategory - Policy definition category. 212 PolicyDefinitionCategory *string `json:"policyDefinitionCategory,omitempty"` 213 // PolicySetDefinitionID - Policy set definition ID, if the policy assignment is for a policy set. 214 PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty"` 215 // PolicySetDefinitionName - Policy set definition name, if the policy assignment is for a policy set. 216 PolicySetDefinitionName *string `json:"policySetDefinitionName,omitempty"` 217 // PolicySetDefinitionOwner - Policy set definition owner, if the policy assignment is for a policy set. 218 PolicySetDefinitionOwner *string `json:"policySetDefinitionOwner,omitempty"` 219 // PolicySetDefinitionCategory - Policy set definition category, if the policy assignment is for a policy set. 220 PolicySetDefinitionCategory *string `json:"policySetDefinitionCategory,omitempty"` 221 // PolicySetDefinitionParameters - Policy set definition parameters, if the policy assignment is for a policy set. 222 PolicySetDefinitionParameters *string `json:"policySetDefinitionParameters,omitempty"` 223 // ManagementGroupIds - Comma separated list of management group IDs, which represent the hierarchy of the management groups the resource is under. 224 ManagementGroupIds *string `json:"managementGroupIds,omitempty"` 225 // PolicyDefinitionReferenceID - Reference ID for the policy definition inside the policy set, if the policy assignment is for a policy set. 226 PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` 227 // TenantID - Tenant ID for the policy event record. 228 TenantID *string `json:"tenantId,omitempty"` 229 // PrincipalOid - Principal object ID for the user who initiated the resource operation that triggered the policy event. 230 PrincipalOid *string `json:"principalOid,omitempty"` 231} 232 233// MarshalJSON is the custom marshaler for PolicyEvent. 234func (peVar PolicyEvent) MarshalJSON() ([]byte, error) { 235 objectMap := make(map[string]interface{}) 236 if peVar.OdataID != nil { 237 objectMap["@odata.id"] = peVar.OdataID 238 } 239 if peVar.OdataContext != nil { 240 objectMap["@odata.context"] = peVar.OdataContext 241 } 242 if peVar.Timestamp != nil { 243 objectMap["timestamp"] = peVar.Timestamp 244 } 245 if peVar.ResourceID != nil { 246 objectMap["resourceId"] = peVar.ResourceID 247 } 248 if peVar.PolicyAssignmentID != nil { 249 objectMap["policyAssignmentId"] = peVar.PolicyAssignmentID 250 } 251 if peVar.PolicyDefinitionID != nil { 252 objectMap["policyDefinitionId"] = peVar.PolicyDefinitionID 253 } 254 if peVar.EffectiveParameters != nil { 255 objectMap["effectiveParameters"] = peVar.EffectiveParameters 256 } 257 if peVar.IsCompliant != nil { 258 objectMap["isCompliant"] = peVar.IsCompliant 259 } 260 if peVar.SubscriptionID != nil { 261 objectMap["subscriptionId"] = peVar.SubscriptionID 262 } 263 if peVar.ResourceType != nil { 264 objectMap["resourceType"] = peVar.ResourceType 265 } 266 if peVar.ResourceLocation != nil { 267 objectMap["resourceLocation"] = peVar.ResourceLocation 268 } 269 if peVar.ResourceGroup != nil { 270 objectMap["resourceGroup"] = peVar.ResourceGroup 271 } 272 if peVar.ResourceTags != nil { 273 objectMap["resourceTags"] = peVar.ResourceTags 274 } 275 if peVar.PolicyAssignmentName != nil { 276 objectMap["policyAssignmentName"] = peVar.PolicyAssignmentName 277 } 278 if peVar.PolicyAssignmentOwner != nil { 279 objectMap["policyAssignmentOwner"] = peVar.PolicyAssignmentOwner 280 } 281 if peVar.PolicyAssignmentParameters != nil { 282 objectMap["policyAssignmentParameters"] = peVar.PolicyAssignmentParameters 283 } 284 if peVar.PolicyAssignmentScope != nil { 285 objectMap["policyAssignmentScope"] = peVar.PolicyAssignmentScope 286 } 287 if peVar.PolicyDefinitionName != nil { 288 objectMap["policyDefinitionName"] = peVar.PolicyDefinitionName 289 } 290 if peVar.PolicyDefinitionAction != nil { 291 objectMap["policyDefinitionAction"] = peVar.PolicyDefinitionAction 292 } 293 if peVar.PolicyDefinitionCategory != nil { 294 objectMap["policyDefinitionCategory"] = peVar.PolicyDefinitionCategory 295 } 296 if peVar.PolicySetDefinitionID != nil { 297 objectMap["policySetDefinitionId"] = peVar.PolicySetDefinitionID 298 } 299 if peVar.PolicySetDefinitionName != nil { 300 objectMap["policySetDefinitionName"] = peVar.PolicySetDefinitionName 301 } 302 if peVar.PolicySetDefinitionOwner != nil { 303 objectMap["policySetDefinitionOwner"] = peVar.PolicySetDefinitionOwner 304 } 305 if peVar.PolicySetDefinitionCategory != nil { 306 objectMap["policySetDefinitionCategory"] = peVar.PolicySetDefinitionCategory 307 } 308 if peVar.PolicySetDefinitionParameters != nil { 309 objectMap["policySetDefinitionParameters"] = peVar.PolicySetDefinitionParameters 310 } 311 if peVar.ManagementGroupIds != nil { 312 objectMap["managementGroupIds"] = peVar.ManagementGroupIds 313 } 314 if peVar.PolicyDefinitionReferenceID != nil { 315 objectMap["policyDefinitionReferenceId"] = peVar.PolicyDefinitionReferenceID 316 } 317 if peVar.TenantID != nil { 318 objectMap["tenantId"] = peVar.TenantID 319 } 320 if peVar.PrincipalOid != nil { 321 objectMap["principalOid"] = peVar.PrincipalOid 322 } 323 for k, v := range peVar.AdditionalProperties { 324 objectMap[k] = v 325 } 326 return json.Marshal(objectMap) 327} 328 329// UnmarshalJSON is the custom unmarshaler for PolicyEvent struct. 330func (peVar *PolicyEvent) UnmarshalJSON(body []byte) error { 331 var m map[string]*json.RawMessage 332 err := json.Unmarshal(body, &m) 333 if err != nil { 334 return err 335 } 336 for k, v := range m { 337 switch k { 338 default: 339 if v != nil { 340 var additionalProperties interface{} 341 err = json.Unmarshal(*v, &additionalProperties) 342 if err != nil { 343 return err 344 } 345 if peVar.AdditionalProperties == nil { 346 peVar.AdditionalProperties = make(map[string]interface{}) 347 } 348 peVar.AdditionalProperties[k] = additionalProperties 349 } 350 case "@odata.id": 351 if v != nil { 352 var odataID string 353 err = json.Unmarshal(*v, &odataID) 354 if err != nil { 355 return err 356 } 357 peVar.OdataID = &odataID 358 } 359 case "@odata.context": 360 if v != nil { 361 var odataContext string 362 err = json.Unmarshal(*v, &odataContext) 363 if err != nil { 364 return err 365 } 366 peVar.OdataContext = &odataContext 367 } 368 case "timestamp": 369 if v != nil { 370 var timestamp date.Time 371 err = json.Unmarshal(*v, ×tamp) 372 if err != nil { 373 return err 374 } 375 peVar.Timestamp = ×tamp 376 } 377 case "resourceId": 378 if v != nil { 379 var resourceID string 380 err = json.Unmarshal(*v, &resourceID) 381 if err != nil { 382 return err 383 } 384 peVar.ResourceID = &resourceID 385 } 386 case "policyAssignmentId": 387 if v != nil { 388 var policyAssignmentID string 389 err = json.Unmarshal(*v, &policyAssignmentID) 390 if err != nil { 391 return err 392 } 393 peVar.PolicyAssignmentID = &policyAssignmentID 394 } 395 case "policyDefinitionId": 396 if v != nil { 397 var policyDefinitionID string 398 err = json.Unmarshal(*v, &policyDefinitionID) 399 if err != nil { 400 return err 401 } 402 peVar.PolicyDefinitionID = &policyDefinitionID 403 } 404 case "effectiveParameters": 405 if v != nil { 406 var effectiveParameters string 407 err = json.Unmarshal(*v, &effectiveParameters) 408 if err != nil { 409 return err 410 } 411 peVar.EffectiveParameters = &effectiveParameters 412 } 413 case "isCompliant": 414 if v != nil { 415 var isCompliant bool 416 err = json.Unmarshal(*v, &isCompliant) 417 if err != nil { 418 return err 419 } 420 peVar.IsCompliant = &isCompliant 421 } 422 case "subscriptionId": 423 if v != nil { 424 var subscriptionID string 425 err = json.Unmarshal(*v, &subscriptionID) 426 if err != nil { 427 return err 428 } 429 peVar.SubscriptionID = &subscriptionID 430 } 431 case "resourceType": 432 if v != nil { 433 var resourceType string 434 err = json.Unmarshal(*v, &resourceType) 435 if err != nil { 436 return err 437 } 438 peVar.ResourceType = &resourceType 439 } 440 case "resourceLocation": 441 if v != nil { 442 var resourceLocation string 443 err = json.Unmarshal(*v, &resourceLocation) 444 if err != nil { 445 return err 446 } 447 peVar.ResourceLocation = &resourceLocation 448 } 449 case "resourceGroup": 450 if v != nil { 451 var resourceGroup string 452 err = json.Unmarshal(*v, &resourceGroup) 453 if err != nil { 454 return err 455 } 456 peVar.ResourceGroup = &resourceGroup 457 } 458 case "resourceTags": 459 if v != nil { 460 var resourceTags string 461 err = json.Unmarshal(*v, &resourceTags) 462 if err != nil { 463 return err 464 } 465 peVar.ResourceTags = &resourceTags 466 } 467 case "policyAssignmentName": 468 if v != nil { 469 var policyAssignmentName string 470 err = json.Unmarshal(*v, &policyAssignmentName) 471 if err != nil { 472 return err 473 } 474 peVar.PolicyAssignmentName = &policyAssignmentName 475 } 476 case "policyAssignmentOwner": 477 if v != nil { 478 var policyAssignmentOwner string 479 err = json.Unmarshal(*v, &policyAssignmentOwner) 480 if err != nil { 481 return err 482 } 483 peVar.PolicyAssignmentOwner = &policyAssignmentOwner 484 } 485 case "policyAssignmentParameters": 486 if v != nil { 487 var policyAssignmentParameters string 488 err = json.Unmarshal(*v, &policyAssignmentParameters) 489 if err != nil { 490 return err 491 } 492 peVar.PolicyAssignmentParameters = &policyAssignmentParameters 493 } 494 case "policyAssignmentScope": 495 if v != nil { 496 var policyAssignmentScope string 497 err = json.Unmarshal(*v, &policyAssignmentScope) 498 if err != nil { 499 return err 500 } 501 peVar.PolicyAssignmentScope = &policyAssignmentScope 502 } 503 case "policyDefinitionName": 504 if v != nil { 505 var policyDefinitionName string 506 err = json.Unmarshal(*v, &policyDefinitionName) 507 if err != nil { 508 return err 509 } 510 peVar.PolicyDefinitionName = &policyDefinitionName 511 } 512 case "policyDefinitionAction": 513 if v != nil { 514 var policyDefinitionAction string 515 err = json.Unmarshal(*v, &policyDefinitionAction) 516 if err != nil { 517 return err 518 } 519 peVar.PolicyDefinitionAction = &policyDefinitionAction 520 } 521 case "policyDefinitionCategory": 522 if v != nil { 523 var policyDefinitionCategory string 524 err = json.Unmarshal(*v, &policyDefinitionCategory) 525 if err != nil { 526 return err 527 } 528 peVar.PolicyDefinitionCategory = &policyDefinitionCategory 529 } 530 case "policySetDefinitionId": 531 if v != nil { 532 var policySetDefinitionID string 533 err = json.Unmarshal(*v, &policySetDefinitionID) 534 if err != nil { 535 return err 536 } 537 peVar.PolicySetDefinitionID = &policySetDefinitionID 538 } 539 case "policySetDefinitionName": 540 if v != nil { 541 var policySetDefinitionName string 542 err = json.Unmarshal(*v, &policySetDefinitionName) 543 if err != nil { 544 return err 545 } 546 peVar.PolicySetDefinitionName = &policySetDefinitionName 547 } 548 case "policySetDefinitionOwner": 549 if v != nil { 550 var policySetDefinitionOwner string 551 err = json.Unmarshal(*v, &policySetDefinitionOwner) 552 if err != nil { 553 return err 554 } 555 peVar.PolicySetDefinitionOwner = &policySetDefinitionOwner 556 } 557 case "policySetDefinitionCategory": 558 if v != nil { 559 var policySetDefinitionCategory string 560 err = json.Unmarshal(*v, &policySetDefinitionCategory) 561 if err != nil { 562 return err 563 } 564 peVar.PolicySetDefinitionCategory = &policySetDefinitionCategory 565 } 566 case "policySetDefinitionParameters": 567 if v != nil { 568 var policySetDefinitionParameters string 569 err = json.Unmarshal(*v, &policySetDefinitionParameters) 570 if err != nil { 571 return err 572 } 573 peVar.PolicySetDefinitionParameters = &policySetDefinitionParameters 574 } 575 case "managementGroupIds": 576 if v != nil { 577 var managementGroupIds string 578 err = json.Unmarshal(*v, &managementGroupIds) 579 if err != nil { 580 return err 581 } 582 peVar.ManagementGroupIds = &managementGroupIds 583 } 584 case "policyDefinitionReferenceId": 585 if v != nil { 586 var policyDefinitionReferenceID string 587 err = json.Unmarshal(*v, &policyDefinitionReferenceID) 588 if err != nil { 589 return err 590 } 591 peVar.PolicyDefinitionReferenceID = &policyDefinitionReferenceID 592 } 593 case "tenantId": 594 if v != nil { 595 var tenantID string 596 err = json.Unmarshal(*v, &tenantID) 597 if err != nil { 598 return err 599 } 600 peVar.TenantID = &tenantID 601 } 602 case "principalOid": 603 if v != nil { 604 var principalOid string 605 err = json.Unmarshal(*v, &principalOid) 606 if err != nil { 607 return err 608 } 609 peVar.PrincipalOid = &principalOid 610 } 611 } 612 } 613 614 return nil 615} 616 617// PolicyEventsQueryResults query results. 618type PolicyEventsQueryResults struct { 619 autorest.Response `json:"-"` 620 // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. 621 OdataContext *string `json:"@odata.context,omitempty"` 622 // OdataCount - OData entity count; represents the number of policy event records returned. 623 OdataCount *int32 `json:"@odata.count,omitempty"` 624 // OdataNextLink - Odata next link; URL to get the next set of results. 625 OdataNextLink *string `json:"@odata.nextLink,omitempty"` 626 // Value - Query results. 627 Value *[]PolicyEvent `json:"value,omitempty"` 628} 629 630// PolicyEventsQueryResultsIterator provides access to a complete listing of PolicyEvent values. 631type PolicyEventsQueryResultsIterator struct { 632 i int 633 page PolicyEventsQueryResultsPage 634} 635 636// NextWithContext advances to the next value. If there was an error making 637// the request the iterator does not advance and the error is returned. 638func (iter *PolicyEventsQueryResultsIterator) NextWithContext(ctx context.Context) (err error) { 639 if tracing.IsEnabled() { 640 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsQueryResultsIterator.NextWithContext") 641 defer func() { 642 sc := -1 643 if iter.Response().Response.Response != nil { 644 sc = iter.Response().Response.Response.StatusCode 645 } 646 tracing.EndSpan(ctx, sc, err) 647 }() 648 } 649 iter.i++ 650 if iter.i < len(iter.page.Values()) { 651 return nil 652 } 653 err = iter.page.NextWithContext(ctx) 654 if err != nil { 655 iter.i-- 656 return err 657 } 658 iter.i = 0 659 return nil 660} 661 662// Next advances to the next value. If there was an error making 663// the request the iterator does not advance and the error is returned. 664// Deprecated: Use NextWithContext() instead. 665func (iter *PolicyEventsQueryResultsIterator) Next() error { 666 return iter.NextWithContext(context.Background()) 667} 668 669// NotDone returns true if the enumeration should be started or is not yet complete. 670func (iter PolicyEventsQueryResultsIterator) NotDone() bool { 671 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 672} 673 674// Response returns the raw server response from the last page request. 675func (iter PolicyEventsQueryResultsIterator) Response() PolicyEventsQueryResults { 676 return iter.page.Response() 677} 678 679// Value returns the current value or a zero-initialized value if the 680// iterator has advanced beyond the end of the collection. 681func (iter PolicyEventsQueryResultsIterator) Value() PolicyEvent { 682 if !iter.page.NotDone() { 683 return PolicyEvent{} 684 } 685 return iter.page.Values()[iter.i] 686} 687 688// Creates a new instance of the PolicyEventsQueryResultsIterator type. 689func NewPolicyEventsQueryResultsIterator(page PolicyEventsQueryResultsPage) PolicyEventsQueryResultsIterator { 690 return PolicyEventsQueryResultsIterator{page: page} 691} 692 693// IsEmpty returns true if the ListResult contains no values. 694func (peqr PolicyEventsQueryResults) IsEmpty() bool { 695 return peqr.Value == nil || len(*peqr.Value) == 0 696} 697 698// policyEventsQueryResultsPreparer prepares a request to retrieve the next set of results. 699// It returns nil if no more results exist. 700func (peqr PolicyEventsQueryResults) policyEventsQueryResultsPreparer(ctx context.Context) (*http.Request, error) { 701 if peqr.OdataNextLink == nil || len(to.String(peqr.OdataNextLink)) < 1 { 702 return nil, nil 703 } 704 return autorest.Prepare((&http.Request{}).WithContext(ctx), 705 autorest.AsJSON(), 706 autorest.AsGet(), 707 autorest.WithBaseURL(to.String(peqr.OdataNextLink))) 708} 709 710// PolicyEventsQueryResultsPage contains a page of PolicyEvent values. 711type PolicyEventsQueryResultsPage struct { 712 fn func(context.Context, PolicyEventsQueryResults) (PolicyEventsQueryResults, error) 713 peqr PolicyEventsQueryResults 714} 715 716// NextWithContext advances to the next page of values. If there was an error making 717// the request the page does not advance and the error is returned. 718func (page *PolicyEventsQueryResultsPage) NextWithContext(ctx context.Context) (err error) { 719 if tracing.IsEnabled() { 720 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsQueryResultsPage.NextWithContext") 721 defer func() { 722 sc := -1 723 if page.Response().Response.Response != nil { 724 sc = page.Response().Response.Response.StatusCode 725 } 726 tracing.EndSpan(ctx, sc, err) 727 }() 728 } 729 next, err := page.fn(ctx, page.peqr) 730 if err != nil { 731 return err 732 } 733 page.peqr = next 734 return nil 735} 736 737// Next advances to the next page of values. If there was an error making 738// the request the page does not advance and the error is returned. 739// Deprecated: Use NextWithContext() instead. 740func (page *PolicyEventsQueryResultsPage) Next() error { 741 return page.NextWithContext(context.Background()) 742} 743 744// NotDone returns true if the page enumeration should be started or is not yet complete. 745func (page PolicyEventsQueryResultsPage) NotDone() bool { 746 return !page.peqr.IsEmpty() 747} 748 749// Response returns the raw server response from the last page request. 750func (page PolicyEventsQueryResultsPage) Response() PolicyEventsQueryResults { 751 return page.peqr 752} 753 754// Values returns the slice of values for the current page or nil if there are no values. 755func (page PolicyEventsQueryResultsPage) Values() []PolicyEvent { 756 if page.peqr.IsEmpty() { 757 return nil 758 } 759 return *page.peqr.Value 760} 761 762// Creates a new instance of the PolicyEventsQueryResultsPage type. 763func NewPolicyEventsQueryResultsPage(getNextPage func(context.Context, PolicyEventsQueryResults) (PolicyEventsQueryResults, error)) PolicyEventsQueryResultsPage { 764 return PolicyEventsQueryResultsPage{fn: getNextPage} 765} 766 767// PolicyState policy state record. 768type PolicyState struct { 769 // AdditionalProperties - Unmatched properties from the message are deserialized this collection 770 AdditionalProperties map[string]interface{} `json:""` 771 // OdataID - OData entity ID; always set to null since policy state records do not have an entity ID. 772 OdataID *string `json:"@odata.id,omitempty"` 773 // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. 774 OdataContext *string `json:"@odata.context,omitempty"` 775 // Timestamp - Timestamp for the policy state record. 776 Timestamp *date.Time `json:"timestamp,omitempty"` 777 // ResourceID - Resource ID. 778 ResourceID *string `json:"resourceId,omitempty"` 779 // PolicyAssignmentID - Policy assignment ID. 780 PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` 781 // PolicyDefinitionID - Policy definition ID. 782 PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` 783 // EffectiveParameters - Effective parameters for the policy assignment. 784 EffectiveParameters *string `json:"effectiveParameters,omitempty"` 785 // IsCompliant - Flag which states whether the resource is compliant against the policy assignment it was evaluated against. 786 IsCompliant *bool `json:"isCompliant,omitempty"` 787 // SubscriptionID - Subscription ID. 788 SubscriptionID *string `json:"subscriptionId,omitempty"` 789 // ResourceType - Resource type. 790 ResourceType *string `json:"resourceType,omitempty"` 791 // ResourceLocation - Resource location. 792 ResourceLocation *string `json:"resourceLocation,omitempty"` 793 // ResourceGroup - Resource group name. 794 ResourceGroup *string `json:"resourceGroup,omitempty"` 795 // ResourceTags - List of resource tags. 796 ResourceTags *string `json:"resourceTags,omitempty"` 797 // PolicyAssignmentName - Policy assignment name. 798 PolicyAssignmentName *string `json:"policyAssignmentName,omitempty"` 799 // PolicyAssignmentOwner - Policy assignment owner. 800 PolicyAssignmentOwner *string `json:"policyAssignmentOwner,omitempty"` 801 // PolicyAssignmentParameters - Policy assignment parameters. 802 PolicyAssignmentParameters *string `json:"policyAssignmentParameters,omitempty"` 803 // PolicyAssignmentScope - Policy assignment scope. 804 PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty"` 805 // PolicyDefinitionName - Policy definition name. 806 PolicyDefinitionName *string `json:"policyDefinitionName,omitempty"` 807 // PolicyDefinitionAction - Policy definition action, i.e. effect. 808 PolicyDefinitionAction *string `json:"policyDefinitionAction,omitempty"` 809 // PolicyDefinitionCategory - Policy definition category. 810 PolicyDefinitionCategory *string `json:"policyDefinitionCategory,omitempty"` 811 // PolicySetDefinitionID - Policy set definition ID, if the policy assignment is for a policy set. 812 PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty"` 813 // PolicySetDefinitionName - Policy set definition name, if the policy assignment is for a policy set. 814 PolicySetDefinitionName *string `json:"policySetDefinitionName,omitempty"` 815 // PolicySetDefinitionOwner - Policy set definition owner, if the policy assignment is for a policy set. 816 PolicySetDefinitionOwner *string `json:"policySetDefinitionOwner,omitempty"` 817 // PolicySetDefinitionCategory - Policy set definition category, if the policy assignment is for a policy set. 818 PolicySetDefinitionCategory *string `json:"policySetDefinitionCategory,omitempty"` 819 // PolicySetDefinitionParameters - Policy set definition parameters, if the policy assignment is for a policy set. 820 PolicySetDefinitionParameters *string `json:"policySetDefinitionParameters,omitempty"` 821 // ManagementGroupIds - Comma separated list of management group IDs, which represent the hierarchy of the management groups the resource is under. 822 ManagementGroupIds *string `json:"managementGroupIds,omitempty"` 823 // PolicyDefinitionReferenceID - Reference ID for the policy definition inside the policy set, if the policy assignment is for a policy set. 824 PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` 825 // ComplianceState - Compliance state of the resource. 826 ComplianceState *string `json:"complianceState,omitempty"` 827 // PolicyEvaluationDetails - Policy evaluation details. 828 PolicyEvaluationDetails *PolicyEvaluationDetails `json:"policyEvaluationDetails,omitempty"` 829} 830 831// MarshalJSON is the custom marshaler for PolicyState. 832func (ps PolicyState) MarshalJSON() ([]byte, error) { 833 objectMap := make(map[string]interface{}) 834 if ps.OdataID != nil { 835 objectMap["@odata.id"] = ps.OdataID 836 } 837 if ps.OdataContext != nil { 838 objectMap["@odata.context"] = ps.OdataContext 839 } 840 if ps.Timestamp != nil { 841 objectMap["timestamp"] = ps.Timestamp 842 } 843 if ps.ResourceID != nil { 844 objectMap["resourceId"] = ps.ResourceID 845 } 846 if ps.PolicyAssignmentID != nil { 847 objectMap["policyAssignmentId"] = ps.PolicyAssignmentID 848 } 849 if ps.PolicyDefinitionID != nil { 850 objectMap["policyDefinitionId"] = ps.PolicyDefinitionID 851 } 852 if ps.EffectiveParameters != nil { 853 objectMap["effectiveParameters"] = ps.EffectiveParameters 854 } 855 if ps.IsCompliant != nil { 856 objectMap["isCompliant"] = ps.IsCompliant 857 } 858 if ps.SubscriptionID != nil { 859 objectMap["subscriptionId"] = ps.SubscriptionID 860 } 861 if ps.ResourceType != nil { 862 objectMap["resourceType"] = ps.ResourceType 863 } 864 if ps.ResourceLocation != nil { 865 objectMap["resourceLocation"] = ps.ResourceLocation 866 } 867 if ps.ResourceGroup != nil { 868 objectMap["resourceGroup"] = ps.ResourceGroup 869 } 870 if ps.ResourceTags != nil { 871 objectMap["resourceTags"] = ps.ResourceTags 872 } 873 if ps.PolicyAssignmentName != nil { 874 objectMap["policyAssignmentName"] = ps.PolicyAssignmentName 875 } 876 if ps.PolicyAssignmentOwner != nil { 877 objectMap["policyAssignmentOwner"] = ps.PolicyAssignmentOwner 878 } 879 if ps.PolicyAssignmentParameters != nil { 880 objectMap["policyAssignmentParameters"] = ps.PolicyAssignmentParameters 881 } 882 if ps.PolicyAssignmentScope != nil { 883 objectMap["policyAssignmentScope"] = ps.PolicyAssignmentScope 884 } 885 if ps.PolicyDefinitionName != nil { 886 objectMap["policyDefinitionName"] = ps.PolicyDefinitionName 887 } 888 if ps.PolicyDefinitionAction != nil { 889 objectMap["policyDefinitionAction"] = ps.PolicyDefinitionAction 890 } 891 if ps.PolicyDefinitionCategory != nil { 892 objectMap["policyDefinitionCategory"] = ps.PolicyDefinitionCategory 893 } 894 if ps.PolicySetDefinitionID != nil { 895 objectMap["policySetDefinitionId"] = ps.PolicySetDefinitionID 896 } 897 if ps.PolicySetDefinitionName != nil { 898 objectMap["policySetDefinitionName"] = ps.PolicySetDefinitionName 899 } 900 if ps.PolicySetDefinitionOwner != nil { 901 objectMap["policySetDefinitionOwner"] = ps.PolicySetDefinitionOwner 902 } 903 if ps.PolicySetDefinitionCategory != nil { 904 objectMap["policySetDefinitionCategory"] = ps.PolicySetDefinitionCategory 905 } 906 if ps.PolicySetDefinitionParameters != nil { 907 objectMap["policySetDefinitionParameters"] = ps.PolicySetDefinitionParameters 908 } 909 if ps.ManagementGroupIds != nil { 910 objectMap["managementGroupIds"] = ps.ManagementGroupIds 911 } 912 if ps.PolicyDefinitionReferenceID != nil { 913 objectMap["policyDefinitionReferenceId"] = ps.PolicyDefinitionReferenceID 914 } 915 if ps.ComplianceState != nil { 916 objectMap["complianceState"] = ps.ComplianceState 917 } 918 if ps.PolicyEvaluationDetails != nil { 919 objectMap["policyEvaluationDetails"] = ps.PolicyEvaluationDetails 920 } 921 for k, v := range ps.AdditionalProperties { 922 objectMap[k] = v 923 } 924 return json.Marshal(objectMap) 925} 926 927// UnmarshalJSON is the custom unmarshaler for PolicyState struct. 928func (ps *PolicyState) UnmarshalJSON(body []byte) error { 929 var m map[string]*json.RawMessage 930 err := json.Unmarshal(body, &m) 931 if err != nil { 932 return err 933 } 934 for k, v := range m { 935 switch k { 936 default: 937 if v != nil { 938 var additionalProperties interface{} 939 err = json.Unmarshal(*v, &additionalProperties) 940 if err != nil { 941 return err 942 } 943 if ps.AdditionalProperties == nil { 944 ps.AdditionalProperties = make(map[string]interface{}) 945 } 946 ps.AdditionalProperties[k] = additionalProperties 947 } 948 case "@odata.id": 949 if v != nil { 950 var odataID string 951 err = json.Unmarshal(*v, &odataID) 952 if err != nil { 953 return err 954 } 955 ps.OdataID = &odataID 956 } 957 case "@odata.context": 958 if v != nil { 959 var odataContext string 960 err = json.Unmarshal(*v, &odataContext) 961 if err != nil { 962 return err 963 } 964 ps.OdataContext = &odataContext 965 } 966 case "timestamp": 967 if v != nil { 968 var timestamp date.Time 969 err = json.Unmarshal(*v, ×tamp) 970 if err != nil { 971 return err 972 } 973 ps.Timestamp = ×tamp 974 } 975 case "resourceId": 976 if v != nil { 977 var resourceID string 978 err = json.Unmarshal(*v, &resourceID) 979 if err != nil { 980 return err 981 } 982 ps.ResourceID = &resourceID 983 } 984 case "policyAssignmentId": 985 if v != nil { 986 var policyAssignmentID string 987 err = json.Unmarshal(*v, &policyAssignmentID) 988 if err != nil { 989 return err 990 } 991 ps.PolicyAssignmentID = &policyAssignmentID 992 } 993 case "policyDefinitionId": 994 if v != nil { 995 var policyDefinitionID string 996 err = json.Unmarshal(*v, &policyDefinitionID) 997 if err != nil { 998 return err 999 } 1000 ps.PolicyDefinitionID = &policyDefinitionID 1001 } 1002 case "effectiveParameters": 1003 if v != nil { 1004 var effectiveParameters string 1005 err = json.Unmarshal(*v, &effectiveParameters) 1006 if err != nil { 1007 return err 1008 } 1009 ps.EffectiveParameters = &effectiveParameters 1010 } 1011 case "isCompliant": 1012 if v != nil { 1013 var isCompliant bool 1014 err = json.Unmarshal(*v, &isCompliant) 1015 if err != nil { 1016 return err 1017 } 1018 ps.IsCompliant = &isCompliant 1019 } 1020 case "subscriptionId": 1021 if v != nil { 1022 var subscriptionID string 1023 err = json.Unmarshal(*v, &subscriptionID) 1024 if err != nil { 1025 return err 1026 } 1027 ps.SubscriptionID = &subscriptionID 1028 } 1029 case "resourceType": 1030 if v != nil { 1031 var resourceType string 1032 err = json.Unmarshal(*v, &resourceType) 1033 if err != nil { 1034 return err 1035 } 1036 ps.ResourceType = &resourceType 1037 } 1038 case "resourceLocation": 1039 if v != nil { 1040 var resourceLocation string 1041 err = json.Unmarshal(*v, &resourceLocation) 1042 if err != nil { 1043 return err 1044 } 1045 ps.ResourceLocation = &resourceLocation 1046 } 1047 case "resourceGroup": 1048 if v != nil { 1049 var resourceGroup string 1050 err = json.Unmarshal(*v, &resourceGroup) 1051 if err != nil { 1052 return err 1053 } 1054 ps.ResourceGroup = &resourceGroup 1055 } 1056 case "resourceTags": 1057 if v != nil { 1058 var resourceTags string 1059 err = json.Unmarshal(*v, &resourceTags) 1060 if err != nil { 1061 return err 1062 } 1063 ps.ResourceTags = &resourceTags 1064 } 1065 case "policyAssignmentName": 1066 if v != nil { 1067 var policyAssignmentName string 1068 err = json.Unmarshal(*v, &policyAssignmentName) 1069 if err != nil { 1070 return err 1071 } 1072 ps.PolicyAssignmentName = &policyAssignmentName 1073 } 1074 case "policyAssignmentOwner": 1075 if v != nil { 1076 var policyAssignmentOwner string 1077 err = json.Unmarshal(*v, &policyAssignmentOwner) 1078 if err != nil { 1079 return err 1080 } 1081 ps.PolicyAssignmentOwner = &policyAssignmentOwner 1082 } 1083 case "policyAssignmentParameters": 1084 if v != nil { 1085 var policyAssignmentParameters string 1086 err = json.Unmarshal(*v, &policyAssignmentParameters) 1087 if err != nil { 1088 return err 1089 } 1090 ps.PolicyAssignmentParameters = &policyAssignmentParameters 1091 } 1092 case "policyAssignmentScope": 1093 if v != nil { 1094 var policyAssignmentScope string 1095 err = json.Unmarshal(*v, &policyAssignmentScope) 1096 if err != nil { 1097 return err 1098 } 1099 ps.PolicyAssignmentScope = &policyAssignmentScope 1100 } 1101 case "policyDefinitionName": 1102 if v != nil { 1103 var policyDefinitionName string 1104 err = json.Unmarshal(*v, &policyDefinitionName) 1105 if err != nil { 1106 return err 1107 } 1108 ps.PolicyDefinitionName = &policyDefinitionName 1109 } 1110 case "policyDefinitionAction": 1111 if v != nil { 1112 var policyDefinitionAction string 1113 err = json.Unmarshal(*v, &policyDefinitionAction) 1114 if err != nil { 1115 return err 1116 } 1117 ps.PolicyDefinitionAction = &policyDefinitionAction 1118 } 1119 case "policyDefinitionCategory": 1120 if v != nil { 1121 var policyDefinitionCategory string 1122 err = json.Unmarshal(*v, &policyDefinitionCategory) 1123 if err != nil { 1124 return err 1125 } 1126 ps.PolicyDefinitionCategory = &policyDefinitionCategory 1127 } 1128 case "policySetDefinitionId": 1129 if v != nil { 1130 var policySetDefinitionID string 1131 err = json.Unmarshal(*v, &policySetDefinitionID) 1132 if err != nil { 1133 return err 1134 } 1135 ps.PolicySetDefinitionID = &policySetDefinitionID 1136 } 1137 case "policySetDefinitionName": 1138 if v != nil { 1139 var policySetDefinitionName string 1140 err = json.Unmarshal(*v, &policySetDefinitionName) 1141 if err != nil { 1142 return err 1143 } 1144 ps.PolicySetDefinitionName = &policySetDefinitionName 1145 } 1146 case "policySetDefinitionOwner": 1147 if v != nil { 1148 var policySetDefinitionOwner string 1149 err = json.Unmarshal(*v, &policySetDefinitionOwner) 1150 if err != nil { 1151 return err 1152 } 1153 ps.PolicySetDefinitionOwner = &policySetDefinitionOwner 1154 } 1155 case "policySetDefinitionCategory": 1156 if v != nil { 1157 var policySetDefinitionCategory string 1158 err = json.Unmarshal(*v, &policySetDefinitionCategory) 1159 if err != nil { 1160 return err 1161 } 1162 ps.PolicySetDefinitionCategory = &policySetDefinitionCategory 1163 } 1164 case "policySetDefinitionParameters": 1165 if v != nil { 1166 var policySetDefinitionParameters string 1167 err = json.Unmarshal(*v, &policySetDefinitionParameters) 1168 if err != nil { 1169 return err 1170 } 1171 ps.PolicySetDefinitionParameters = &policySetDefinitionParameters 1172 } 1173 case "managementGroupIds": 1174 if v != nil { 1175 var managementGroupIds string 1176 err = json.Unmarshal(*v, &managementGroupIds) 1177 if err != nil { 1178 return err 1179 } 1180 ps.ManagementGroupIds = &managementGroupIds 1181 } 1182 case "policyDefinitionReferenceId": 1183 if v != nil { 1184 var policyDefinitionReferenceID string 1185 err = json.Unmarshal(*v, &policyDefinitionReferenceID) 1186 if err != nil { 1187 return err 1188 } 1189 ps.PolicyDefinitionReferenceID = &policyDefinitionReferenceID 1190 } 1191 case "complianceState": 1192 if v != nil { 1193 var complianceState string 1194 err = json.Unmarshal(*v, &complianceState) 1195 if err != nil { 1196 return err 1197 } 1198 ps.ComplianceState = &complianceState 1199 } 1200 case "policyEvaluationDetails": 1201 if v != nil { 1202 var policyEvaluationDetails PolicyEvaluationDetails 1203 err = json.Unmarshal(*v, &policyEvaluationDetails) 1204 if err != nil { 1205 return err 1206 } 1207 ps.PolicyEvaluationDetails = &policyEvaluationDetails 1208 } 1209 } 1210 } 1211 1212 return nil 1213} 1214 1215// PolicyStatesQueryResults query results. 1216type PolicyStatesQueryResults struct { 1217 autorest.Response `json:"-"` 1218 // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. 1219 OdataContext *string `json:"@odata.context,omitempty"` 1220 // OdataCount - OData entity count; represents the number of policy state records returned. 1221 OdataCount *int32 `json:"@odata.count,omitempty"` 1222 // OdataNextLink - Odata next link; URL to get the next set of results. 1223 OdataNextLink *string `json:"@odata.nextLink,omitempty"` 1224 // Value - Query results. 1225 Value *[]PolicyState `json:"value,omitempty"` 1226} 1227 1228// PolicyStatesQueryResultsIterator provides access to a complete listing of PolicyState values. 1229type PolicyStatesQueryResultsIterator struct { 1230 i int 1231 page PolicyStatesQueryResultsPage 1232} 1233 1234// NextWithContext advances to the next value. If there was an error making 1235// the request the iterator does not advance and the error is returned. 1236func (iter *PolicyStatesQueryResultsIterator) NextWithContext(ctx context.Context) (err error) { 1237 if tracing.IsEnabled() { 1238 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesQueryResultsIterator.NextWithContext") 1239 defer func() { 1240 sc := -1 1241 if iter.Response().Response.Response != nil { 1242 sc = iter.Response().Response.Response.StatusCode 1243 } 1244 tracing.EndSpan(ctx, sc, err) 1245 }() 1246 } 1247 iter.i++ 1248 if iter.i < len(iter.page.Values()) { 1249 return nil 1250 } 1251 err = iter.page.NextWithContext(ctx) 1252 if err != nil { 1253 iter.i-- 1254 return err 1255 } 1256 iter.i = 0 1257 return nil 1258} 1259 1260// Next advances to the next value. If there was an error making 1261// the request the iterator does not advance and the error is returned. 1262// Deprecated: Use NextWithContext() instead. 1263func (iter *PolicyStatesQueryResultsIterator) Next() error { 1264 return iter.NextWithContext(context.Background()) 1265} 1266 1267// NotDone returns true if the enumeration should be started or is not yet complete. 1268func (iter PolicyStatesQueryResultsIterator) NotDone() bool { 1269 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1270} 1271 1272// Response returns the raw server response from the last page request. 1273func (iter PolicyStatesQueryResultsIterator) Response() PolicyStatesQueryResults { 1274 return iter.page.Response() 1275} 1276 1277// Value returns the current value or a zero-initialized value if the 1278// iterator has advanced beyond the end of the collection. 1279func (iter PolicyStatesQueryResultsIterator) Value() PolicyState { 1280 if !iter.page.NotDone() { 1281 return PolicyState{} 1282 } 1283 return iter.page.Values()[iter.i] 1284} 1285 1286// Creates a new instance of the PolicyStatesQueryResultsIterator type. 1287func NewPolicyStatesQueryResultsIterator(page PolicyStatesQueryResultsPage) PolicyStatesQueryResultsIterator { 1288 return PolicyStatesQueryResultsIterator{page: page} 1289} 1290 1291// IsEmpty returns true if the ListResult contains no values. 1292func (psqr PolicyStatesQueryResults) IsEmpty() bool { 1293 return psqr.Value == nil || len(*psqr.Value) == 0 1294} 1295 1296// policyStatesQueryResultsPreparer prepares a request to retrieve the next set of results. 1297// It returns nil if no more results exist. 1298func (psqr PolicyStatesQueryResults) policyStatesQueryResultsPreparer(ctx context.Context) (*http.Request, error) { 1299 if psqr.OdataNextLink == nil || len(to.String(psqr.OdataNextLink)) < 1 { 1300 return nil, nil 1301 } 1302 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1303 autorest.AsJSON(), 1304 autorest.AsGet(), 1305 autorest.WithBaseURL(to.String(psqr.OdataNextLink))) 1306} 1307 1308// PolicyStatesQueryResultsPage contains a page of PolicyState values. 1309type PolicyStatesQueryResultsPage struct { 1310 fn func(context.Context, PolicyStatesQueryResults) (PolicyStatesQueryResults, error) 1311 psqr PolicyStatesQueryResults 1312} 1313 1314// NextWithContext advances to the next page of values. If there was an error making 1315// the request the page does not advance and the error is returned. 1316func (page *PolicyStatesQueryResultsPage) NextWithContext(ctx context.Context) (err error) { 1317 if tracing.IsEnabled() { 1318 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesQueryResultsPage.NextWithContext") 1319 defer func() { 1320 sc := -1 1321 if page.Response().Response.Response != nil { 1322 sc = page.Response().Response.Response.StatusCode 1323 } 1324 tracing.EndSpan(ctx, sc, err) 1325 }() 1326 } 1327 next, err := page.fn(ctx, page.psqr) 1328 if err != nil { 1329 return err 1330 } 1331 page.psqr = next 1332 return nil 1333} 1334 1335// Next advances to the next page of values. If there was an error making 1336// the request the page does not advance and the error is returned. 1337// Deprecated: Use NextWithContext() instead. 1338func (page *PolicyStatesQueryResultsPage) Next() error { 1339 return page.NextWithContext(context.Background()) 1340} 1341 1342// NotDone returns true if the page enumeration should be started or is not yet complete. 1343func (page PolicyStatesQueryResultsPage) NotDone() bool { 1344 return !page.psqr.IsEmpty() 1345} 1346 1347// Response returns the raw server response from the last page request. 1348func (page PolicyStatesQueryResultsPage) Response() PolicyStatesQueryResults { 1349 return page.psqr 1350} 1351 1352// Values returns the slice of values for the current page or nil if there are no values. 1353func (page PolicyStatesQueryResultsPage) Values() []PolicyState { 1354 if page.psqr.IsEmpty() { 1355 return nil 1356 } 1357 return *page.psqr.Value 1358} 1359 1360// Creates a new instance of the PolicyStatesQueryResultsPage type. 1361func NewPolicyStatesQueryResultsPage(getNextPage func(context.Context, PolicyStatesQueryResults) (PolicyStatesQueryResults, error)) PolicyStatesQueryResultsPage { 1362 return PolicyStatesQueryResultsPage{fn: getNextPage} 1363} 1364 1365// PolicyTrackedResource policy tracked resource record. 1366type PolicyTrackedResource struct { 1367 // TrackedResourceID - READ-ONLY; The ID of the policy tracked resource. 1368 TrackedResourceID *string `json:"trackedResourceId,omitempty"` 1369 // PolicyDetails - READ-ONLY; The details of the policy that require the tracked resource. 1370 PolicyDetails *PolicyDetails `json:"policyDetails,omitempty"` 1371 // CreatedBy - READ-ONLY; The details of the policy triggered deployment that created the tracked resource. 1372 CreatedBy *TrackedResourceModificationDetails `json:"createdBy,omitempty"` 1373 // LastModifiedBy - READ-ONLY; The details of the policy triggered deployment that modified the tracked resource. 1374 LastModifiedBy *TrackedResourceModificationDetails `json:"lastModifiedBy,omitempty"` 1375 // LastUpdateUtc - READ-ONLY; Timestamp of the last update to the tracked resource. 1376 LastUpdateUtc *date.Time `json:"lastUpdateUtc,omitempty"` 1377} 1378 1379// PolicyTrackedResourcesQueryResults query results. 1380type PolicyTrackedResourcesQueryResults struct { 1381 autorest.Response `json:"-"` 1382 // Value - READ-ONLY; Query results. 1383 Value *[]PolicyTrackedResource `json:"value,omitempty"` 1384 // NextLink - READ-ONLY; The URL to get the next set of results. 1385 NextLink *string `json:"nextLink,omitempty"` 1386} 1387 1388// PolicyTrackedResourcesQueryResultsIterator provides access to a complete listing of 1389// PolicyTrackedResource values. 1390type PolicyTrackedResourcesQueryResultsIterator struct { 1391 i int 1392 page PolicyTrackedResourcesQueryResultsPage 1393} 1394 1395// NextWithContext advances to the next value. If there was an error making 1396// the request the iterator does not advance and the error is returned. 1397func (iter *PolicyTrackedResourcesQueryResultsIterator) NextWithContext(ctx context.Context) (err error) { 1398 if tracing.IsEnabled() { 1399 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesQueryResultsIterator.NextWithContext") 1400 defer func() { 1401 sc := -1 1402 if iter.Response().Response.Response != nil { 1403 sc = iter.Response().Response.Response.StatusCode 1404 } 1405 tracing.EndSpan(ctx, sc, err) 1406 }() 1407 } 1408 iter.i++ 1409 if iter.i < len(iter.page.Values()) { 1410 return nil 1411 } 1412 err = iter.page.NextWithContext(ctx) 1413 if err != nil { 1414 iter.i-- 1415 return err 1416 } 1417 iter.i = 0 1418 return nil 1419} 1420 1421// Next advances to the next value. If there was an error making 1422// the request the iterator does not advance and the error is returned. 1423// Deprecated: Use NextWithContext() instead. 1424func (iter *PolicyTrackedResourcesQueryResultsIterator) Next() error { 1425 return iter.NextWithContext(context.Background()) 1426} 1427 1428// NotDone returns true if the enumeration should be started or is not yet complete. 1429func (iter PolicyTrackedResourcesQueryResultsIterator) NotDone() bool { 1430 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1431} 1432 1433// Response returns the raw server response from the last page request. 1434func (iter PolicyTrackedResourcesQueryResultsIterator) Response() PolicyTrackedResourcesQueryResults { 1435 return iter.page.Response() 1436} 1437 1438// Value returns the current value or a zero-initialized value if the 1439// iterator has advanced beyond the end of the collection. 1440func (iter PolicyTrackedResourcesQueryResultsIterator) Value() PolicyTrackedResource { 1441 if !iter.page.NotDone() { 1442 return PolicyTrackedResource{} 1443 } 1444 return iter.page.Values()[iter.i] 1445} 1446 1447// Creates a new instance of the PolicyTrackedResourcesQueryResultsIterator type. 1448func NewPolicyTrackedResourcesQueryResultsIterator(page PolicyTrackedResourcesQueryResultsPage) PolicyTrackedResourcesQueryResultsIterator { 1449 return PolicyTrackedResourcesQueryResultsIterator{page: page} 1450} 1451 1452// IsEmpty returns true if the ListResult contains no values. 1453func (ptrqr PolicyTrackedResourcesQueryResults) IsEmpty() bool { 1454 return ptrqr.Value == nil || len(*ptrqr.Value) == 0 1455} 1456 1457// policyTrackedResourcesQueryResultsPreparer prepares a request to retrieve the next set of results. 1458// It returns nil if no more results exist. 1459func (ptrqr PolicyTrackedResourcesQueryResults) policyTrackedResourcesQueryResultsPreparer(ctx context.Context) (*http.Request, error) { 1460 if ptrqr.NextLink == nil || len(to.String(ptrqr.NextLink)) < 1 { 1461 return nil, nil 1462 } 1463 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1464 autorest.AsJSON(), 1465 autorest.AsGet(), 1466 autorest.WithBaseURL(to.String(ptrqr.NextLink))) 1467} 1468 1469// PolicyTrackedResourcesQueryResultsPage contains a page of PolicyTrackedResource values. 1470type PolicyTrackedResourcesQueryResultsPage struct { 1471 fn func(context.Context, PolicyTrackedResourcesQueryResults) (PolicyTrackedResourcesQueryResults, error) 1472 ptrqr PolicyTrackedResourcesQueryResults 1473} 1474 1475// NextWithContext advances to the next page of values. If there was an error making 1476// the request the page does not advance and the error is returned. 1477func (page *PolicyTrackedResourcesQueryResultsPage) NextWithContext(ctx context.Context) (err error) { 1478 if tracing.IsEnabled() { 1479 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesQueryResultsPage.NextWithContext") 1480 defer func() { 1481 sc := -1 1482 if page.Response().Response.Response != nil { 1483 sc = page.Response().Response.Response.StatusCode 1484 } 1485 tracing.EndSpan(ctx, sc, err) 1486 }() 1487 } 1488 next, err := page.fn(ctx, page.ptrqr) 1489 if err != nil { 1490 return err 1491 } 1492 page.ptrqr = next 1493 return nil 1494} 1495 1496// Next advances to the next page of values. If there was an error making 1497// the request the page does not advance and the error is returned. 1498// Deprecated: Use NextWithContext() instead. 1499func (page *PolicyTrackedResourcesQueryResultsPage) Next() error { 1500 return page.NextWithContext(context.Background()) 1501} 1502 1503// NotDone returns true if the page enumeration should be started or is not yet complete. 1504func (page PolicyTrackedResourcesQueryResultsPage) NotDone() bool { 1505 return !page.ptrqr.IsEmpty() 1506} 1507 1508// Response returns the raw server response from the last page request. 1509func (page PolicyTrackedResourcesQueryResultsPage) Response() PolicyTrackedResourcesQueryResults { 1510 return page.ptrqr 1511} 1512 1513// Values returns the slice of values for the current page or nil if there are no values. 1514func (page PolicyTrackedResourcesQueryResultsPage) Values() []PolicyTrackedResource { 1515 if page.ptrqr.IsEmpty() { 1516 return nil 1517 } 1518 return *page.ptrqr.Value 1519} 1520 1521// Creates a new instance of the PolicyTrackedResourcesQueryResultsPage type. 1522func NewPolicyTrackedResourcesQueryResultsPage(getNextPage func(context.Context, PolicyTrackedResourcesQueryResults) (PolicyTrackedResourcesQueryResults, error)) PolicyTrackedResourcesQueryResultsPage { 1523 return PolicyTrackedResourcesQueryResultsPage{fn: getNextPage} 1524} 1525 1526// QueryFailure error response. 1527type QueryFailure struct { 1528 // Error - Error definition. 1529 Error *QueryFailureError `json:"error,omitempty"` 1530} 1531 1532// QueryFailureError error definition. 1533type QueryFailureError struct { 1534 // Code - READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. 1535 Code *string `json:"code,omitempty"` 1536 // Message - READ-ONLY; Description of the error. 1537 Message *string `json:"message,omitempty"` 1538} 1539 1540// Remediation the remediation definition. 1541type Remediation struct { 1542 autorest.Response `json:"-"` 1543 // RemediationProperties - Properties for the remediation. 1544 *RemediationProperties `json:"properties,omitempty"` 1545 // ID - READ-ONLY; The ID of the remediation. 1546 ID *string `json:"id,omitempty"` 1547 // Type - READ-ONLY; The type of the remediation. 1548 Type *string `json:"type,omitempty"` 1549 // Name - READ-ONLY; The name of the remediation. 1550 Name *string `json:"name,omitempty"` 1551} 1552 1553// MarshalJSON is the custom marshaler for Remediation. 1554func (r Remediation) MarshalJSON() ([]byte, error) { 1555 objectMap := make(map[string]interface{}) 1556 if r.RemediationProperties != nil { 1557 objectMap["properties"] = r.RemediationProperties 1558 } 1559 return json.Marshal(objectMap) 1560} 1561 1562// UnmarshalJSON is the custom unmarshaler for Remediation struct. 1563func (r *Remediation) UnmarshalJSON(body []byte) error { 1564 var m map[string]*json.RawMessage 1565 err := json.Unmarshal(body, &m) 1566 if err != nil { 1567 return err 1568 } 1569 for k, v := range m { 1570 switch k { 1571 case "properties": 1572 if v != nil { 1573 var remediationProperties RemediationProperties 1574 err = json.Unmarshal(*v, &remediationProperties) 1575 if err != nil { 1576 return err 1577 } 1578 r.RemediationProperties = &remediationProperties 1579 } 1580 case "id": 1581 if v != nil { 1582 var ID string 1583 err = json.Unmarshal(*v, &ID) 1584 if err != nil { 1585 return err 1586 } 1587 r.ID = &ID 1588 } 1589 case "type": 1590 if v != nil { 1591 var typeVar string 1592 err = json.Unmarshal(*v, &typeVar) 1593 if err != nil { 1594 return err 1595 } 1596 r.Type = &typeVar 1597 } 1598 case "name": 1599 if v != nil { 1600 var name string 1601 err = json.Unmarshal(*v, &name) 1602 if err != nil { 1603 return err 1604 } 1605 r.Name = &name 1606 } 1607 } 1608 } 1609 1610 return nil 1611} 1612 1613// RemediationDeployment details of a single deployment created by the remediation. 1614type RemediationDeployment struct { 1615 // RemediatedResourceID - READ-ONLY; Resource ID of the resource that is being remediated by the deployment. 1616 RemediatedResourceID *string `json:"remediatedResourceId,omitempty"` 1617 // DeploymentID - READ-ONLY; Resource ID of the template deployment that will remediate the resource. 1618 DeploymentID *string `json:"deploymentId,omitempty"` 1619 // Status - READ-ONLY; Status of the remediation deployment. 1620 Status *string `json:"status,omitempty"` 1621 // ResourceLocation - READ-ONLY; Location of the resource that is being remediated. 1622 ResourceLocation *string `json:"resourceLocation,omitempty"` 1623 // Error - READ-ONLY; Error encountered while remediated the resource. 1624 Error *ErrorDefinition `json:"error,omitempty"` 1625 // CreatedOn - READ-ONLY; The time at which the remediation was created. 1626 CreatedOn *date.Time `json:"createdOn,omitempty"` 1627 // LastUpdatedOn - READ-ONLY; The time at which the remediation deployment was last updated. 1628 LastUpdatedOn *date.Time `json:"lastUpdatedOn,omitempty"` 1629} 1630 1631// RemediationDeploymentsListResult list of deployments for a remediation. 1632type RemediationDeploymentsListResult struct { 1633 autorest.Response `json:"-"` 1634 // Value - READ-ONLY; Array of deployments for the remediation. 1635 Value *[]RemediationDeployment `json:"value,omitempty"` 1636 // NextLink - READ-ONLY; The URL to get the next set of results. 1637 NextLink *string `json:"nextLink,omitempty"` 1638} 1639 1640// RemediationDeploymentsListResultIterator provides access to a complete listing of RemediationDeployment 1641// values. 1642type RemediationDeploymentsListResultIterator struct { 1643 i int 1644 page RemediationDeploymentsListResultPage 1645} 1646 1647// NextWithContext advances to the next value. If there was an error making 1648// the request the iterator does not advance and the error is returned. 1649func (iter *RemediationDeploymentsListResultIterator) NextWithContext(ctx context.Context) (err error) { 1650 if tracing.IsEnabled() { 1651 ctx = tracing.StartSpan(ctx, fqdn+"/RemediationDeploymentsListResultIterator.NextWithContext") 1652 defer func() { 1653 sc := -1 1654 if iter.Response().Response.Response != nil { 1655 sc = iter.Response().Response.Response.StatusCode 1656 } 1657 tracing.EndSpan(ctx, sc, err) 1658 }() 1659 } 1660 iter.i++ 1661 if iter.i < len(iter.page.Values()) { 1662 return nil 1663 } 1664 err = iter.page.NextWithContext(ctx) 1665 if err != nil { 1666 iter.i-- 1667 return err 1668 } 1669 iter.i = 0 1670 return nil 1671} 1672 1673// Next advances to the next value. If there was an error making 1674// the request the iterator does not advance and the error is returned. 1675// Deprecated: Use NextWithContext() instead. 1676func (iter *RemediationDeploymentsListResultIterator) Next() error { 1677 return iter.NextWithContext(context.Background()) 1678} 1679 1680// NotDone returns true if the enumeration should be started or is not yet complete. 1681func (iter RemediationDeploymentsListResultIterator) NotDone() bool { 1682 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1683} 1684 1685// Response returns the raw server response from the last page request. 1686func (iter RemediationDeploymentsListResultIterator) Response() RemediationDeploymentsListResult { 1687 return iter.page.Response() 1688} 1689 1690// Value returns the current value or a zero-initialized value if the 1691// iterator has advanced beyond the end of the collection. 1692func (iter RemediationDeploymentsListResultIterator) Value() RemediationDeployment { 1693 if !iter.page.NotDone() { 1694 return RemediationDeployment{} 1695 } 1696 return iter.page.Values()[iter.i] 1697} 1698 1699// Creates a new instance of the RemediationDeploymentsListResultIterator type. 1700func NewRemediationDeploymentsListResultIterator(page RemediationDeploymentsListResultPage) RemediationDeploymentsListResultIterator { 1701 return RemediationDeploymentsListResultIterator{page: page} 1702} 1703 1704// IsEmpty returns true if the ListResult contains no values. 1705func (rdlr RemediationDeploymentsListResult) IsEmpty() bool { 1706 return rdlr.Value == nil || len(*rdlr.Value) == 0 1707} 1708 1709// remediationDeploymentsListResultPreparer prepares a request to retrieve the next set of results. 1710// It returns nil if no more results exist. 1711func (rdlr RemediationDeploymentsListResult) remediationDeploymentsListResultPreparer(ctx context.Context) (*http.Request, error) { 1712 if rdlr.NextLink == nil || len(to.String(rdlr.NextLink)) < 1 { 1713 return nil, nil 1714 } 1715 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1716 autorest.AsJSON(), 1717 autorest.AsGet(), 1718 autorest.WithBaseURL(to.String(rdlr.NextLink))) 1719} 1720 1721// RemediationDeploymentsListResultPage contains a page of RemediationDeployment values. 1722type RemediationDeploymentsListResultPage struct { 1723 fn func(context.Context, RemediationDeploymentsListResult) (RemediationDeploymentsListResult, error) 1724 rdlr RemediationDeploymentsListResult 1725} 1726 1727// NextWithContext advances to the next page of values. If there was an error making 1728// the request the page does not advance and the error is returned. 1729func (page *RemediationDeploymentsListResultPage) NextWithContext(ctx context.Context) (err error) { 1730 if tracing.IsEnabled() { 1731 ctx = tracing.StartSpan(ctx, fqdn+"/RemediationDeploymentsListResultPage.NextWithContext") 1732 defer func() { 1733 sc := -1 1734 if page.Response().Response.Response != nil { 1735 sc = page.Response().Response.Response.StatusCode 1736 } 1737 tracing.EndSpan(ctx, sc, err) 1738 }() 1739 } 1740 next, err := page.fn(ctx, page.rdlr) 1741 if err != nil { 1742 return err 1743 } 1744 page.rdlr = next 1745 return nil 1746} 1747 1748// Next advances to the next page of values. If there was an error making 1749// the request the page does not advance and the error is returned. 1750// Deprecated: Use NextWithContext() instead. 1751func (page *RemediationDeploymentsListResultPage) Next() error { 1752 return page.NextWithContext(context.Background()) 1753} 1754 1755// NotDone returns true if the page enumeration should be started or is not yet complete. 1756func (page RemediationDeploymentsListResultPage) NotDone() bool { 1757 return !page.rdlr.IsEmpty() 1758} 1759 1760// Response returns the raw server response from the last page request. 1761func (page RemediationDeploymentsListResultPage) Response() RemediationDeploymentsListResult { 1762 return page.rdlr 1763} 1764 1765// Values returns the slice of values for the current page or nil if there are no values. 1766func (page RemediationDeploymentsListResultPage) Values() []RemediationDeployment { 1767 if page.rdlr.IsEmpty() { 1768 return nil 1769 } 1770 return *page.rdlr.Value 1771} 1772 1773// Creates a new instance of the RemediationDeploymentsListResultPage type. 1774func NewRemediationDeploymentsListResultPage(getNextPage func(context.Context, RemediationDeploymentsListResult) (RemediationDeploymentsListResult, error)) RemediationDeploymentsListResultPage { 1775 return RemediationDeploymentsListResultPage{fn: getNextPage} 1776} 1777 1778// RemediationDeploymentSummary the deployment status summary for all deployments created by the 1779// remediation. 1780type RemediationDeploymentSummary struct { 1781 // TotalDeployments - The number of deployments required by the remediation. 1782 TotalDeployments *int32 `json:"totalDeployments,omitempty"` 1783 // SuccessfulDeployments - The number of deployments required by the remediation that have succeeded. 1784 SuccessfulDeployments *int32 `json:"successfulDeployments,omitempty"` 1785 // FailedDeployments - The number of deployments required by the remediation that have failed. 1786 FailedDeployments *int32 `json:"failedDeployments,omitempty"` 1787} 1788 1789// RemediationFilters the filters that will be applied to determine which resources to remediate. 1790type RemediationFilters struct { 1791 // Locations - The resource locations that will be remediated. 1792 Locations *[]string `json:"locations,omitempty"` 1793} 1794 1795// RemediationListResult list of remediations. 1796type RemediationListResult struct { 1797 autorest.Response `json:"-"` 1798 // Value - READ-ONLY; Array of remediation definitions. 1799 Value *[]Remediation `json:"value,omitempty"` 1800 // NextLink - READ-ONLY; The URL to get the next set of results. 1801 NextLink *string `json:"nextLink,omitempty"` 1802} 1803 1804// RemediationListResultIterator provides access to a complete listing of Remediation values. 1805type RemediationListResultIterator struct { 1806 i int 1807 page RemediationListResultPage 1808} 1809 1810// NextWithContext advances to the next value. If there was an error making 1811// the request the iterator does not advance and the error is returned. 1812func (iter *RemediationListResultIterator) NextWithContext(ctx context.Context) (err error) { 1813 if tracing.IsEnabled() { 1814 ctx = tracing.StartSpan(ctx, fqdn+"/RemediationListResultIterator.NextWithContext") 1815 defer func() { 1816 sc := -1 1817 if iter.Response().Response.Response != nil { 1818 sc = iter.Response().Response.Response.StatusCode 1819 } 1820 tracing.EndSpan(ctx, sc, err) 1821 }() 1822 } 1823 iter.i++ 1824 if iter.i < len(iter.page.Values()) { 1825 return nil 1826 } 1827 err = iter.page.NextWithContext(ctx) 1828 if err != nil { 1829 iter.i-- 1830 return err 1831 } 1832 iter.i = 0 1833 return nil 1834} 1835 1836// Next advances to the next value. If there was an error making 1837// the request the iterator does not advance and the error is returned. 1838// Deprecated: Use NextWithContext() instead. 1839func (iter *RemediationListResultIterator) Next() error { 1840 return iter.NextWithContext(context.Background()) 1841} 1842 1843// NotDone returns true if the enumeration should be started or is not yet complete. 1844func (iter RemediationListResultIterator) NotDone() bool { 1845 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1846} 1847 1848// Response returns the raw server response from the last page request. 1849func (iter RemediationListResultIterator) Response() RemediationListResult { 1850 return iter.page.Response() 1851} 1852 1853// Value returns the current value or a zero-initialized value if the 1854// iterator has advanced beyond the end of the collection. 1855func (iter RemediationListResultIterator) Value() Remediation { 1856 if !iter.page.NotDone() { 1857 return Remediation{} 1858 } 1859 return iter.page.Values()[iter.i] 1860} 1861 1862// Creates a new instance of the RemediationListResultIterator type. 1863func NewRemediationListResultIterator(page RemediationListResultPage) RemediationListResultIterator { 1864 return RemediationListResultIterator{page: page} 1865} 1866 1867// IsEmpty returns true if the ListResult contains no values. 1868func (rlr RemediationListResult) IsEmpty() bool { 1869 return rlr.Value == nil || len(*rlr.Value) == 0 1870} 1871 1872// remediationListResultPreparer prepares a request to retrieve the next set of results. 1873// It returns nil if no more results exist. 1874func (rlr RemediationListResult) remediationListResultPreparer(ctx context.Context) (*http.Request, error) { 1875 if rlr.NextLink == nil || len(to.String(rlr.NextLink)) < 1 { 1876 return nil, nil 1877 } 1878 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1879 autorest.AsJSON(), 1880 autorest.AsGet(), 1881 autorest.WithBaseURL(to.String(rlr.NextLink))) 1882} 1883 1884// RemediationListResultPage contains a page of Remediation values. 1885type RemediationListResultPage struct { 1886 fn func(context.Context, RemediationListResult) (RemediationListResult, error) 1887 rlr RemediationListResult 1888} 1889 1890// NextWithContext advances to the next page of values. If there was an error making 1891// the request the page does not advance and the error is returned. 1892func (page *RemediationListResultPage) NextWithContext(ctx context.Context) (err error) { 1893 if tracing.IsEnabled() { 1894 ctx = tracing.StartSpan(ctx, fqdn+"/RemediationListResultPage.NextWithContext") 1895 defer func() { 1896 sc := -1 1897 if page.Response().Response.Response != nil { 1898 sc = page.Response().Response.Response.StatusCode 1899 } 1900 tracing.EndSpan(ctx, sc, err) 1901 }() 1902 } 1903 next, err := page.fn(ctx, page.rlr) 1904 if err != nil { 1905 return err 1906 } 1907 page.rlr = next 1908 return nil 1909} 1910 1911// Next advances to the next page of values. If there was an error making 1912// the request the page does not advance and the error is returned. 1913// Deprecated: Use NextWithContext() instead. 1914func (page *RemediationListResultPage) Next() error { 1915 return page.NextWithContext(context.Background()) 1916} 1917 1918// NotDone returns true if the page enumeration should be started or is not yet complete. 1919func (page RemediationListResultPage) NotDone() bool { 1920 return !page.rlr.IsEmpty() 1921} 1922 1923// Response returns the raw server response from the last page request. 1924func (page RemediationListResultPage) Response() RemediationListResult { 1925 return page.rlr 1926} 1927 1928// Values returns the slice of values for the current page or nil if there are no values. 1929func (page RemediationListResultPage) Values() []Remediation { 1930 if page.rlr.IsEmpty() { 1931 return nil 1932 } 1933 return *page.rlr.Value 1934} 1935 1936// Creates a new instance of the RemediationListResultPage type. 1937func NewRemediationListResultPage(getNextPage func(context.Context, RemediationListResult) (RemediationListResult, error)) RemediationListResultPage { 1938 return RemediationListResultPage{fn: getNextPage} 1939} 1940 1941// RemediationProperties the remediation properties. 1942type RemediationProperties struct { 1943 // PolicyAssignmentID - The resource ID of the policy assignment that should be remediated. 1944 PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` 1945 // PolicyDefinitionReferenceID - The policy definition reference ID of the individual definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition. 1946 PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` 1947 // ProvisioningState - READ-ONLY; The status of the remediation. 1948 ProvisioningState *string `json:"provisioningState,omitempty"` 1949 // CreatedOn - READ-ONLY; The time at which the remediation was created. 1950 CreatedOn *date.Time `json:"createdOn,omitempty"` 1951 // LastUpdatedOn - READ-ONLY; The time at which the remediation was last updated. 1952 LastUpdatedOn *date.Time `json:"lastUpdatedOn,omitempty"` 1953 // Filters - The filters that will be applied to determine which resources to remediate. 1954 Filters *RemediationFilters `json:"filters,omitempty"` 1955 // DeploymentStatus - The deployment status summary for all deployments created by the remediation. 1956 DeploymentStatus *RemediationDeploymentSummary `json:"deploymentStatus,omitempty"` 1957} 1958 1959// String ... 1960type String struct { 1961 autorest.Response `json:"-"` 1962 Value *string `json:"value,omitempty"` 1963} 1964 1965// SummarizeResults summarize action results. 1966type SummarizeResults struct { 1967 autorest.Response `json:"-"` 1968 // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. 1969 OdataContext *string `json:"@odata.context,omitempty"` 1970 // OdataCount - OData entity count; represents the number of summaries returned; always set to 1. 1971 OdataCount *int32 `json:"@odata.count,omitempty"` 1972 // Value - Summarize action results. 1973 Value *[]Summary `json:"value,omitempty"` 1974} 1975 1976// Summary summary results. 1977type Summary struct { 1978 // OdataID - OData entity ID; always set to null since summaries do not have an entity ID. 1979 OdataID *string `json:"@odata.id,omitempty"` 1980 // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. 1981 OdataContext *string `json:"@odata.context,omitempty"` 1982 // Results - Non-compliance summary for all policy assignments. 1983 Results *SummaryResults `json:"results,omitempty"` 1984 // PolicyAssignments - Policy assignments summary. 1985 PolicyAssignments *[]PolicyAssignmentSummary `json:"policyAssignments,omitempty"` 1986} 1987 1988// SummaryResults non-compliance summary on a particular summary level. 1989type SummaryResults struct { 1990 // QueryResultsURI - HTTP POST URI for queryResults action on Microsoft.PolicyInsights to retrieve raw results for the non-compliance summary. 1991 QueryResultsURI *string `json:"queryResultsUri,omitempty"` 1992 // NonCompliantResources - Number of non-compliant resources. 1993 NonCompliantResources *int32 `json:"nonCompliantResources,omitempty"` 1994 // NonCompliantPolicies - Number of non-compliant policies. 1995 NonCompliantPolicies *int32 `json:"nonCompliantPolicies,omitempty"` 1996} 1997 1998// TrackedResourceModificationDetails the details of the policy triggered deployment that created or 1999// modified the tracked resource. 2000type TrackedResourceModificationDetails struct { 2001 // PolicyDetails - READ-ONLY; The details of the policy that created or modified the tracked resource. 2002 PolicyDetails *PolicyDetails `json:"policyDetails,omitempty"` 2003 // DeploymentID - READ-ONLY; The ID of the deployment that created or modified the tracked resource. 2004 DeploymentID *string `json:"deploymentId,omitempty"` 2005 // DeploymentTime - READ-ONLY; Timestamp of the deployment that created or modified the tracked resource. 2006 DeploymentTime *date.Time `json:"deploymentTime,omitempty"` 2007} 2008 2009// TypedErrorInfo scenario specific error details. 2010type TypedErrorInfo struct { 2011 // Type - READ-ONLY; The type of included error details. 2012 Type *string `json:"type,omitempty"` 2013 // Info - READ-ONLY; The scenario specific error details. 2014 Info interface{} `json:"info,omitempty"` 2015} 2016