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/azure" 25 "github.com/Azure/go-autorest/autorest/date" 26 "github.com/Azure/go-autorest/autorest/to" 27 "github.com/Azure/go-autorest/tracing" 28 "net/http" 29) 30 31// The package's fully qualified name. 32const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/policyinsights/mgmt/2020-07-01-preview/policyinsights" 33 34// CheckRestrictionsRequest the check policy restrictions parameters describing the resource that is being 35// evaluated. 36type CheckRestrictionsRequest struct { 37 // ResourceDetails - The information about the resource that will be evaluated. 38 ResourceDetails *CheckRestrictionsResourceDetails `json:"resourceDetails,omitempty"` 39 // PendingFields - The list of fields and values that should be evaluated for potential restrictions. 40 PendingFields *[]PendingField `json:"pendingFields,omitempty"` 41} 42 43// CheckRestrictionsResourceDetails the information about the resource that will be evaluated. 44type CheckRestrictionsResourceDetails struct { 45 // ResourceContent - The resource content. This should include whatever properties are already known and can be a partial set of all resource properties. 46 ResourceContent interface{} `json:"resourceContent,omitempty"` 47 // APIVersion - The api-version of the resource content. 48 APIVersion *string `json:"apiVersion,omitempty"` 49 // Scope - The scope where the resource is being created. For example, if the resource is a child resource this would be the parent resource's resource ID. 50 Scope *string `json:"scope,omitempty"` 51} 52 53// CheckRestrictionsResult the result of a check policy restrictions evaluation on a resource. 54type CheckRestrictionsResult struct { 55 autorest.Response `json:"-"` 56 // FieldRestrictions - READ-ONLY; The restrictions that will be placed on various fields in the resource by policy. 57 FieldRestrictions *[]FieldRestrictions `json:"fieldRestrictions,omitempty"` 58 // ContentEvaluationResult - READ-ONLY; Evaluation results for the provided partial resource content. 59 ContentEvaluationResult *CheckRestrictionsResultContentEvaluationResult `json:"contentEvaluationResult,omitempty"` 60} 61 62// CheckRestrictionsResultContentEvaluationResult evaluation results for the provided partial resource 63// content. 64type CheckRestrictionsResultContentEvaluationResult struct { 65 // PolicyEvaluations - Policy evaluation results against the given resource content. This will indicate if the partial content that was provided will be denied as-is. 66 PolicyEvaluations *[]PolicyEvaluationResult `json:"policyEvaluations,omitempty"` 67} 68 69// ComplianceDetail the compliance state rollup. 70type ComplianceDetail struct { 71 // ComplianceState - The compliance state. 72 ComplianceState *string `json:"complianceState,omitempty"` 73 // Count - Summarized count value for this compliance state. 74 Count *int32 `json:"count,omitempty"` 75} 76 77// ComponentEventDetails component event details. 78type ComponentEventDetails struct { 79 // AdditionalProperties - Unmatched properties from the message are deserialized this collection 80 AdditionalProperties map[string]interface{} `json:""` 81 // ID - Component Id. 82 ID *string `json:"id,omitempty"` 83 // Type - Component type. 84 Type *string `json:"type,omitempty"` 85 // Name - Component name. 86 Name *string `json:"name,omitempty"` 87 // Timestamp - Timestamp for component policy event record. 88 Timestamp *date.Time `json:"timestamp,omitempty"` 89 // TenantID - Tenant ID for the policy event record. 90 TenantID *string `json:"tenantId,omitempty"` 91 // PrincipalOid - Principal object ID for the user who initiated the resource component operation that triggered the policy event. 92 PrincipalOid *string `json:"principalOid,omitempty"` 93 // PolicyDefinitionAction - Policy definition action, i.e. effect. 94 PolicyDefinitionAction *string `json:"policyDefinitionAction,omitempty"` 95} 96 97// MarshalJSON is the custom marshaler for ComponentEventDetails. 98func (ced ComponentEventDetails) MarshalJSON() ([]byte, error) { 99 objectMap := make(map[string]interface{}) 100 if ced.ID != nil { 101 objectMap["id"] = ced.ID 102 } 103 if ced.Type != nil { 104 objectMap["type"] = ced.Type 105 } 106 if ced.Name != nil { 107 objectMap["name"] = ced.Name 108 } 109 if ced.Timestamp != nil { 110 objectMap["timestamp"] = ced.Timestamp 111 } 112 if ced.TenantID != nil { 113 objectMap["tenantId"] = ced.TenantID 114 } 115 if ced.PrincipalOid != nil { 116 objectMap["principalOid"] = ced.PrincipalOid 117 } 118 if ced.PolicyDefinitionAction != nil { 119 objectMap["policyDefinitionAction"] = ced.PolicyDefinitionAction 120 } 121 for k, v := range ced.AdditionalProperties { 122 objectMap[k] = v 123 } 124 return json.Marshal(objectMap) 125} 126 127// UnmarshalJSON is the custom unmarshaler for ComponentEventDetails struct. 128func (ced *ComponentEventDetails) UnmarshalJSON(body []byte) error { 129 var m map[string]*json.RawMessage 130 err := json.Unmarshal(body, &m) 131 if err != nil { 132 return err 133 } 134 for k, v := range m { 135 switch k { 136 default: 137 if v != nil { 138 var additionalProperties interface{} 139 err = json.Unmarshal(*v, &additionalProperties) 140 if err != nil { 141 return err 142 } 143 if ced.AdditionalProperties == nil { 144 ced.AdditionalProperties = make(map[string]interface{}) 145 } 146 ced.AdditionalProperties[k] = additionalProperties 147 } 148 case "id": 149 if v != nil { 150 var ID string 151 err = json.Unmarshal(*v, &ID) 152 if err != nil { 153 return err 154 } 155 ced.ID = &ID 156 } 157 case "type": 158 if v != nil { 159 var typeVar string 160 err = json.Unmarshal(*v, &typeVar) 161 if err != nil { 162 return err 163 } 164 ced.Type = &typeVar 165 } 166 case "name": 167 if v != nil { 168 var name string 169 err = json.Unmarshal(*v, &name) 170 if err != nil { 171 return err 172 } 173 ced.Name = &name 174 } 175 case "timestamp": 176 if v != nil { 177 var timestamp date.Time 178 err = json.Unmarshal(*v, ×tamp) 179 if err != nil { 180 return err 181 } 182 ced.Timestamp = ×tamp 183 } 184 case "tenantId": 185 if v != nil { 186 var tenantID string 187 err = json.Unmarshal(*v, &tenantID) 188 if err != nil { 189 return err 190 } 191 ced.TenantID = &tenantID 192 } 193 case "principalOid": 194 if v != nil { 195 var principalOid string 196 err = json.Unmarshal(*v, &principalOid) 197 if err != nil { 198 return err 199 } 200 ced.PrincipalOid = &principalOid 201 } 202 case "policyDefinitionAction": 203 if v != nil { 204 var policyDefinitionAction string 205 err = json.Unmarshal(*v, &policyDefinitionAction) 206 if err != nil { 207 return err 208 } 209 ced.PolicyDefinitionAction = &policyDefinitionAction 210 } 211 } 212 } 213 214 return nil 215} 216 217// ComponentStateDetails component state details. 218type ComponentStateDetails struct { 219 // AdditionalProperties - Unmatched properties from the message are deserialized this collection 220 AdditionalProperties map[string]interface{} `json:""` 221 // ID - Component Id. 222 ID *string `json:"id,omitempty"` 223 // Type - Component type. 224 Type *string `json:"type,omitempty"` 225 // Name - Component name. 226 Name *string `json:"name,omitempty"` 227 // Timestamp - Component compliance evaluation timestamp. 228 Timestamp *date.Time `json:"timestamp,omitempty"` 229 // ComplianceState - Component compliance state. 230 ComplianceState *string `json:"complianceState,omitempty"` 231} 232 233// MarshalJSON is the custom marshaler for ComponentStateDetails. 234func (csd ComponentStateDetails) MarshalJSON() ([]byte, error) { 235 objectMap := make(map[string]interface{}) 236 if csd.ID != nil { 237 objectMap["id"] = csd.ID 238 } 239 if csd.Type != nil { 240 objectMap["type"] = csd.Type 241 } 242 if csd.Name != nil { 243 objectMap["name"] = csd.Name 244 } 245 if csd.Timestamp != nil { 246 objectMap["timestamp"] = csd.Timestamp 247 } 248 if csd.ComplianceState != nil { 249 objectMap["complianceState"] = csd.ComplianceState 250 } 251 for k, v := range csd.AdditionalProperties { 252 objectMap[k] = v 253 } 254 return json.Marshal(objectMap) 255} 256 257// UnmarshalJSON is the custom unmarshaler for ComponentStateDetails struct. 258func (csd *ComponentStateDetails) UnmarshalJSON(body []byte) error { 259 var m map[string]*json.RawMessage 260 err := json.Unmarshal(body, &m) 261 if err != nil { 262 return err 263 } 264 for k, v := range m { 265 switch k { 266 default: 267 if v != nil { 268 var additionalProperties interface{} 269 err = json.Unmarshal(*v, &additionalProperties) 270 if err != nil { 271 return err 272 } 273 if csd.AdditionalProperties == nil { 274 csd.AdditionalProperties = make(map[string]interface{}) 275 } 276 csd.AdditionalProperties[k] = additionalProperties 277 } 278 case "id": 279 if v != nil { 280 var ID string 281 err = json.Unmarshal(*v, &ID) 282 if err != nil { 283 return err 284 } 285 csd.ID = &ID 286 } 287 case "type": 288 if v != nil { 289 var typeVar string 290 err = json.Unmarshal(*v, &typeVar) 291 if err != nil { 292 return err 293 } 294 csd.Type = &typeVar 295 } 296 case "name": 297 if v != nil { 298 var name string 299 err = json.Unmarshal(*v, &name) 300 if err != nil { 301 return err 302 } 303 csd.Name = &name 304 } 305 case "timestamp": 306 if v != nil { 307 var timestamp date.Time 308 err = json.Unmarshal(*v, ×tamp) 309 if err != nil { 310 return err 311 } 312 csd.Timestamp = ×tamp 313 } 314 case "complianceState": 315 if v != nil { 316 var complianceState string 317 err = json.Unmarshal(*v, &complianceState) 318 if err != nil { 319 return err 320 } 321 csd.ComplianceState = &complianceState 322 } 323 } 324 } 325 326 return nil 327} 328 329// ErrorDefinition error definition. 330type ErrorDefinition struct { 331 // Code - READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. 332 Code *string `json:"code,omitempty"` 333 // Message - READ-ONLY; Description of the error. 334 Message *string `json:"message,omitempty"` 335 // Target - READ-ONLY; The target of the error. 336 Target *string `json:"target,omitempty"` 337 // Details - READ-ONLY; Internal error details. 338 Details *[]ErrorDefinition `json:"details,omitempty"` 339 // AdditionalInfo - READ-ONLY; Additional scenario specific error details. 340 AdditionalInfo *[]TypedErrorInfo `json:"additionalInfo,omitempty"` 341} 342 343// ErrorResponse error response. 344type ErrorResponse struct { 345 // Error - The error details. 346 Error *ErrorDefinition `json:"error,omitempty"` 347} 348 349// ExpressionEvaluationDetails evaluation details of policy language expressions. 350type ExpressionEvaluationDetails struct { 351 // Result - Evaluation result. 352 Result *string `json:"result,omitempty"` 353 // Expression - Expression evaluated. 354 Expression *string `json:"expression,omitempty"` 355 // ExpressionKind - READ-ONLY; The kind of expression that was evaluated. 356 ExpressionKind *string `json:"expressionKind,omitempty"` 357 // Path - Property path if the expression is a field or an alias. 358 Path *string `json:"path,omitempty"` 359 // ExpressionValue - Value of the expression. 360 ExpressionValue interface{} `json:"expressionValue,omitempty"` 361 // TargetValue - Target value to be compared with the expression value. 362 TargetValue interface{} `json:"targetValue,omitempty"` 363 // Operator - Operator to compare the expression value and the target value. 364 Operator *string `json:"operator,omitempty"` 365} 366 367// MarshalJSON is the custom marshaler for ExpressionEvaluationDetails. 368func (eed ExpressionEvaluationDetails) MarshalJSON() ([]byte, error) { 369 objectMap := make(map[string]interface{}) 370 if eed.Result != nil { 371 objectMap["result"] = eed.Result 372 } 373 if eed.Expression != nil { 374 objectMap["expression"] = eed.Expression 375 } 376 if eed.Path != nil { 377 objectMap["path"] = eed.Path 378 } 379 if eed.ExpressionValue != nil { 380 objectMap["expressionValue"] = eed.ExpressionValue 381 } 382 if eed.TargetValue != nil { 383 objectMap["targetValue"] = eed.TargetValue 384 } 385 if eed.Operator != nil { 386 objectMap["operator"] = eed.Operator 387 } 388 return json.Marshal(objectMap) 389} 390 391// FieldRestriction the restrictions on a field imposed by a specific policy. 392type FieldRestriction struct { 393 // Result - READ-ONLY; The type of restriction that is imposed on the field. Possible values include: 'Required', 'Removed', 'Deny' 394 Result FieldRestrictionResult `json:"result,omitempty"` 395 // DefaultValue - READ-ONLY; The value that policy will set for the field if the user does not provide a value. 396 DefaultValue *string `json:"defaultValue,omitempty"` 397 // Values - READ-ONLY; The values that policy either requires or denies for the field. 398 Values *[]string `json:"values,omitempty"` 399 // Policy - READ-ONLY; The details of the policy that is causing the field restriction. 400 Policy *PolicyReference `json:"policy,omitempty"` 401} 402 403// FieldRestrictions the restrictions that will be placed on a field in the resource by policy. 404type FieldRestrictions struct { 405 // Field - READ-ONLY; The name of the field. This can be a top-level property like 'name' or 'type' or an Azure Policy field alias. 406 Field *string `json:"field,omitempty"` 407 // Restrictions - The restrictions placed on that field by policy. 408 Restrictions *[]FieldRestriction `json:"restrictions,omitempty"` 409} 410 411// MarshalJSON is the custom marshaler for FieldRestrictions. 412func (fr FieldRestrictions) MarshalJSON() ([]byte, error) { 413 objectMap := make(map[string]interface{}) 414 if fr.Restrictions != nil { 415 objectMap["restrictions"] = fr.Restrictions 416 } 417 return json.Marshal(objectMap) 418} 419 420// IfNotExistsEvaluationDetails evaluation details of IfNotExists effect. 421type IfNotExistsEvaluationDetails struct { 422 // ResourceID - ID of the last evaluated resource for IfNotExists effect. 423 ResourceID *string `json:"resourceId,omitempty"` 424 // TotalResources - Total number of resources to which the existence condition is applicable. 425 TotalResources *int32 `json:"totalResources,omitempty"` 426} 427 428// Operation operation definition. 429type Operation struct { 430 // Name - Operation name. 431 Name *string `json:"name,omitempty"` 432 // Display - Display metadata associated with the operation. 433 Display *OperationDisplay `json:"display,omitempty"` 434} 435 436// OperationDisplay display metadata associated with the operation. 437type OperationDisplay struct { 438 // Provider - Resource provider name. 439 Provider *string `json:"provider,omitempty"` 440 // Resource - Resource name on which the operation is performed. 441 Resource *string `json:"resource,omitempty"` 442 // Operation - Operation name. 443 Operation *string `json:"operation,omitempty"` 444 // Description - Operation description. 445 Description *string `json:"description,omitempty"` 446} 447 448// OperationsListResults list of available operations. 449type OperationsListResults struct { 450 autorest.Response `json:"-"` 451 // OdataCount - OData entity count; represents the number of operations returned. 452 OdataCount *int32 `json:"@odata.count,omitempty"` 453 // Value - List of available operations. 454 Value *[]Operation `json:"value,omitempty"` 455} 456 457// PendingField a field that should be evaluated against Azure Policy to determine restrictions. 458type PendingField struct { 459 // Field - The name of the field. This can be a top-level property like 'name' or 'type' or an Azure Policy field alias. 460 Field *string `json:"field,omitempty"` 461 // Values - The list of potential values for the field that should be evaluated against Azure Policy. 462 Values *[]string `json:"values,omitempty"` 463} 464 465// PolicyAssignmentSummary policy assignment summary. 466type PolicyAssignmentSummary struct { 467 // PolicyAssignmentID - Policy assignment ID. 468 PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` 469 // PolicySetDefinitionID - Policy set definition ID, if the policy assignment is for a policy set. 470 PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty"` 471 // Results - Compliance summary for the policy assignment. 472 Results *SummaryResults `json:"results,omitempty"` 473 // PolicyDefinitions - Policy definitions summary. 474 PolicyDefinitions *[]PolicyDefinitionSummary `json:"policyDefinitions,omitempty"` 475 // PolicyGroups - Policy definition group summary. 476 PolicyGroups *[]PolicyGroupSummary `json:"policyGroups,omitempty"` 477} 478 479// PolicyDefinitionSummary policy definition summary. 480type PolicyDefinitionSummary struct { 481 // PolicyDefinitionID - Policy definition ID. 482 PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` 483 // PolicyDefinitionReferenceID - Policy definition reference ID. 484 PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` 485 // PolicyDefinitionGroupNames - Policy definition group names. 486 PolicyDefinitionGroupNames *[]string `json:"policyDefinitionGroupNames,omitempty"` 487 // Effect - Policy effect, i.e. policy definition action. 488 Effect *string `json:"effect,omitempty"` 489 // Results - Compliance summary for the policy definition. 490 Results *SummaryResults `json:"results,omitempty"` 491} 492 493// PolicyDetails the policy details. 494type PolicyDetails struct { 495 // PolicyDefinitionID - READ-ONLY; The ID of the policy definition. 496 PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` 497 // PolicyAssignmentID - READ-ONLY; The ID of the policy assignment. 498 PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` 499 // PolicyAssignmentDisplayName - READ-ONLY; The display name of the policy assignment. 500 PolicyAssignmentDisplayName *string `json:"policyAssignmentDisplayName,omitempty"` 501 // PolicyAssignmentScope - READ-ONLY; The scope of the policy assignment. 502 PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty"` 503 // PolicySetDefinitionID - READ-ONLY; The ID of the policy set definition. 504 PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty"` 505 // PolicyDefinitionReferenceID - READ-ONLY; The policy definition reference ID within the policy set definition. 506 PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` 507} 508 509// PolicyEvaluationDetails policy evaluation details. 510type PolicyEvaluationDetails struct { 511 // EvaluatedExpressions - Details of the evaluated expressions. 512 EvaluatedExpressions *[]ExpressionEvaluationDetails `json:"evaluatedExpressions,omitempty"` 513 // IfNotExistsDetails - Evaluation details of IfNotExists effect. 514 IfNotExistsDetails *IfNotExistsEvaluationDetails `json:"ifNotExistsDetails,omitempty"` 515} 516 517// PolicyEvaluationResult the result of a non-compliant policy evaluation against the given resource 518// content. 519type PolicyEvaluationResult struct { 520 // PolicyInfo - READ-ONLY; The details of the policy that was evaluated. 521 PolicyInfo *PolicyReference `json:"policyInfo,omitempty"` 522 // EvaluationResult - READ-ONLY; The result of the policy evaluation against the resource. This will typically be 'NonCompliant' but may contain other values if errors were encountered. 523 EvaluationResult *string `json:"evaluationResult,omitempty"` 524 // EvaluationDetails - READ-ONLY; The detailed results of the policy expressions and values that were evaluated. 525 EvaluationDetails *PolicyEvaluationDetails `json:"evaluationDetails,omitempty"` 526} 527 528// PolicyEvent policy event record. 529type PolicyEvent struct { 530 // AdditionalProperties - Unmatched properties from the message are deserialized this collection 531 AdditionalProperties map[string]interface{} `json:""` 532 // OdataID - OData entity ID; always set to null since policy event records do not have an entity ID. 533 OdataID *string `json:"@odata.id,omitempty"` 534 // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. 535 OdataContext *string `json:"@odata.context,omitempty"` 536 // Timestamp - Timestamp for the policy event record. 537 Timestamp *date.Time `json:"timestamp,omitempty"` 538 // ResourceID - Resource ID. 539 ResourceID *string `json:"resourceId,omitempty"` 540 // PolicyAssignmentID - Policy assignment ID. 541 PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` 542 // PolicyDefinitionID - Policy definition ID. 543 PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` 544 // EffectiveParameters - Effective parameters for the policy assignment. 545 EffectiveParameters *string `json:"effectiveParameters,omitempty"` 546 // IsCompliant - Flag which states whether the resource is compliant against the policy assignment it was evaluated against. 547 IsCompliant *bool `json:"isCompliant,omitempty"` 548 // SubscriptionID - Subscription ID. 549 SubscriptionID *string `json:"subscriptionId,omitempty"` 550 // ResourceType - Resource type. 551 ResourceType *string `json:"resourceType,omitempty"` 552 // ResourceLocation - Resource location. 553 ResourceLocation *string `json:"resourceLocation,omitempty"` 554 // ResourceGroup - Resource group name. 555 ResourceGroup *string `json:"resourceGroup,omitempty"` 556 // ResourceTags - List of resource tags. 557 ResourceTags *string `json:"resourceTags,omitempty"` 558 // PolicyAssignmentName - Policy assignment name. 559 PolicyAssignmentName *string `json:"policyAssignmentName,omitempty"` 560 // PolicyAssignmentOwner - Policy assignment owner. 561 PolicyAssignmentOwner *string `json:"policyAssignmentOwner,omitempty"` 562 // PolicyAssignmentParameters - Policy assignment parameters. 563 PolicyAssignmentParameters *string `json:"policyAssignmentParameters,omitempty"` 564 // PolicyAssignmentScope - Policy assignment scope. 565 PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty"` 566 // PolicyDefinitionName - Policy definition name. 567 PolicyDefinitionName *string `json:"policyDefinitionName,omitempty"` 568 // PolicyDefinitionAction - Policy definition action, i.e. effect. 569 PolicyDefinitionAction *string `json:"policyDefinitionAction,omitempty"` 570 // PolicyDefinitionCategory - Policy definition category. 571 PolicyDefinitionCategory *string `json:"policyDefinitionCategory,omitempty"` 572 // PolicySetDefinitionID - Policy set definition ID, if the policy assignment is for a policy set. 573 PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty"` 574 // PolicySetDefinitionName - Policy set definition name, if the policy assignment is for a policy set. 575 PolicySetDefinitionName *string `json:"policySetDefinitionName,omitempty"` 576 // PolicySetDefinitionOwner - Policy set definition owner, if the policy assignment is for a policy set. 577 PolicySetDefinitionOwner *string `json:"policySetDefinitionOwner,omitempty"` 578 // PolicySetDefinitionCategory - Policy set definition category, if the policy assignment is for a policy set. 579 PolicySetDefinitionCategory *string `json:"policySetDefinitionCategory,omitempty"` 580 // PolicySetDefinitionParameters - Policy set definition parameters, if the policy assignment is for a policy set. 581 PolicySetDefinitionParameters *string `json:"policySetDefinitionParameters,omitempty"` 582 // ManagementGroupIds - Comma separated list of management group IDs, which represent the hierarchy of the management groups the resource is under. 583 ManagementGroupIds *string `json:"managementGroupIds,omitempty"` 584 // PolicyDefinitionReferenceID - Reference ID for the policy definition inside the policy set, if the policy assignment is for a policy set. 585 PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` 586 // ComplianceState - Compliance state of the resource. 587 ComplianceState *string `json:"complianceState,omitempty"` 588 // TenantID - Tenant ID for the policy event record. 589 TenantID *string `json:"tenantId,omitempty"` 590 // PrincipalOid - Principal object ID for the user who initiated the resource operation that triggered the policy event. 591 PrincipalOid *string `json:"principalOid,omitempty"` 592 // Components - Components events records populated only when URL contains $expand=components clause. 593 Components *[]ComponentEventDetails `json:"components,omitempty"` 594} 595 596// MarshalJSON is the custom marshaler for PolicyEvent. 597func (peVar PolicyEvent) MarshalJSON() ([]byte, error) { 598 objectMap := make(map[string]interface{}) 599 if peVar.OdataID != nil { 600 objectMap["@odata.id"] = peVar.OdataID 601 } 602 if peVar.OdataContext != nil { 603 objectMap["@odata.context"] = peVar.OdataContext 604 } 605 if peVar.Timestamp != nil { 606 objectMap["timestamp"] = peVar.Timestamp 607 } 608 if peVar.ResourceID != nil { 609 objectMap["resourceId"] = peVar.ResourceID 610 } 611 if peVar.PolicyAssignmentID != nil { 612 objectMap["policyAssignmentId"] = peVar.PolicyAssignmentID 613 } 614 if peVar.PolicyDefinitionID != nil { 615 objectMap["policyDefinitionId"] = peVar.PolicyDefinitionID 616 } 617 if peVar.EffectiveParameters != nil { 618 objectMap["effectiveParameters"] = peVar.EffectiveParameters 619 } 620 if peVar.IsCompliant != nil { 621 objectMap["isCompliant"] = peVar.IsCompliant 622 } 623 if peVar.SubscriptionID != nil { 624 objectMap["subscriptionId"] = peVar.SubscriptionID 625 } 626 if peVar.ResourceType != nil { 627 objectMap["resourceType"] = peVar.ResourceType 628 } 629 if peVar.ResourceLocation != nil { 630 objectMap["resourceLocation"] = peVar.ResourceLocation 631 } 632 if peVar.ResourceGroup != nil { 633 objectMap["resourceGroup"] = peVar.ResourceGroup 634 } 635 if peVar.ResourceTags != nil { 636 objectMap["resourceTags"] = peVar.ResourceTags 637 } 638 if peVar.PolicyAssignmentName != nil { 639 objectMap["policyAssignmentName"] = peVar.PolicyAssignmentName 640 } 641 if peVar.PolicyAssignmentOwner != nil { 642 objectMap["policyAssignmentOwner"] = peVar.PolicyAssignmentOwner 643 } 644 if peVar.PolicyAssignmentParameters != nil { 645 objectMap["policyAssignmentParameters"] = peVar.PolicyAssignmentParameters 646 } 647 if peVar.PolicyAssignmentScope != nil { 648 objectMap["policyAssignmentScope"] = peVar.PolicyAssignmentScope 649 } 650 if peVar.PolicyDefinitionName != nil { 651 objectMap["policyDefinitionName"] = peVar.PolicyDefinitionName 652 } 653 if peVar.PolicyDefinitionAction != nil { 654 objectMap["policyDefinitionAction"] = peVar.PolicyDefinitionAction 655 } 656 if peVar.PolicyDefinitionCategory != nil { 657 objectMap["policyDefinitionCategory"] = peVar.PolicyDefinitionCategory 658 } 659 if peVar.PolicySetDefinitionID != nil { 660 objectMap["policySetDefinitionId"] = peVar.PolicySetDefinitionID 661 } 662 if peVar.PolicySetDefinitionName != nil { 663 objectMap["policySetDefinitionName"] = peVar.PolicySetDefinitionName 664 } 665 if peVar.PolicySetDefinitionOwner != nil { 666 objectMap["policySetDefinitionOwner"] = peVar.PolicySetDefinitionOwner 667 } 668 if peVar.PolicySetDefinitionCategory != nil { 669 objectMap["policySetDefinitionCategory"] = peVar.PolicySetDefinitionCategory 670 } 671 if peVar.PolicySetDefinitionParameters != nil { 672 objectMap["policySetDefinitionParameters"] = peVar.PolicySetDefinitionParameters 673 } 674 if peVar.ManagementGroupIds != nil { 675 objectMap["managementGroupIds"] = peVar.ManagementGroupIds 676 } 677 if peVar.PolicyDefinitionReferenceID != nil { 678 objectMap["policyDefinitionReferenceId"] = peVar.PolicyDefinitionReferenceID 679 } 680 if peVar.ComplianceState != nil { 681 objectMap["complianceState"] = peVar.ComplianceState 682 } 683 if peVar.TenantID != nil { 684 objectMap["tenantId"] = peVar.TenantID 685 } 686 if peVar.PrincipalOid != nil { 687 objectMap["principalOid"] = peVar.PrincipalOid 688 } 689 if peVar.Components != nil { 690 objectMap["components"] = peVar.Components 691 } 692 for k, v := range peVar.AdditionalProperties { 693 objectMap[k] = v 694 } 695 return json.Marshal(objectMap) 696} 697 698// UnmarshalJSON is the custom unmarshaler for PolicyEvent struct. 699func (peVar *PolicyEvent) UnmarshalJSON(body []byte) error { 700 var m map[string]*json.RawMessage 701 err := json.Unmarshal(body, &m) 702 if err != nil { 703 return err 704 } 705 for k, v := range m { 706 switch k { 707 default: 708 if v != nil { 709 var additionalProperties interface{} 710 err = json.Unmarshal(*v, &additionalProperties) 711 if err != nil { 712 return err 713 } 714 if peVar.AdditionalProperties == nil { 715 peVar.AdditionalProperties = make(map[string]interface{}) 716 } 717 peVar.AdditionalProperties[k] = additionalProperties 718 } 719 case "@odata.id": 720 if v != nil { 721 var odataID string 722 err = json.Unmarshal(*v, &odataID) 723 if err != nil { 724 return err 725 } 726 peVar.OdataID = &odataID 727 } 728 case "@odata.context": 729 if v != nil { 730 var odataContext string 731 err = json.Unmarshal(*v, &odataContext) 732 if err != nil { 733 return err 734 } 735 peVar.OdataContext = &odataContext 736 } 737 case "timestamp": 738 if v != nil { 739 var timestamp date.Time 740 err = json.Unmarshal(*v, ×tamp) 741 if err != nil { 742 return err 743 } 744 peVar.Timestamp = ×tamp 745 } 746 case "resourceId": 747 if v != nil { 748 var resourceID string 749 err = json.Unmarshal(*v, &resourceID) 750 if err != nil { 751 return err 752 } 753 peVar.ResourceID = &resourceID 754 } 755 case "policyAssignmentId": 756 if v != nil { 757 var policyAssignmentID string 758 err = json.Unmarshal(*v, &policyAssignmentID) 759 if err != nil { 760 return err 761 } 762 peVar.PolicyAssignmentID = &policyAssignmentID 763 } 764 case "policyDefinitionId": 765 if v != nil { 766 var policyDefinitionID string 767 err = json.Unmarshal(*v, &policyDefinitionID) 768 if err != nil { 769 return err 770 } 771 peVar.PolicyDefinitionID = &policyDefinitionID 772 } 773 case "effectiveParameters": 774 if v != nil { 775 var effectiveParameters string 776 err = json.Unmarshal(*v, &effectiveParameters) 777 if err != nil { 778 return err 779 } 780 peVar.EffectiveParameters = &effectiveParameters 781 } 782 case "isCompliant": 783 if v != nil { 784 var isCompliant bool 785 err = json.Unmarshal(*v, &isCompliant) 786 if err != nil { 787 return err 788 } 789 peVar.IsCompliant = &isCompliant 790 } 791 case "subscriptionId": 792 if v != nil { 793 var subscriptionID string 794 err = json.Unmarshal(*v, &subscriptionID) 795 if err != nil { 796 return err 797 } 798 peVar.SubscriptionID = &subscriptionID 799 } 800 case "resourceType": 801 if v != nil { 802 var resourceType string 803 err = json.Unmarshal(*v, &resourceType) 804 if err != nil { 805 return err 806 } 807 peVar.ResourceType = &resourceType 808 } 809 case "resourceLocation": 810 if v != nil { 811 var resourceLocation string 812 err = json.Unmarshal(*v, &resourceLocation) 813 if err != nil { 814 return err 815 } 816 peVar.ResourceLocation = &resourceLocation 817 } 818 case "resourceGroup": 819 if v != nil { 820 var resourceGroup string 821 err = json.Unmarshal(*v, &resourceGroup) 822 if err != nil { 823 return err 824 } 825 peVar.ResourceGroup = &resourceGroup 826 } 827 case "resourceTags": 828 if v != nil { 829 var resourceTags string 830 err = json.Unmarshal(*v, &resourceTags) 831 if err != nil { 832 return err 833 } 834 peVar.ResourceTags = &resourceTags 835 } 836 case "policyAssignmentName": 837 if v != nil { 838 var policyAssignmentName string 839 err = json.Unmarshal(*v, &policyAssignmentName) 840 if err != nil { 841 return err 842 } 843 peVar.PolicyAssignmentName = &policyAssignmentName 844 } 845 case "policyAssignmentOwner": 846 if v != nil { 847 var policyAssignmentOwner string 848 err = json.Unmarshal(*v, &policyAssignmentOwner) 849 if err != nil { 850 return err 851 } 852 peVar.PolicyAssignmentOwner = &policyAssignmentOwner 853 } 854 case "policyAssignmentParameters": 855 if v != nil { 856 var policyAssignmentParameters string 857 err = json.Unmarshal(*v, &policyAssignmentParameters) 858 if err != nil { 859 return err 860 } 861 peVar.PolicyAssignmentParameters = &policyAssignmentParameters 862 } 863 case "policyAssignmentScope": 864 if v != nil { 865 var policyAssignmentScope string 866 err = json.Unmarshal(*v, &policyAssignmentScope) 867 if err != nil { 868 return err 869 } 870 peVar.PolicyAssignmentScope = &policyAssignmentScope 871 } 872 case "policyDefinitionName": 873 if v != nil { 874 var policyDefinitionName string 875 err = json.Unmarshal(*v, &policyDefinitionName) 876 if err != nil { 877 return err 878 } 879 peVar.PolicyDefinitionName = &policyDefinitionName 880 } 881 case "policyDefinitionAction": 882 if v != nil { 883 var policyDefinitionAction string 884 err = json.Unmarshal(*v, &policyDefinitionAction) 885 if err != nil { 886 return err 887 } 888 peVar.PolicyDefinitionAction = &policyDefinitionAction 889 } 890 case "policyDefinitionCategory": 891 if v != nil { 892 var policyDefinitionCategory string 893 err = json.Unmarshal(*v, &policyDefinitionCategory) 894 if err != nil { 895 return err 896 } 897 peVar.PolicyDefinitionCategory = &policyDefinitionCategory 898 } 899 case "policySetDefinitionId": 900 if v != nil { 901 var policySetDefinitionID string 902 err = json.Unmarshal(*v, &policySetDefinitionID) 903 if err != nil { 904 return err 905 } 906 peVar.PolicySetDefinitionID = &policySetDefinitionID 907 } 908 case "policySetDefinitionName": 909 if v != nil { 910 var policySetDefinitionName string 911 err = json.Unmarshal(*v, &policySetDefinitionName) 912 if err != nil { 913 return err 914 } 915 peVar.PolicySetDefinitionName = &policySetDefinitionName 916 } 917 case "policySetDefinitionOwner": 918 if v != nil { 919 var policySetDefinitionOwner string 920 err = json.Unmarshal(*v, &policySetDefinitionOwner) 921 if err != nil { 922 return err 923 } 924 peVar.PolicySetDefinitionOwner = &policySetDefinitionOwner 925 } 926 case "policySetDefinitionCategory": 927 if v != nil { 928 var policySetDefinitionCategory string 929 err = json.Unmarshal(*v, &policySetDefinitionCategory) 930 if err != nil { 931 return err 932 } 933 peVar.PolicySetDefinitionCategory = &policySetDefinitionCategory 934 } 935 case "policySetDefinitionParameters": 936 if v != nil { 937 var policySetDefinitionParameters string 938 err = json.Unmarshal(*v, &policySetDefinitionParameters) 939 if err != nil { 940 return err 941 } 942 peVar.PolicySetDefinitionParameters = &policySetDefinitionParameters 943 } 944 case "managementGroupIds": 945 if v != nil { 946 var managementGroupIds string 947 err = json.Unmarshal(*v, &managementGroupIds) 948 if err != nil { 949 return err 950 } 951 peVar.ManagementGroupIds = &managementGroupIds 952 } 953 case "policyDefinitionReferenceId": 954 if v != nil { 955 var policyDefinitionReferenceID string 956 err = json.Unmarshal(*v, &policyDefinitionReferenceID) 957 if err != nil { 958 return err 959 } 960 peVar.PolicyDefinitionReferenceID = &policyDefinitionReferenceID 961 } 962 case "complianceState": 963 if v != nil { 964 var complianceState string 965 err = json.Unmarshal(*v, &complianceState) 966 if err != nil { 967 return err 968 } 969 peVar.ComplianceState = &complianceState 970 } 971 case "tenantId": 972 if v != nil { 973 var tenantID string 974 err = json.Unmarshal(*v, &tenantID) 975 if err != nil { 976 return err 977 } 978 peVar.TenantID = &tenantID 979 } 980 case "principalOid": 981 if v != nil { 982 var principalOid string 983 err = json.Unmarshal(*v, &principalOid) 984 if err != nil { 985 return err 986 } 987 peVar.PrincipalOid = &principalOid 988 } 989 case "components": 990 if v != nil { 991 var components []ComponentEventDetails 992 err = json.Unmarshal(*v, &components) 993 if err != nil { 994 return err 995 } 996 peVar.Components = &components 997 } 998 } 999 } 1000 1001 return nil 1002} 1003 1004// PolicyEventsQueryResults query results. 1005type PolicyEventsQueryResults struct { 1006 autorest.Response `json:"-"` 1007 // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. 1008 OdataContext *string `json:"@odata.context,omitempty"` 1009 // OdataCount - OData entity count; represents the number of policy event records returned. 1010 OdataCount *int32 `json:"@odata.count,omitempty"` 1011 // OdataNextLink - Odata next link; URL to get the next set of results. 1012 OdataNextLink *string `json:"@odata.nextLink,omitempty"` 1013 // Value - Query results. 1014 Value *[]PolicyEvent `json:"value,omitempty"` 1015} 1016 1017// PolicyEventsQueryResultsIterator provides access to a complete listing of PolicyEvent values. 1018type PolicyEventsQueryResultsIterator struct { 1019 i int 1020 page PolicyEventsQueryResultsPage 1021} 1022 1023// NextWithContext advances to the next value. If there was an error making 1024// the request the iterator does not advance and the error is returned. 1025func (iter *PolicyEventsQueryResultsIterator) NextWithContext(ctx context.Context) (err error) { 1026 if tracing.IsEnabled() { 1027 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsQueryResultsIterator.NextWithContext") 1028 defer func() { 1029 sc := -1 1030 if iter.Response().Response.Response != nil { 1031 sc = iter.Response().Response.Response.StatusCode 1032 } 1033 tracing.EndSpan(ctx, sc, err) 1034 }() 1035 } 1036 iter.i++ 1037 if iter.i < len(iter.page.Values()) { 1038 return nil 1039 } 1040 err = iter.page.NextWithContext(ctx) 1041 if err != nil { 1042 iter.i-- 1043 return err 1044 } 1045 iter.i = 0 1046 return nil 1047} 1048 1049// Next advances to the next value. If there was an error making 1050// the request the iterator does not advance and the error is returned. 1051// Deprecated: Use NextWithContext() instead. 1052func (iter *PolicyEventsQueryResultsIterator) Next() error { 1053 return iter.NextWithContext(context.Background()) 1054} 1055 1056// NotDone returns true if the enumeration should be started or is not yet complete. 1057func (iter PolicyEventsQueryResultsIterator) NotDone() bool { 1058 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1059} 1060 1061// Response returns the raw server response from the last page request. 1062func (iter PolicyEventsQueryResultsIterator) Response() PolicyEventsQueryResults { 1063 return iter.page.Response() 1064} 1065 1066// Value returns the current value or a zero-initialized value if the 1067// iterator has advanced beyond the end of the collection. 1068func (iter PolicyEventsQueryResultsIterator) Value() PolicyEvent { 1069 if !iter.page.NotDone() { 1070 return PolicyEvent{} 1071 } 1072 return iter.page.Values()[iter.i] 1073} 1074 1075// Creates a new instance of the PolicyEventsQueryResultsIterator type. 1076func NewPolicyEventsQueryResultsIterator(page PolicyEventsQueryResultsPage) PolicyEventsQueryResultsIterator { 1077 return PolicyEventsQueryResultsIterator{page: page} 1078} 1079 1080// IsEmpty returns true if the ListResult contains no values. 1081func (peqr PolicyEventsQueryResults) IsEmpty() bool { 1082 return peqr.Value == nil || len(*peqr.Value) == 0 1083} 1084 1085// hasNextLink returns true if the NextLink is not empty. 1086func (peqr PolicyEventsQueryResults) hasNextLink() bool { 1087 return peqr.OdataNextLink != nil && len(*peqr.OdataNextLink) != 0 1088} 1089 1090// policyEventsQueryResultsPreparer prepares a request to retrieve the next set of results. 1091// It returns nil if no more results exist. 1092func (peqr PolicyEventsQueryResults) policyEventsQueryResultsPreparer(ctx context.Context) (*http.Request, error) { 1093 if !peqr.hasNextLink() { 1094 return nil, nil 1095 } 1096 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1097 autorest.AsJSON(), 1098 autorest.AsGet(), 1099 autorest.WithBaseURL(to.String(peqr.OdataNextLink))) 1100} 1101 1102// PolicyEventsQueryResultsPage contains a page of PolicyEvent values. 1103type PolicyEventsQueryResultsPage struct { 1104 fn func(context.Context, PolicyEventsQueryResults) (PolicyEventsQueryResults, error) 1105 peqr PolicyEventsQueryResults 1106} 1107 1108// NextWithContext advances to the next page of values. If there was an error making 1109// the request the page does not advance and the error is returned. 1110func (page *PolicyEventsQueryResultsPage) NextWithContext(ctx context.Context) (err error) { 1111 if tracing.IsEnabled() { 1112 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyEventsQueryResultsPage.NextWithContext") 1113 defer func() { 1114 sc := -1 1115 if page.Response().Response.Response != nil { 1116 sc = page.Response().Response.Response.StatusCode 1117 } 1118 tracing.EndSpan(ctx, sc, err) 1119 }() 1120 } 1121 for { 1122 next, err := page.fn(ctx, page.peqr) 1123 if err != nil { 1124 return err 1125 } 1126 page.peqr = next 1127 if !next.hasNextLink() || !next.IsEmpty() { 1128 break 1129 } 1130 } 1131 return nil 1132} 1133 1134// Next advances to the next page of values. If there was an error making 1135// the request the page does not advance and the error is returned. 1136// Deprecated: Use NextWithContext() instead. 1137func (page *PolicyEventsQueryResultsPage) Next() error { 1138 return page.NextWithContext(context.Background()) 1139} 1140 1141// NotDone returns true if the page enumeration should be started or is not yet complete. 1142func (page PolicyEventsQueryResultsPage) NotDone() bool { 1143 return !page.peqr.IsEmpty() 1144} 1145 1146// Response returns the raw server response from the last page request. 1147func (page PolicyEventsQueryResultsPage) Response() PolicyEventsQueryResults { 1148 return page.peqr 1149} 1150 1151// Values returns the slice of values for the current page or nil if there are no values. 1152func (page PolicyEventsQueryResultsPage) Values() []PolicyEvent { 1153 if page.peqr.IsEmpty() { 1154 return nil 1155 } 1156 return *page.peqr.Value 1157} 1158 1159// Creates a new instance of the PolicyEventsQueryResultsPage type. 1160func NewPolicyEventsQueryResultsPage(cur PolicyEventsQueryResults, getNextPage func(context.Context, PolicyEventsQueryResults) (PolicyEventsQueryResults, error)) PolicyEventsQueryResultsPage { 1161 return PolicyEventsQueryResultsPage{ 1162 fn: getNextPage, 1163 peqr: cur, 1164 } 1165} 1166 1167// PolicyGroupSummary policy definition group summary. 1168type PolicyGroupSummary struct { 1169 // PolicyGroupName - Policy group name. 1170 PolicyGroupName *string `json:"policyGroupName,omitempty"` 1171 // Results - Compliance summary for the policy definition group. 1172 Results *SummaryResults `json:"results,omitempty"` 1173} 1174 1175// PolicyMetadata policy metadata resource definition. 1176type PolicyMetadata struct { 1177 autorest.Response `json:"-"` 1178 // PolicyMetadataProperties - Properties of the policy metadata. 1179 *PolicyMetadataProperties `json:"properties,omitempty"` 1180 // ID - READ-ONLY; The ID of the policy metadata. 1181 ID *string `json:"id,omitempty"` 1182 // Type - READ-ONLY; The type of the policy metadata. 1183 Type *string `json:"type,omitempty"` 1184 // Name - READ-ONLY; The name of the policy metadata. 1185 Name *string `json:"name,omitempty"` 1186} 1187 1188// MarshalJSON is the custom marshaler for PolicyMetadata. 1189func (pm PolicyMetadata) MarshalJSON() ([]byte, error) { 1190 objectMap := make(map[string]interface{}) 1191 if pm.PolicyMetadataProperties != nil { 1192 objectMap["properties"] = pm.PolicyMetadataProperties 1193 } 1194 return json.Marshal(objectMap) 1195} 1196 1197// UnmarshalJSON is the custom unmarshaler for PolicyMetadata struct. 1198func (pm *PolicyMetadata) UnmarshalJSON(body []byte) error { 1199 var m map[string]*json.RawMessage 1200 err := json.Unmarshal(body, &m) 1201 if err != nil { 1202 return err 1203 } 1204 for k, v := range m { 1205 switch k { 1206 case "properties": 1207 if v != nil { 1208 var policyMetadataProperties PolicyMetadataProperties 1209 err = json.Unmarshal(*v, &policyMetadataProperties) 1210 if err != nil { 1211 return err 1212 } 1213 pm.PolicyMetadataProperties = &policyMetadataProperties 1214 } 1215 case "id": 1216 if v != nil { 1217 var ID string 1218 err = json.Unmarshal(*v, &ID) 1219 if err != nil { 1220 return err 1221 } 1222 pm.ID = &ID 1223 } 1224 case "type": 1225 if v != nil { 1226 var typeVar string 1227 err = json.Unmarshal(*v, &typeVar) 1228 if err != nil { 1229 return err 1230 } 1231 pm.Type = &typeVar 1232 } 1233 case "name": 1234 if v != nil { 1235 var name string 1236 err = json.Unmarshal(*v, &name) 1237 if err != nil { 1238 return err 1239 } 1240 pm.Name = &name 1241 } 1242 } 1243 } 1244 1245 return nil 1246} 1247 1248// PolicyMetadataCollection collection of policy metadata resources. 1249type PolicyMetadataCollection struct { 1250 autorest.Response `json:"-"` 1251 // Value - READ-ONLY; Array of policy metadata definitions. 1252 Value *[]SlimPolicyMetadata `json:"value,omitempty"` 1253 // NextLink - READ-ONLY; The URL to get the next set of results. 1254 NextLink *string `json:"nextLink,omitempty"` 1255} 1256 1257// PolicyMetadataCollectionIterator provides access to a complete listing of SlimPolicyMetadata values. 1258type PolicyMetadataCollectionIterator struct { 1259 i int 1260 page PolicyMetadataCollectionPage 1261} 1262 1263// NextWithContext advances to the next value. If there was an error making 1264// the request the iterator does not advance and the error is returned. 1265func (iter *PolicyMetadataCollectionIterator) NextWithContext(ctx context.Context) (err error) { 1266 if tracing.IsEnabled() { 1267 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyMetadataCollectionIterator.NextWithContext") 1268 defer func() { 1269 sc := -1 1270 if iter.Response().Response.Response != nil { 1271 sc = iter.Response().Response.Response.StatusCode 1272 } 1273 tracing.EndSpan(ctx, sc, err) 1274 }() 1275 } 1276 iter.i++ 1277 if iter.i < len(iter.page.Values()) { 1278 return nil 1279 } 1280 err = iter.page.NextWithContext(ctx) 1281 if err != nil { 1282 iter.i-- 1283 return err 1284 } 1285 iter.i = 0 1286 return nil 1287} 1288 1289// Next advances to the next value. If there was an error making 1290// the request the iterator does not advance and the error is returned. 1291// Deprecated: Use NextWithContext() instead. 1292func (iter *PolicyMetadataCollectionIterator) Next() error { 1293 return iter.NextWithContext(context.Background()) 1294} 1295 1296// NotDone returns true if the enumeration should be started or is not yet complete. 1297func (iter PolicyMetadataCollectionIterator) NotDone() bool { 1298 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1299} 1300 1301// Response returns the raw server response from the last page request. 1302func (iter PolicyMetadataCollectionIterator) Response() PolicyMetadataCollection { 1303 return iter.page.Response() 1304} 1305 1306// Value returns the current value or a zero-initialized value if the 1307// iterator has advanced beyond the end of the collection. 1308func (iter PolicyMetadataCollectionIterator) Value() SlimPolicyMetadata { 1309 if !iter.page.NotDone() { 1310 return SlimPolicyMetadata{} 1311 } 1312 return iter.page.Values()[iter.i] 1313} 1314 1315// Creates a new instance of the PolicyMetadataCollectionIterator type. 1316func NewPolicyMetadataCollectionIterator(page PolicyMetadataCollectionPage) PolicyMetadataCollectionIterator { 1317 return PolicyMetadataCollectionIterator{page: page} 1318} 1319 1320// IsEmpty returns true if the ListResult contains no values. 1321func (pmc PolicyMetadataCollection) IsEmpty() bool { 1322 return pmc.Value == nil || len(*pmc.Value) == 0 1323} 1324 1325// hasNextLink returns true if the NextLink is not empty. 1326func (pmc PolicyMetadataCollection) hasNextLink() bool { 1327 return pmc.NextLink != nil && len(*pmc.NextLink) != 0 1328} 1329 1330// policyMetadataCollectionPreparer prepares a request to retrieve the next set of results. 1331// It returns nil if no more results exist. 1332func (pmc PolicyMetadataCollection) policyMetadataCollectionPreparer(ctx context.Context) (*http.Request, error) { 1333 if !pmc.hasNextLink() { 1334 return nil, nil 1335 } 1336 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1337 autorest.AsJSON(), 1338 autorest.AsGet(), 1339 autorest.WithBaseURL(to.String(pmc.NextLink))) 1340} 1341 1342// PolicyMetadataCollectionPage contains a page of SlimPolicyMetadata values. 1343type PolicyMetadataCollectionPage struct { 1344 fn func(context.Context, PolicyMetadataCollection) (PolicyMetadataCollection, error) 1345 pmc PolicyMetadataCollection 1346} 1347 1348// NextWithContext advances to the next page of values. If there was an error making 1349// the request the page does not advance and the error is returned. 1350func (page *PolicyMetadataCollectionPage) NextWithContext(ctx context.Context) (err error) { 1351 if tracing.IsEnabled() { 1352 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyMetadataCollectionPage.NextWithContext") 1353 defer func() { 1354 sc := -1 1355 if page.Response().Response.Response != nil { 1356 sc = page.Response().Response.Response.StatusCode 1357 } 1358 tracing.EndSpan(ctx, sc, err) 1359 }() 1360 } 1361 for { 1362 next, err := page.fn(ctx, page.pmc) 1363 if err != nil { 1364 return err 1365 } 1366 page.pmc = next 1367 if !next.hasNextLink() || !next.IsEmpty() { 1368 break 1369 } 1370 } 1371 return nil 1372} 1373 1374// Next advances to the next page of values. If there was an error making 1375// the request the page does not advance and the error is returned. 1376// Deprecated: Use NextWithContext() instead. 1377func (page *PolicyMetadataCollectionPage) Next() error { 1378 return page.NextWithContext(context.Background()) 1379} 1380 1381// NotDone returns true if the page enumeration should be started or is not yet complete. 1382func (page PolicyMetadataCollectionPage) NotDone() bool { 1383 return !page.pmc.IsEmpty() 1384} 1385 1386// Response returns the raw server response from the last page request. 1387func (page PolicyMetadataCollectionPage) Response() PolicyMetadataCollection { 1388 return page.pmc 1389} 1390 1391// Values returns the slice of values for the current page or nil if there are no values. 1392func (page PolicyMetadataCollectionPage) Values() []SlimPolicyMetadata { 1393 if page.pmc.IsEmpty() { 1394 return nil 1395 } 1396 return *page.pmc.Value 1397} 1398 1399// Creates a new instance of the PolicyMetadataCollectionPage type. 1400func NewPolicyMetadataCollectionPage(cur PolicyMetadataCollection, getNextPage func(context.Context, PolicyMetadataCollection) (PolicyMetadataCollection, error)) PolicyMetadataCollectionPage { 1401 return PolicyMetadataCollectionPage{ 1402 fn: getNextPage, 1403 pmc: cur, 1404 } 1405} 1406 1407// PolicyMetadataProperties the properties of the policy metadata. 1408type PolicyMetadataProperties struct { 1409 // Description - READ-ONLY; The description of the policy metadata. 1410 Description *string `json:"description,omitempty"` 1411 // Requirements - READ-ONLY; The requirements of the policy metadata. 1412 Requirements *string `json:"requirements,omitempty"` 1413 // MetadataID - READ-ONLY; The policy metadata identifier. 1414 MetadataID *string `json:"metadataId,omitempty"` 1415 // Category - READ-ONLY; The category of the policy metadata. 1416 Category *string `json:"category,omitempty"` 1417 // Title - READ-ONLY; The title of the policy metadata. 1418 Title *string `json:"title,omitempty"` 1419 // Owner - READ-ONLY; The owner of the policy metadata. 1420 Owner *string `json:"owner,omitempty"` 1421 // AdditionalContentURL - READ-ONLY; Url for getting additional content about the resource metadata. 1422 AdditionalContentURL *string `json:"additionalContentUrl,omitempty"` 1423 // Metadata - READ-ONLY; Additional metadata. 1424 Metadata interface{} `json:"metadata,omitempty"` 1425} 1426 1427// PolicyMetadataSlimProperties the properties of the policy metadata, excluding properties containing 1428// large strings 1429type PolicyMetadataSlimProperties struct { 1430 // MetadataID - READ-ONLY; The policy metadata identifier. 1431 MetadataID *string `json:"metadataId,omitempty"` 1432 // Category - READ-ONLY; The category of the policy metadata. 1433 Category *string `json:"category,omitempty"` 1434 // Title - READ-ONLY; The title of the policy metadata. 1435 Title *string `json:"title,omitempty"` 1436 // Owner - READ-ONLY; The owner of the policy metadata. 1437 Owner *string `json:"owner,omitempty"` 1438 // AdditionalContentURL - READ-ONLY; Url for getting additional content about the resource metadata. 1439 AdditionalContentURL *string `json:"additionalContentUrl,omitempty"` 1440 // Metadata - READ-ONLY; Additional metadata. 1441 Metadata interface{} `json:"metadata,omitempty"` 1442} 1443 1444// PolicyReference resource identifiers for a policy. 1445type PolicyReference struct { 1446 // PolicyDefinitionID - READ-ONLY; The resource identifier of the policy definition. 1447 PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` 1448 // PolicySetDefinitionID - READ-ONLY; The resource identifier of the policy set definition. 1449 PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty"` 1450 // PolicyDefinitionReferenceID - READ-ONLY; The reference identifier of a specific policy definition within a policy set definition. 1451 PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` 1452 // PolicyAssignmentID - READ-ONLY; The resource identifier of the policy assignment. 1453 PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` 1454} 1455 1456// PolicyState policy state record. 1457type PolicyState struct { 1458 // AdditionalProperties - Unmatched properties from the message are deserialized this collection 1459 AdditionalProperties map[string]interface{} `json:""` 1460 // OdataID - OData entity ID; always set to null since policy state records do not have an entity ID. 1461 OdataID *string `json:"@odata.id,omitempty"` 1462 // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. 1463 OdataContext *string `json:"@odata.context,omitempty"` 1464 // Timestamp - Timestamp for the policy state record. 1465 Timestamp *date.Time `json:"timestamp,omitempty"` 1466 // ResourceID - Resource ID. 1467 ResourceID *string `json:"resourceId,omitempty"` 1468 // PolicyAssignmentID - Policy assignment ID. 1469 PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` 1470 // PolicyDefinitionID - Policy definition ID. 1471 PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` 1472 // EffectiveParameters - Effective parameters for the policy assignment. 1473 EffectiveParameters *string `json:"effectiveParameters,omitempty"` 1474 // IsCompliant - Flag which states whether the resource is compliant against the policy assignment it was evaluated against. This property is deprecated; please use ComplianceState instead. 1475 IsCompliant *bool `json:"isCompliant,omitempty"` 1476 // SubscriptionID - Subscription ID. 1477 SubscriptionID *string `json:"subscriptionId,omitempty"` 1478 // ResourceType - Resource type. 1479 ResourceType *string `json:"resourceType,omitempty"` 1480 // ResourceLocation - Resource location. 1481 ResourceLocation *string `json:"resourceLocation,omitempty"` 1482 // ResourceGroup - Resource group name. 1483 ResourceGroup *string `json:"resourceGroup,omitempty"` 1484 // ResourceTags - List of resource tags. 1485 ResourceTags *string `json:"resourceTags,omitempty"` 1486 // PolicyAssignmentName - Policy assignment name. 1487 PolicyAssignmentName *string `json:"policyAssignmentName,omitempty"` 1488 // PolicyAssignmentOwner - Policy assignment owner. 1489 PolicyAssignmentOwner *string `json:"policyAssignmentOwner,omitempty"` 1490 // PolicyAssignmentParameters - Policy assignment parameters. 1491 PolicyAssignmentParameters *string `json:"policyAssignmentParameters,omitempty"` 1492 // PolicyAssignmentScope - Policy assignment scope. 1493 PolicyAssignmentScope *string `json:"policyAssignmentScope,omitempty"` 1494 // PolicyDefinitionName - Policy definition name. 1495 PolicyDefinitionName *string `json:"policyDefinitionName,omitempty"` 1496 // PolicyDefinitionAction - Policy definition action, i.e. effect. 1497 PolicyDefinitionAction *string `json:"policyDefinitionAction,omitempty"` 1498 // PolicyDefinitionCategory - Policy definition category. 1499 PolicyDefinitionCategory *string `json:"policyDefinitionCategory,omitempty"` 1500 // PolicySetDefinitionID - Policy set definition ID, if the policy assignment is for a policy set. 1501 PolicySetDefinitionID *string `json:"policySetDefinitionId,omitempty"` 1502 // PolicySetDefinitionName - Policy set definition name, if the policy assignment is for a policy set. 1503 PolicySetDefinitionName *string `json:"policySetDefinitionName,omitempty"` 1504 // PolicySetDefinitionOwner - Policy set definition owner, if the policy assignment is for a policy set. 1505 PolicySetDefinitionOwner *string `json:"policySetDefinitionOwner,omitempty"` 1506 // PolicySetDefinitionCategory - Policy set definition category, if the policy assignment is for a policy set. 1507 PolicySetDefinitionCategory *string `json:"policySetDefinitionCategory,omitempty"` 1508 // PolicySetDefinitionParameters - Policy set definition parameters, if the policy assignment is for a policy set. 1509 PolicySetDefinitionParameters *string `json:"policySetDefinitionParameters,omitempty"` 1510 // ManagementGroupIds - Comma separated list of management group IDs, which represent the hierarchy of the management groups the resource is under. 1511 ManagementGroupIds *string `json:"managementGroupIds,omitempty"` 1512 // PolicyDefinitionReferenceID - Reference ID for the policy definition inside the policy set, if the policy assignment is for a policy set. 1513 PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` 1514 // ComplianceState - Compliance state of the resource. 1515 ComplianceState *string `json:"complianceState,omitempty"` 1516 // PolicyEvaluationDetails - Policy evaluation details. 1517 PolicyEvaluationDetails *PolicyEvaluationDetails `json:"policyEvaluationDetails,omitempty"` 1518 // PolicyDefinitionGroupNames - Policy definition group names. 1519 PolicyDefinitionGroupNames *[]string `json:"policyDefinitionGroupNames,omitempty"` 1520 // Components - Components state compliance records populated only when URL contains $expand=components clause. 1521 Components *[]ComponentStateDetails `json:"components,omitempty"` 1522 // PolicyDefinitionVersion - READ-ONLY; Evaluated policy definition version. 1523 PolicyDefinitionVersion *string `json:"policyDefinitionVersion,omitempty"` 1524 // PolicySetDefinitionVersion - READ-ONLY; Evaluated policy set definition version. 1525 PolicySetDefinitionVersion *string `json:"policySetDefinitionVersion,omitempty"` 1526 // PolicyAssignmentVersion - READ-ONLY; Evaluated policy assignment version. 1527 PolicyAssignmentVersion *string `json:"policyAssignmentVersion,omitempty"` 1528} 1529 1530// MarshalJSON is the custom marshaler for PolicyState. 1531func (ps PolicyState) MarshalJSON() ([]byte, error) { 1532 objectMap := make(map[string]interface{}) 1533 if ps.OdataID != nil { 1534 objectMap["@odata.id"] = ps.OdataID 1535 } 1536 if ps.OdataContext != nil { 1537 objectMap["@odata.context"] = ps.OdataContext 1538 } 1539 if ps.Timestamp != nil { 1540 objectMap["timestamp"] = ps.Timestamp 1541 } 1542 if ps.ResourceID != nil { 1543 objectMap["resourceId"] = ps.ResourceID 1544 } 1545 if ps.PolicyAssignmentID != nil { 1546 objectMap["policyAssignmentId"] = ps.PolicyAssignmentID 1547 } 1548 if ps.PolicyDefinitionID != nil { 1549 objectMap["policyDefinitionId"] = ps.PolicyDefinitionID 1550 } 1551 if ps.EffectiveParameters != nil { 1552 objectMap["effectiveParameters"] = ps.EffectiveParameters 1553 } 1554 if ps.IsCompliant != nil { 1555 objectMap["isCompliant"] = ps.IsCompliant 1556 } 1557 if ps.SubscriptionID != nil { 1558 objectMap["subscriptionId"] = ps.SubscriptionID 1559 } 1560 if ps.ResourceType != nil { 1561 objectMap["resourceType"] = ps.ResourceType 1562 } 1563 if ps.ResourceLocation != nil { 1564 objectMap["resourceLocation"] = ps.ResourceLocation 1565 } 1566 if ps.ResourceGroup != nil { 1567 objectMap["resourceGroup"] = ps.ResourceGroup 1568 } 1569 if ps.ResourceTags != nil { 1570 objectMap["resourceTags"] = ps.ResourceTags 1571 } 1572 if ps.PolicyAssignmentName != nil { 1573 objectMap["policyAssignmentName"] = ps.PolicyAssignmentName 1574 } 1575 if ps.PolicyAssignmentOwner != nil { 1576 objectMap["policyAssignmentOwner"] = ps.PolicyAssignmentOwner 1577 } 1578 if ps.PolicyAssignmentParameters != nil { 1579 objectMap["policyAssignmentParameters"] = ps.PolicyAssignmentParameters 1580 } 1581 if ps.PolicyAssignmentScope != nil { 1582 objectMap["policyAssignmentScope"] = ps.PolicyAssignmentScope 1583 } 1584 if ps.PolicyDefinitionName != nil { 1585 objectMap["policyDefinitionName"] = ps.PolicyDefinitionName 1586 } 1587 if ps.PolicyDefinitionAction != nil { 1588 objectMap["policyDefinitionAction"] = ps.PolicyDefinitionAction 1589 } 1590 if ps.PolicyDefinitionCategory != nil { 1591 objectMap["policyDefinitionCategory"] = ps.PolicyDefinitionCategory 1592 } 1593 if ps.PolicySetDefinitionID != nil { 1594 objectMap["policySetDefinitionId"] = ps.PolicySetDefinitionID 1595 } 1596 if ps.PolicySetDefinitionName != nil { 1597 objectMap["policySetDefinitionName"] = ps.PolicySetDefinitionName 1598 } 1599 if ps.PolicySetDefinitionOwner != nil { 1600 objectMap["policySetDefinitionOwner"] = ps.PolicySetDefinitionOwner 1601 } 1602 if ps.PolicySetDefinitionCategory != nil { 1603 objectMap["policySetDefinitionCategory"] = ps.PolicySetDefinitionCategory 1604 } 1605 if ps.PolicySetDefinitionParameters != nil { 1606 objectMap["policySetDefinitionParameters"] = ps.PolicySetDefinitionParameters 1607 } 1608 if ps.ManagementGroupIds != nil { 1609 objectMap["managementGroupIds"] = ps.ManagementGroupIds 1610 } 1611 if ps.PolicyDefinitionReferenceID != nil { 1612 objectMap["policyDefinitionReferenceId"] = ps.PolicyDefinitionReferenceID 1613 } 1614 if ps.ComplianceState != nil { 1615 objectMap["complianceState"] = ps.ComplianceState 1616 } 1617 if ps.PolicyEvaluationDetails != nil { 1618 objectMap["policyEvaluationDetails"] = ps.PolicyEvaluationDetails 1619 } 1620 if ps.PolicyDefinitionGroupNames != nil { 1621 objectMap["policyDefinitionGroupNames"] = ps.PolicyDefinitionGroupNames 1622 } 1623 if ps.Components != nil { 1624 objectMap["components"] = ps.Components 1625 } 1626 for k, v := range ps.AdditionalProperties { 1627 objectMap[k] = v 1628 } 1629 return json.Marshal(objectMap) 1630} 1631 1632// UnmarshalJSON is the custom unmarshaler for PolicyState struct. 1633func (ps *PolicyState) UnmarshalJSON(body []byte) error { 1634 var m map[string]*json.RawMessage 1635 err := json.Unmarshal(body, &m) 1636 if err != nil { 1637 return err 1638 } 1639 for k, v := range m { 1640 switch k { 1641 default: 1642 if v != nil { 1643 var additionalProperties interface{} 1644 err = json.Unmarshal(*v, &additionalProperties) 1645 if err != nil { 1646 return err 1647 } 1648 if ps.AdditionalProperties == nil { 1649 ps.AdditionalProperties = make(map[string]interface{}) 1650 } 1651 ps.AdditionalProperties[k] = additionalProperties 1652 } 1653 case "@odata.id": 1654 if v != nil { 1655 var odataID string 1656 err = json.Unmarshal(*v, &odataID) 1657 if err != nil { 1658 return err 1659 } 1660 ps.OdataID = &odataID 1661 } 1662 case "@odata.context": 1663 if v != nil { 1664 var odataContext string 1665 err = json.Unmarshal(*v, &odataContext) 1666 if err != nil { 1667 return err 1668 } 1669 ps.OdataContext = &odataContext 1670 } 1671 case "timestamp": 1672 if v != nil { 1673 var timestamp date.Time 1674 err = json.Unmarshal(*v, ×tamp) 1675 if err != nil { 1676 return err 1677 } 1678 ps.Timestamp = ×tamp 1679 } 1680 case "resourceId": 1681 if v != nil { 1682 var resourceID string 1683 err = json.Unmarshal(*v, &resourceID) 1684 if err != nil { 1685 return err 1686 } 1687 ps.ResourceID = &resourceID 1688 } 1689 case "policyAssignmentId": 1690 if v != nil { 1691 var policyAssignmentID string 1692 err = json.Unmarshal(*v, &policyAssignmentID) 1693 if err != nil { 1694 return err 1695 } 1696 ps.PolicyAssignmentID = &policyAssignmentID 1697 } 1698 case "policyDefinitionId": 1699 if v != nil { 1700 var policyDefinitionID string 1701 err = json.Unmarshal(*v, &policyDefinitionID) 1702 if err != nil { 1703 return err 1704 } 1705 ps.PolicyDefinitionID = &policyDefinitionID 1706 } 1707 case "effectiveParameters": 1708 if v != nil { 1709 var effectiveParameters string 1710 err = json.Unmarshal(*v, &effectiveParameters) 1711 if err != nil { 1712 return err 1713 } 1714 ps.EffectiveParameters = &effectiveParameters 1715 } 1716 case "isCompliant": 1717 if v != nil { 1718 var isCompliant bool 1719 err = json.Unmarshal(*v, &isCompliant) 1720 if err != nil { 1721 return err 1722 } 1723 ps.IsCompliant = &isCompliant 1724 } 1725 case "subscriptionId": 1726 if v != nil { 1727 var subscriptionID string 1728 err = json.Unmarshal(*v, &subscriptionID) 1729 if err != nil { 1730 return err 1731 } 1732 ps.SubscriptionID = &subscriptionID 1733 } 1734 case "resourceType": 1735 if v != nil { 1736 var resourceType string 1737 err = json.Unmarshal(*v, &resourceType) 1738 if err != nil { 1739 return err 1740 } 1741 ps.ResourceType = &resourceType 1742 } 1743 case "resourceLocation": 1744 if v != nil { 1745 var resourceLocation string 1746 err = json.Unmarshal(*v, &resourceLocation) 1747 if err != nil { 1748 return err 1749 } 1750 ps.ResourceLocation = &resourceLocation 1751 } 1752 case "resourceGroup": 1753 if v != nil { 1754 var resourceGroup string 1755 err = json.Unmarshal(*v, &resourceGroup) 1756 if err != nil { 1757 return err 1758 } 1759 ps.ResourceGroup = &resourceGroup 1760 } 1761 case "resourceTags": 1762 if v != nil { 1763 var resourceTags string 1764 err = json.Unmarshal(*v, &resourceTags) 1765 if err != nil { 1766 return err 1767 } 1768 ps.ResourceTags = &resourceTags 1769 } 1770 case "policyAssignmentName": 1771 if v != nil { 1772 var policyAssignmentName string 1773 err = json.Unmarshal(*v, &policyAssignmentName) 1774 if err != nil { 1775 return err 1776 } 1777 ps.PolicyAssignmentName = &policyAssignmentName 1778 } 1779 case "policyAssignmentOwner": 1780 if v != nil { 1781 var policyAssignmentOwner string 1782 err = json.Unmarshal(*v, &policyAssignmentOwner) 1783 if err != nil { 1784 return err 1785 } 1786 ps.PolicyAssignmentOwner = &policyAssignmentOwner 1787 } 1788 case "policyAssignmentParameters": 1789 if v != nil { 1790 var policyAssignmentParameters string 1791 err = json.Unmarshal(*v, &policyAssignmentParameters) 1792 if err != nil { 1793 return err 1794 } 1795 ps.PolicyAssignmentParameters = &policyAssignmentParameters 1796 } 1797 case "policyAssignmentScope": 1798 if v != nil { 1799 var policyAssignmentScope string 1800 err = json.Unmarshal(*v, &policyAssignmentScope) 1801 if err != nil { 1802 return err 1803 } 1804 ps.PolicyAssignmentScope = &policyAssignmentScope 1805 } 1806 case "policyDefinitionName": 1807 if v != nil { 1808 var policyDefinitionName string 1809 err = json.Unmarshal(*v, &policyDefinitionName) 1810 if err != nil { 1811 return err 1812 } 1813 ps.PolicyDefinitionName = &policyDefinitionName 1814 } 1815 case "policyDefinitionAction": 1816 if v != nil { 1817 var policyDefinitionAction string 1818 err = json.Unmarshal(*v, &policyDefinitionAction) 1819 if err != nil { 1820 return err 1821 } 1822 ps.PolicyDefinitionAction = &policyDefinitionAction 1823 } 1824 case "policyDefinitionCategory": 1825 if v != nil { 1826 var policyDefinitionCategory string 1827 err = json.Unmarshal(*v, &policyDefinitionCategory) 1828 if err != nil { 1829 return err 1830 } 1831 ps.PolicyDefinitionCategory = &policyDefinitionCategory 1832 } 1833 case "policySetDefinitionId": 1834 if v != nil { 1835 var policySetDefinitionID string 1836 err = json.Unmarshal(*v, &policySetDefinitionID) 1837 if err != nil { 1838 return err 1839 } 1840 ps.PolicySetDefinitionID = &policySetDefinitionID 1841 } 1842 case "policySetDefinitionName": 1843 if v != nil { 1844 var policySetDefinitionName string 1845 err = json.Unmarshal(*v, &policySetDefinitionName) 1846 if err != nil { 1847 return err 1848 } 1849 ps.PolicySetDefinitionName = &policySetDefinitionName 1850 } 1851 case "policySetDefinitionOwner": 1852 if v != nil { 1853 var policySetDefinitionOwner string 1854 err = json.Unmarshal(*v, &policySetDefinitionOwner) 1855 if err != nil { 1856 return err 1857 } 1858 ps.PolicySetDefinitionOwner = &policySetDefinitionOwner 1859 } 1860 case "policySetDefinitionCategory": 1861 if v != nil { 1862 var policySetDefinitionCategory string 1863 err = json.Unmarshal(*v, &policySetDefinitionCategory) 1864 if err != nil { 1865 return err 1866 } 1867 ps.PolicySetDefinitionCategory = &policySetDefinitionCategory 1868 } 1869 case "policySetDefinitionParameters": 1870 if v != nil { 1871 var policySetDefinitionParameters string 1872 err = json.Unmarshal(*v, &policySetDefinitionParameters) 1873 if err != nil { 1874 return err 1875 } 1876 ps.PolicySetDefinitionParameters = &policySetDefinitionParameters 1877 } 1878 case "managementGroupIds": 1879 if v != nil { 1880 var managementGroupIds string 1881 err = json.Unmarshal(*v, &managementGroupIds) 1882 if err != nil { 1883 return err 1884 } 1885 ps.ManagementGroupIds = &managementGroupIds 1886 } 1887 case "policyDefinitionReferenceId": 1888 if v != nil { 1889 var policyDefinitionReferenceID string 1890 err = json.Unmarshal(*v, &policyDefinitionReferenceID) 1891 if err != nil { 1892 return err 1893 } 1894 ps.PolicyDefinitionReferenceID = &policyDefinitionReferenceID 1895 } 1896 case "complianceState": 1897 if v != nil { 1898 var complianceState string 1899 err = json.Unmarshal(*v, &complianceState) 1900 if err != nil { 1901 return err 1902 } 1903 ps.ComplianceState = &complianceState 1904 } 1905 case "policyEvaluationDetails": 1906 if v != nil { 1907 var policyEvaluationDetails PolicyEvaluationDetails 1908 err = json.Unmarshal(*v, &policyEvaluationDetails) 1909 if err != nil { 1910 return err 1911 } 1912 ps.PolicyEvaluationDetails = &policyEvaluationDetails 1913 } 1914 case "policyDefinitionGroupNames": 1915 if v != nil { 1916 var policyDefinitionGroupNames []string 1917 err = json.Unmarshal(*v, &policyDefinitionGroupNames) 1918 if err != nil { 1919 return err 1920 } 1921 ps.PolicyDefinitionGroupNames = &policyDefinitionGroupNames 1922 } 1923 case "components": 1924 if v != nil { 1925 var components []ComponentStateDetails 1926 err = json.Unmarshal(*v, &components) 1927 if err != nil { 1928 return err 1929 } 1930 ps.Components = &components 1931 } 1932 case "policyDefinitionVersion": 1933 if v != nil { 1934 var policyDefinitionVersion string 1935 err = json.Unmarshal(*v, &policyDefinitionVersion) 1936 if err != nil { 1937 return err 1938 } 1939 ps.PolicyDefinitionVersion = &policyDefinitionVersion 1940 } 1941 case "policySetDefinitionVersion": 1942 if v != nil { 1943 var policySetDefinitionVersion string 1944 err = json.Unmarshal(*v, &policySetDefinitionVersion) 1945 if err != nil { 1946 return err 1947 } 1948 ps.PolicySetDefinitionVersion = &policySetDefinitionVersion 1949 } 1950 case "policyAssignmentVersion": 1951 if v != nil { 1952 var policyAssignmentVersion string 1953 err = json.Unmarshal(*v, &policyAssignmentVersion) 1954 if err != nil { 1955 return err 1956 } 1957 ps.PolicyAssignmentVersion = &policyAssignmentVersion 1958 } 1959 } 1960 } 1961 1962 return nil 1963} 1964 1965// PolicyStatesQueryResults query results. 1966type PolicyStatesQueryResults 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 policy state records returned. 1971 OdataCount *int32 `json:"@odata.count,omitempty"` 1972 // OdataNextLink - Odata next link; URL to get the next set of results. 1973 OdataNextLink *string `json:"@odata.nextLink,omitempty"` 1974 // Value - Query results. 1975 Value *[]PolicyState `json:"value,omitempty"` 1976} 1977 1978// PolicyStatesQueryResultsIterator provides access to a complete listing of PolicyState values. 1979type PolicyStatesQueryResultsIterator struct { 1980 i int 1981 page PolicyStatesQueryResultsPage 1982} 1983 1984// NextWithContext advances to the next value. If there was an error making 1985// the request the iterator does not advance and the error is returned. 1986func (iter *PolicyStatesQueryResultsIterator) NextWithContext(ctx context.Context) (err error) { 1987 if tracing.IsEnabled() { 1988 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesQueryResultsIterator.NextWithContext") 1989 defer func() { 1990 sc := -1 1991 if iter.Response().Response.Response != nil { 1992 sc = iter.Response().Response.Response.StatusCode 1993 } 1994 tracing.EndSpan(ctx, sc, err) 1995 }() 1996 } 1997 iter.i++ 1998 if iter.i < len(iter.page.Values()) { 1999 return nil 2000 } 2001 err = iter.page.NextWithContext(ctx) 2002 if err != nil { 2003 iter.i-- 2004 return err 2005 } 2006 iter.i = 0 2007 return nil 2008} 2009 2010// Next advances to the next value. If there was an error making 2011// the request the iterator does not advance and the error is returned. 2012// Deprecated: Use NextWithContext() instead. 2013func (iter *PolicyStatesQueryResultsIterator) Next() error { 2014 return iter.NextWithContext(context.Background()) 2015} 2016 2017// NotDone returns true if the enumeration should be started or is not yet complete. 2018func (iter PolicyStatesQueryResultsIterator) NotDone() bool { 2019 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 2020} 2021 2022// Response returns the raw server response from the last page request. 2023func (iter PolicyStatesQueryResultsIterator) Response() PolicyStatesQueryResults { 2024 return iter.page.Response() 2025} 2026 2027// Value returns the current value or a zero-initialized value if the 2028// iterator has advanced beyond the end of the collection. 2029func (iter PolicyStatesQueryResultsIterator) Value() PolicyState { 2030 if !iter.page.NotDone() { 2031 return PolicyState{} 2032 } 2033 return iter.page.Values()[iter.i] 2034} 2035 2036// Creates a new instance of the PolicyStatesQueryResultsIterator type. 2037func NewPolicyStatesQueryResultsIterator(page PolicyStatesQueryResultsPage) PolicyStatesQueryResultsIterator { 2038 return PolicyStatesQueryResultsIterator{page: page} 2039} 2040 2041// IsEmpty returns true if the ListResult contains no values. 2042func (psqr PolicyStatesQueryResults) IsEmpty() bool { 2043 return psqr.Value == nil || len(*psqr.Value) == 0 2044} 2045 2046// hasNextLink returns true if the NextLink is not empty. 2047func (psqr PolicyStatesQueryResults) hasNextLink() bool { 2048 return psqr.OdataNextLink != nil && len(*psqr.OdataNextLink) != 0 2049} 2050 2051// policyStatesQueryResultsPreparer prepares a request to retrieve the next set of results. 2052// It returns nil if no more results exist. 2053func (psqr PolicyStatesQueryResults) policyStatesQueryResultsPreparer(ctx context.Context) (*http.Request, error) { 2054 if !psqr.hasNextLink() { 2055 return nil, nil 2056 } 2057 return autorest.Prepare((&http.Request{}).WithContext(ctx), 2058 autorest.AsJSON(), 2059 autorest.AsGet(), 2060 autorest.WithBaseURL(to.String(psqr.OdataNextLink))) 2061} 2062 2063// PolicyStatesQueryResultsPage contains a page of PolicyState values. 2064type PolicyStatesQueryResultsPage struct { 2065 fn func(context.Context, PolicyStatesQueryResults) (PolicyStatesQueryResults, error) 2066 psqr PolicyStatesQueryResults 2067} 2068 2069// NextWithContext advances to the next page of values. If there was an error making 2070// the request the page does not advance and the error is returned. 2071func (page *PolicyStatesQueryResultsPage) NextWithContext(ctx context.Context) (err error) { 2072 if tracing.IsEnabled() { 2073 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesQueryResultsPage.NextWithContext") 2074 defer func() { 2075 sc := -1 2076 if page.Response().Response.Response != nil { 2077 sc = page.Response().Response.Response.StatusCode 2078 } 2079 tracing.EndSpan(ctx, sc, err) 2080 }() 2081 } 2082 for { 2083 next, err := page.fn(ctx, page.psqr) 2084 if err != nil { 2085 return err 2086 } 2087 page.psqr = next 2088 if !next.hasNextLink() || !next.IsEmpty() { 2089 break 2090 } 2091 } 2092 return nil 2093} 2094 2095// Next advances to the next page of values. If there was an error making 2096// the request the page does not advance and the error is returned. 2097// Deprecated: Use NextWithContext() instead. 2098func (page *PolicyStatesQueryResultsPage) Next() error { 2099 return page.NextWithContext(context.Background()) 2100} 2101 2102// NotDone returns true if the page enumeration should be started or is not yet complete. 2103func (page PolicyStatesQueryResultsPage) NotDone() bool { 2104 return !page.psqr.IsEmpty() 2105} 2106 2107// Response returns the raw server response from the last page request. 2108func (page PolicyStatesQueryResultsPage) Response() PolicyStatesQueryResults { 2109 return page.psqr 2110} 2111 2112// Values returns the slice of values for the current page or nil if there are no values. 2113func (page PolicyStatesQueryResultsPage) Values() []PolicyState { 2114 if page.psqr.IsEmpty() { 2115 return nil 2116 } 2117 return *page.psqr.Value 2118} 2119 2120// Creates a new instance of the PolicyStatesQueryResultsPage type. 2121func NewPolicyStatesQueryResultsPage(cur PolicyStatesQueryResults, getNextPage func(context.Context, PolicyStatesQueryResults) (PolicyStatesQueryResults, error)) PolicyStatesQueryResultsPage { 2122 return PolicyStatesQueryResultsPage{ 2123 fn: getNextPage, 2124 psqr: cur, 2125 } 2126} 2127 2128// PolicyStatesTriggerResourceGroupEvaluationFuture an abstraction for monitoring and retrieving the 2129// results of a long-running operation. 2130type PolicyStatesTriggerResourceGroupEvaluationFuture struct { 2131 azure.FutureAPI 2132 // Result returns the result of the asynchronous operation. 2133 // If the operation has not completed it will return an error. 2134 Result func(PolicyStatesClient) (autorest.Response, error) 2135} 2136 2137// PolicyStatesTriggerSubscriptionEvaluationFuture an abstraction for monitoring and retrieving the results 2138// of a long-running operation. 2139type PolicyStatesTriggerSubscriptionEvaluationFuture struct { 2140 azure.FutureAPI 2141 // Result returns the result of the asynchronous operation. 2142 // If the operation has not completed it will return an error. 2143 Result func(PolicyStatesClient) (autorest.Response, error) 2144} 2145 2146// PolicyTrackedResource policy tracked resource record. 2147type PolicyTrackedResource struct { 2148 // TrackedResourceID - READ-ONLY; The ID of the policy tracked resource. 2149 TrackedResourceID *string `json:"trackedResourceId,omitempty"` 2150 // PolicyDetails - READ-ONLY; The details of the policy that require the tracked resource. 2151 PolicyDetails *PolicyDetails `json:"policyDetails,omitempty"` 2152 // CreatedBy - READ-ONLY; The details of the policy triggered deployment that created the tracked resource. 2153 CreatedBy *TrackedResourceModificationDetails `json:"createdBy,omitempty"` 2154 // LastModifiedBy - READ-ONLY; The details of the policy triggered deployment that modified the tracked resource. 2155 LastModifiedBy *TrackedResourceModificationDetails `json:"lastModifiedBy,omitempty"` 2156 // LastUpdateUtc - READ-ONLY; Timestamp of the last update to the tracked resource. 2157 LastUpdateUtc *date.Time `json:"lastUpdateUtc,omitempty"` 2158} 2159 2160// PolicyTrackedResourcesQueryResults query results. 2161type PolicyTrackedResourcesQueryResults struct { 2162 autorest.Response `json:"-"` 2163 // Value - READ-ONLY; Query results. 2164 Value *[]PolicyTrackedResource `json:"value,omitempty"` 2165 // NextLink - READ-ONLY; The URL to get the next set of results. 2166 NextLink *string `json:"nextLink,omitempty"` 2167} 2168 2169// PolicyTrackedResourcesQueryResultsIterator provides access to a complete listing of 2170// PolicyTrackedResource values. 2171type PolicyTrackedResourcesQueryResultsIterator struct { 2172 i int 2173 page PolicyTrackedResourcesQueryResultsPage 2174} 2175 2176// NextWithContext advances to the next value. If there was an error making 2177// the request the iterator does not advance and the error is returned. 2178func (iter *PolicyTrackedResourcesQueryResultsIterator) NextWithContext(ctx context.Context) (err error) { 2179 if tracing.IsEnabled() { 2180 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesQueryResultsIterator.NextWithContext") 2181 defer func() { 2182 sc := -1 2183 if iter.Response().Response.Response != nil { 2184 sc = iter.Response().Response.Response.StatusCode 2185 } 2186 tracing.EndSpan(ctx, sc, err) 2187 }() 2188 } 2189 iter.i++ 2190 if iter.i < len(iter.page.Values()) { 2191 return nil 2192 } 2193 err = iter.page.NextWithContext(ctx) 2194 if err != nil { 2195 iter.i-- 2196 return err 2197 } 2198 iter.i = 0 2199 return nil 2200} 2201 2202// Next advances to the next value. If there was an error making 2203// the request the iterator does not advance and the error is returned. 2204// Deprecated: Use NextWithContext() instead. 2205func (iter *PolicyTrackedResourcesQueryResultsIterator) Next() error { 2206 return iter.NextWithContext(context.Background()) 2207} 2208 2209// NotDone returns true if the enumeration should be started or is not yet complete. 2210func (iter PolicyTrackedResourcesQueryResultsIterator) NotDone() bool { 2211 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 2212} 2213 2214// Response returns the raw server response from the last page request. 2215func (iter PolicyTrackedResourcesQueryResultsIterator) Response() PolicyTrackedResourcesQueryResults { 2216 return iter.page.Response() 2217} 2218 2219// Value returns the current value or a zero-initialized value if the 2220// iterator has advanced beyond the end of the collection. 2221func (iter PolicyTrackedResourcesQueryResultsIterator) Value() PolicyTrackedResource { 2222 if !iter.page.NotDone() { 2223 return PolicyTrackedResource{} 2224 } 2225 return iter.page.Values()[iter.i] 2226} 2227 2228// Creates a new instance of the PolicyTrackedResourcesQueryResultsIterator type. 2229func NewPolicyTrackedResourcesQueryResultsIterator(page PolicyTrackedResourcesQueryResultsPage) PolicyTrackedResourcesQueryResultsIterator { 2230 return PolicyTrackedResourcesQueryResultsIterator{page: page} 2231} 2232 2233// IsEmpty returns true if the ListResult contains no values. 2234func (ptrqr PolicyTrackedResourcesQueryResults) IsEmpty() bool { 2235 return ptrqr.Value == nil || len(*ptrqr.Value) == 0 2236} 2237 2238// hasNextLink returns true if the NextLink is not empty. 2239func (ptrqr PolicyTrackedResourcesQueryResults) hasNextLink() bool { 2240 return ptrqr.NextLink != nil && len(*ptrqr.NextLink) != 0 2241} 2242 2243// policyTrackedResourcesQueryResultsPreparer prepares a request to retrieve the next set of results. 2244// It returns nil if no more results exist. 2245func (ptrqr PolicyTrackedResourcesQueryResults) policyTrackedResourcesQueryResultsPreparer(ctx context.Context) (*http.Request, error) { 2246 if !ptrqr.hasNextLink() { 2247 return nil, nil 2248 } 2249 return autorest.Prepare((&http.Request{}).WithContext(ctx), 2250 autorest.AsJSON(), 2251 autorest.AsGet(), 2252 autorest.WithBaseURL(to.String(ptrqr.NextLink))) 2253} 2254 2255// PolicyTrackedResourcesQueryResultsPage contains a page of PolicyTrackedResource values. 2256type PolicyTrackedResourcesQueryResultsPage struct { 2257 fn func(context.Context, PolicyTrackedResourcesQueryResults) (PolicyTrackedResourcesQueryResults, error) 2258 ptrqr PolicyTrackedResourcesQueryResults 2259} 2260 2261// NextWithContext advances to the next page of values. If there was an error making 2262// the request the page does not advance and the error is returned. 2263func (page *PolicyTrackedResourcesQueryResultsPage) NextWithContext(ctx context.Context) (err error) { 2264 if tracing.IsEnabled() { 2265 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyTrackedResourcesQueryResultsPage.NextWithContext") 2266 defer func() { 2267 sc := -1 2268 if page.Response().Response.Response != nil { 2269 sc = page.Response().Response.Response.StatusCode 2270 } 2271 tracing.EndSpan(ctx, sc, err) 2272 }() 2273 } 2274 for { 2275 next, err := page.fn(ctx, page.ptrqr) 2276 if err != nil { 2277 return err 2278 } 2279 page.ptrqr = next 2280 if !next.hasNextLink() || !next.IsEmpty() { 2281 break 2282 } 2283 } 2284 return nil 2285} 2286 2287// Next advances to the next page of values. If there was an error making 2288// the request the page does not advance and the error is returned. 2289// Deprecated: Use NextWithContext() instead. 2290func (page *PolicyTrackedResourcesQueryResultsPage) Next() error { 2291 return page.NextWithContext(context.Background()) 2292} 2293 2294// NotDone returns true if the page enumeration should be started or is not yet complete. 2295func (page PolicyTrackedResourcesQueryResultsPage) NotDone() bool { 2296 return !page.ptrqr.IsEmpty() 2297} 2298 2299// Response returns the raw server response from the last page request. 2300func (page PolicyTrackedResourcesQueryResultsPage) Response() PolicyTrackedResourcesQueryResults { 2301 return page.ptrqr 2302} 2303 2304// Values returns the slice of values for the current page or nil if there are no values. 2305func (page PolicyTrackedResourcesQueryResultsPage) Values() []PolicyTrackedResource { 2306 if page.ptrqr.IsEmpty() { 2307 return nil 2308 } 2309 return *page.ptrqr.Value 2310} 2311 2312// Creates a new instance of the PolicyTrackedResourcesQueryResultsPage type. 2313func NewPolicyTrackedResourcesQueryResultsPage(cur PolicyTrackedResourcesQueryResults, getNextPage func(context.Context, PolicyTrackedResourcesQueryResults) (PolicyTrackedResourcesQueryResults, error)) PolicyTrackedResourcesQueryResultsPage { 2314 return PolicyTrackedResourcesQueryResultsPage{ 2315 fn: getNextPage, 2316 ptrqr: cur, 2317 } 2318} 2319 2320// QueryFailure error response. 2321type QueryFailure struct { 2322 // Error - Error definition. 2323 Error *QueryFailureError `json:"error,omitempty"` 2324} 2325 2326// QueryFailureError error definition. 2327type QueryFailureError struct { 2328 // Code - READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. 2329 Code *string `json:"code,omitempty"` 2330 // Message - READ-ONLY; Description of the error. 2331 Message *string `json:"message,omitempty"` 2332} 2333 2334// Remediation the remediation definition. 2335type Remediation struct { 2336 autorest.Response `json:"-"` 2337 // RemediationProperties - Properties for the remediation. 2338 *RemediationProperties `json:"properties,omitempty"` 2339 // ID - READ-ONLY; The ID of the remediation. 2340 ID *string `json:"id,omitempty"` 2341 // Type - READ-ONLY; The type of the remediation. 2342 Type *string `json:"type,omitempty"` 2343 // Name - READ-ONLY; The name of the remediation. 2344 Name *string `json:"name,omitempty"` 2345} 2346 2347// MarshalJSON is the custom marshaler for Remediation. 2348func (r Remediation) MarshalJSON() ([]byte, error) { 2349 objectMap := make(map[string]interface{}) 2350 if r.RemediationProperties != nil { 2351 objectMap["properties"] = r.RemediationProperties 2352 } 2353 return json.Marshal(objectMap) 2354} 2355 2356// UnmarshalJSON is the custom unmarshaler for Remediation struct. 2357func (r *Remediation) UnmarshalJSON(body []byte) error { 2358 var m map[string]*json.RawMessage 2359 err := json.Unmarshal(body, &m) 2360 if err != nil { 2361 return err 2362 } 2363 for k, v := range m { 2364 switch k { 2365 case "properties": 2366 if v != nil { 2367 var remediationProperties RemediationProperties 2368 err = json.Unmarshal(*v, &remediationProperties) 2369 if err != nil { 2370 return err 2371 } 2372 r.RemediationProperties = &remediationProperties 2373 } 2374 case "id": 2375 if v != nil { 2376 var ID string 2377 err = json.Unmarshal(*v, &ID) 2378 if err != nil { 2379 return err 2380 } 2381 r.ID = &ID 2382 } 2383 case "type": 2384 if v != nil { 2385 var typeVar string 2386 err = json.Unmarshal(*v, &typeVar) 2387 if err != nil { 2388 return err 2389 } 2390 r.Type = &typeVar 2391 } 2392 case "name": 2393 if v != nil { 2394 var name string 2395 err = json.Unmarshal(*v, &name) 2396 if err != nil { 2397 return err 2398 } 2399 r.Name = &name 2400 } 2401 } 2402 } 2403 2404 return nil 2405} 2406 2407// RemediationDeployment details of a single deployment created by the remediation. 2408type RemediationDeployment struct { 2409 // RemediatedResourceID - READ-ONLY; Resource ID of the resource that is being remediated by the deployment. 2410 RemediatedResourceID *string `json:"remediatedResourceId,omitempty"` 2411 // DeploymentID - READ-ONLY; Resource ID of the template deployment that will remediate the resource. 2412 DeploymentID *string `json:"deploymentId,omitempty"` 2413 // Status - READ-ONLY; Status of the remediation deployment. 2414 Status *string `json:"status,omitempty"` 2415 // ResourceLocation - READ-ONLY; Location of the resource that is being remediated. 2416 ResourceLocation *string `json:"resourceLocation,omitempty"` 2417 // Error - READ-ONLY; Error encountered while remediated the resource. 2418 Error *ErrorDefinition `json:"error,omitempty"` 2419 // CreatedOn - READ-ONLY; The time at which the remediation was created. 2420 CreatedOn *date.Time `json:"createdOn,omitempty"` 2421 // LastUpdatedOn - READ-ONLY; The time at which the remediation deployment was last updated. 2422 LastUpdatedOn *date.Time `json:"lastUpdatedOn,omitempty"` 2423} 2424 2425// RemediationDeploymentsListResult list of deployments for a remediation. 2426type RemediationDeploymentsListResult struct { 2427 autorest.Response `json:"-"` 2428 // Value - READ-ONLY; Array of deployments for the remediation. 2429 Value *[]RemediationDeployment `json:"value,omitempty"` 2430 // NextLink - READ-ONLY; The URL to get the next set of results. 2431 NextLink *string `json:"nextLink,omitempty"` 2432} 2433 2434// RemediationDeploymentsListResultIterator provides access to a complete listing of RemediationDeployment 2435// values. 2436type RemediationDeploymentsListResultIterator struct { 2437 i int 2438 page RemediationDeploymentsListResultPage 2439} 2440 2441// NextWithContext advances to the next value. If there was an error making 2442// the request the iterator does not advance and the error is returned. 2443func (iter *RemediationDeploymentsListResultIterator) NextWithContext(ctx context.Context) (err error) { 2444 if tracing.IsEnabled() { 2445 ctx = tracing.StartSpan(ctx, fqdn+"/RemediationDeploymentsListResultIterator.NextWithContext") 2446 defer func() { 2447 sc := -1 2448 if iter.Response().Response.Response != nil { 2449 sc = iter.Response().Response.Response.StatusCode 2450 } 2451 tracing.EndSpan(ctx, sc, err) 2452 }() 2453 } 2454 iter.i++ 2455 if iter.i < len(iter.page.Values()) { 2456 return nil 2457 } 2458 err = iter.page.NextWithContext(ctx) 2459 if err != nil { 2460 iter.i-- 2461 return err 2462 } 2463 iter.i = 0 2464 return nil 2465} 2466 2467// Next advances to the next value. If there was an error making 2468// the request the iterator does not advance and the error is returned. 2469// Deprecated: Use NextWithContext() instead. 2470func (iter *RemediationDeploymentsListResultIterator) Next() error { 2471 return iter.NextWithContext(context.Background()) 2472} 2473 2474// NotDone returns true if the enumeration should be started or is not yet complete. 2475func (iter RemediationDeploymentsListResultIterator) NotDone() bool { 2476 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 2477} 2478 2479// Response returns the raw server response from the last page request. 2480func (iter RemediationDeploymentsListResultIterator) Response() RemediationDeploymentsListResult { 2481 return iter.page.Response() 2482} 2483 2484// Value returns the current value or a zero-initialized value if the 2485// iterator has advanced beyond the end of the collection. 2486func (iter RemediationDeploymentsListResultIterator) Value() RemediationDeployment { 2487 if !iter.page.NotDone() { 2488 return RemediationDeployment{} 2489 } 2490 return iter.page.Values()[iter.i] 2491} 2492 2493// Creates a new instance of the RemediationDeploymentsListResultIterator type. 2494func NewRemediationDeploymentsListResultIterator(page RemediationDeploymentsListResultPage) RemediationDeploymentsListResultIterator { 2495 return RemediationDeploymentsListResultIterator{page: page} 2496} 2497 2498// IsEmpty returns true if the ListResult contains no values. 2499func (rdlr RemediationDeploymentsListResult) IsEmpty() bool { 2500 return rdlr.Value == nil || len(*rdlr.Value) == 0 2501} 2502 2503// hasNextLink returns true if the NextLink is not empty. 2504func (rdlr RemediationDeploymentsListResult) hasNextLink() bool { 2505 return rdlr.NextLink != nil && len(*rdlr.NextLink) != 0 2506} 2507 2508// remediationDeploymentsListResultPreparer prepares a request to retrieve the next set of results. 2509// It returns nil if no more results exist. 2510func (rdlr RemediationDeploymentsListResult) remediationDeploymentsListResultPreparer(ctx context.Context) (*http.Request, error) { 2511 if !rdlr.hasNextLink() { 2512 return nil, nil 2513 } 2514 return autorest.Prepare((&http.Request{}).WithContext(ctx), 2515 autorest.AsJSON(), 2516 autorest.AsGet(), 2517 autorest.WithBaseURL(to.String(rdlr.NextLink))) 2518} 2519 2520// RemediationDeploymentsListResultPage contains a page of RemediationDeployment values. 2521type RemediationDeploymentsListResultPage struct { 2522 fn func(context.Context, RemediationDeploymentsListResult) (RemediationDeploymentsListResult, error) 2523 rdlr RemediationDeploymentsListResult 2524} 2525 2526// NextWithContext advances to the next page of values. If there was an error making 2527// the request the page does not advance and the error is returned. 2528func (page *RemediationDeploymentsListResultPage) NextWithContext(ctx context.Context) (err error) { 2529 if tracing.IsEnabled() { 2530 ctx = tracing.StartSpan(ctx, fqdn+"/RemediationDeploymentsListResultPage.NextWithContext") 2531 defer func() { 2532 sc := -1 2533 if page.Response().Response.Response != nil { 2534 sc = page.Response().Response.Response.StatusCode 2535 } 2536 tracing.EndSpan(ctx, sc, err) 2537 }() 2538 } 2539 for { 2540 next, err := page.fn(ctx, page.rdlr) 2541 if err != nil { 2542 return err 2543 } 2544 page.rdlr = next 2545 if !next.hasNextLink() || !next.IsEmpty() { 2546 break 2547 } 2548 } 2549 return nil 2550} 2551 2552// Next advances to the next page of values. If there was an error making 2553// the request the page does not advance and the error is returned. 2554// Deprecated: Use NextWithContext() instead. 2555func (page *RemediationDeploymentsListResultPage) Next() error { 2556 return page.NextWithContext(context.Background()) 2557} 2558 2559// NotDone returns true if the page enumeration should be started or is not yet complete. 2560func (page RemediationDeploymentsListResultPage) NotDone() bool { 2561 return !page.rdlr.IsEmpty() 2562} 2563 2564// Response returns the raw server response from the last page request. 2565func (page RemediationDeploymentsListResultPage) Response() RemediationDeploymentsListResult { 2566 return page.rdlr 2567} 2568 2569// Values returns the slice of values for the current page or nil if there are no values. 2570func (page RemediationDeploymentsListResultPage) Values() []RemediationDeployment { 2571 if page.rdlr.IsEmpty() { 2572 return nil 2573 } 2574 return *page.rdlr.Value 2575} 2576 2577// Creates a new instance of the RemediationDeploymentsListResultPage type. 2578func NewRemediationDeploymentsListResultPage(cur RemediationDeploymentsListResult, getNextPage func(context.Context, RemediationDeploymentsListResult) (RemediationDeploymentsListResult, error)) RemediationDeploymentsListResultPage { 2579 return RemediationDeploymentsListResultPage{ 2580 fn: getNextPage, 2581 rdlr: cur, 2582 } 2583} 2584 2585// RemediationDeploymentSummary the deployment status summary for all deployments created by the 2586// remediation. 2587type RemediationDeploymentSummary struct { 2588 // TotalDeployments - READ-ONLY; The number of deployments required by the remediation. 2589 TotalDeployments *int32 `json:"totalDeployments,omitempty"` 2590 // SuccessfulDeployments - READ-ONLY; The number of deployments required by the remediation that have succeeded. 2591 SuccessfulDeployments *int32 `json:"successfulDeployments,omitempty"` 2592 // FailedDeployments - READ-ONLY; The number of deployments required by the remediation that have failed. 2593 FailedDeployments *int32 `json:"failedDeployments,omitempty"` 2594} 2595 2596// RemediationFilters the filters that will be applied to determine which resources to remediate. 2597type RemediationFilters struct { 2598 // Locations - The resource locations that will be remediated. 2599 Locations *[]string `json:"locations,omitempty"` 2600} 2601 2602// RemediationListResult list of remediations. 2603type RemediationListResult struct { 2604 autorest.Response `json:"-"` 2605 // Value - READ-ONLY; Array of remediation definitions. 2606 Value *[]Remediation `json:"value,omitempty"` 2607 // NextLink - READ-ONLY; The URL to get the next set of results. 2608 NextLink *string `json:"nextLink,omitempty"` 2609} 2610 2611// RemediationListResultIterator provides access to a complete listing of Remediation values. 2612type RemediationListResultIterator struct { 2613 i int 2614 page RemediationListResultPage 2615} 2616 2617// NextWithContext advances to the next value. If there was an error making 2618// the request the iterator does not advance and the error is returned. 2619func (iter *RemediationListResultIterator) NextWithContext(ctx context.Context) (err error) { 2620 if tracing.IsEnabled() { 2621 ctx = tracing.StartSpan(ctx, fqdn+"/RemediationListResultIterator.NextWithContext") 2622 defer func() { 2623 sc := -1 2624 if iter.Response().Response.Response != nil { 2625 sc = iter.Response().Response.Response.StatusCode 2626 } 2627 tracing.EndSpan(ctx, sc, err) 2628 }() 2629 } 2630 iter.i++ 2631 if iter.i < len(iter.page.Values()) { 2632 return nil 2633 } 2634 err = iter.page.NextWithContext(ctx) 2635 if err != nil { 2636 iter.i-- 2637 return err 2638 } 2639 iter.i = 0 2640 return nil 2641} 2642 2643// Next advances to the next value. If there was an error making 2644// the request the iterator does not advance and the error is returned. 2645// Deprecated: Use NextWithContext() instead. 2646func (iter *RemediationListResultIterator) Next() error { 2647 return iter.NextWithContext(context.Background()) 2648} 2649 2650// NotDone returns true if the enumeration should be started or is not yet complete. 2651func (iter RemediationListResultIterator) NotDone() bool { 2652 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 2653} 2654 2655// Response returns the raw server response from the last page request. 2656func (iter RemediationListResultIterator) Response() RemediationListResult { 2657 return iter.page.Response() 2658} 2659 2660// Value returns the current value or a zero-initialized value if the 2661// iterator has advanced beyond the end of the collection. 2662func (iter RemediationListResultIterator) Value() Remediation { 2663 if !iter.page.NotDone() { 2664 return Remediation{} 2665 } 2666 return iter.page.Values()[iter.i] 2667} 2668 2669// Creates a new instance of the RemediationListResultIterator type. 2670func NewRemediationListResultIterator(page RemediationListResultPage) RemediationListResultIterator { 2671 return RemediationListResultIterator{page: page} 2672} 2673 2674// IsEmpty returns true if the ListResult contains no values. 2675func (rlr RemediationListResult) IsEmpty() bool { 2676 return rlr.Value == nil || len(*rlr.Value) == 0 2677} 2678 2679// hasNextLink returns true if the NextLink is not empty. 2680func (rlr RemediationListResult) hasNextLink() bool { 2681 return rlr.NextLink != nil && len(*rlr.NextLink) != 0 2682} 2683 2684// remediationListResultPreparer prepares a request to retrieve the next set of results. 2685// It returns nil if no more results exist. 2686func (rlr RemediationListResult) remediationListResultPreparer(ctx context.Context) (*http.Request, error) { 2687 if !rlr.hasNextLink() { 2688 return nil, nil 2689 } 2690 return autorest.Prepare((&http.Request{}).WithContext(ctx), 2691 autorest.AsJSON(), 2692 autorest.AsGet(), 2693 autorest.WithBaseURL(to.String(rlr.NextLink))) 2694} 2695 2696// RemediationListResultPage contains a page of Remediation values. 2697type RemediationListResultPage struct { 2698 fn func(context.Context, RemediationListResult) (RemediationListResult, error) 2699 rlr RemediationListResult 2700} 2701 2702// NextWithContext advances to the next page of values. If there was an error making 2703// the request the page does not advance and the error is returned. 2704func (page *RemediationListResultPage) NextWithContext(ctx context.Context) (err error) { 2705 if tracing.IsEnabled() { 2706 ctx = tracing.StartSpan(ctx, fqdn+"/RemediationListResultPage.NextWithContext") 2707 defer func() { 2708 sc := -1 2709 if page.Response().Response.Response != nil { 2710 sc = page.Response().Response.Response.StatusCode 2711 } 2712 tracing.EndSpan(ctx, sc, err) 2713 }() 2714 } 2715 for { 2716 next, err := page.fn(ctx, page.rlr) 2717 if err != nil { 2718 return err 2719 } 2720 page.rlr = next 2721 if !next.hasNextLink() || !next.IsEmpty() { 2722 break 2723 } 2724 } 2725 return nil 2726} 2727 2728// Next advances to the next page of values. If there was an error making 2729// the request the page does not advance and the error is returned. 2730// Deprecated: Use NextWithContext() instead. 2731func (page *RemediationListResultPage) Next() error { 2732 return page.NextWithContext(context.Background()) 2733} 2734 2735// NotDone returns true if the page enumeration should be started or is not yet complete. 2736func (page RemediationListResultPage) NotDone() bool { 2737 return !page.rlr.IsEmpty() 2738} 2739 2740// Response returns the raw server response from the last page request. 2741func (page RemediationListResultPage) Response() RemediationListResult { 2742 return page.rlr 2743} 2744 2745// Values returns the slice of values for the current page or nil if there are no values. 2746func (page RemediationListResultPage) Values() []Remediation { 2747 if page.rlr.IsEmpty() { 2748 return nil 2749 } 2750 return *page.rlr.Value 2751} 2752 2753// Creates a new instance of the RemediationListResultPage type. 2754func NewRemediationListResultPage(cur RemediationListResult, getNextPage func(context.Context, RemediationListResult) (RemediationListResult, error)) RemediationListResultPage { 2755 return RemediationListResultPage{ 2756 fn: getNextPage, 2757 rlr: cur, 2758 } 2759} 2760 2761// RemediationProperties the remediation properties. 2762type RemediationProperties struct { 2763 // PolicyAssignmentID - The resource ID of the policy assignment that should be remediated. 2764 PolicyAssignmentID *string `json:"policyAssignmentId,omitempty"` 2765 // 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. 2766 PolicyDefinitionReferenceID *string `json:"policyDefinitionReferenceId,omitempty"` 2767 // ResourceDiscoveryMode - The way resources to remediate are discovered. Defaults to ExistingNonCompliant if not specified. Possible values include: 'ExistingNonCompliant', 'ReEvaluateCompliance' 2768 ResourceDiscoveryMode ResourceDiscoveryMode `json:"resourceDiscoveryMode,omitempty"` 2769 // ProvisioningState - READ-ONLY; The status of the remediation. 2770 ProvisioningState *string `json:"provisioningState,omitempty"` 2771 // CreatedOn - READ-ONLY; The time at which the remediation was created. 2772 CreatedOn *date.Time `json:"createdOn,omitempty"` 2773 // LastUpdatedOn - READ-ONLY; The time at which the remediation was last updated. 2774 LastUpdatedOn *date.Time `json:"lastUpdatedOn,omitempty"` 2775 // Filters - The filters that will be applied to determine which resources to remediate. 2776 Filters *RemediationFilters `json:"filters,omitempty"` 2777 // DeploymentStatus - READ-ONLY; The deployment status summary for all deployments created by the remediation. 2778 DeploymentStatus *RemediationDeploymentSummary `json:"deploymentStatus,omitempty"` 2779} 2780 2781// MarshalJSON is the custom marshaler for RemediationProperties. 2782func (rp RemediationProperties) MarshalJSON() ([]byte, error) { 2783 objectMap := make(map[string]interface{}) 2784 if rp.PolicyAssignmentID != nil { 2785 objectMap["policyAssignmentId"] = rp.PolicyAssignmentID 2786 } 2787 if rp.PolicyDefinitionReferenceID != nil { 2788 objectMap["policyDefinitionReferenceId"] = rp.PolicyDefinitionReferenceID 2789 } 2790 if rp.ResourceDiscoveryMode != "" { 2791 objectMap["resourceDiscoveryMode"] = rp.ResourceDiscoveryMode 2792 } 2793 if rp.Filters != nil { 2794 objectMap["filters"] = rp.Filters 2795 } 2796 return json.Marshal(objectMap) 2797} 2798 2799// SlimPolicyMetadata slim version of policy metadata resource definition, excluding properties with large 2800// strings 2801type SlimPolicyMetadata struct { 2802 // PolicyMetadataSlimProperties - Properties of the policy metadata. 2803 *PolicyMetadataSlimProperties `json:"properties,omitempty"` 2804 // ID - READ-ONLY; The ID of the policy metadata. 2805 ID *string `json:"id,omitempty"` 2806 // Type - READ-ONLY; The type of the policy metadata. 2807 Type *string `json:"type,omitempty"` 2808 // Name - READ-ONLY; The name of the policy metadata. 2809 Name *string `json:"name,omitempty"` 2810} 2811 2812// MarshalJSON is the custom marshaler for SlimPolicyMetadata. 2813func (spm SlimPolicyMetadata) MarshalJSON() ([]byte, error) { 2814 objectMap := make(map[string]interface{}) 2815 if spm.PolicyMetadataSlimProperties != nil { 2816 objectMap["properties"] = spm.PolicyMetadataSlimProperties 2817 } 2818 return json.Marshal(objectMap) 2819} 2820 2821// UnmarshalJSON is the custom unmarshaler for SlimPolicyMetadata struct. 2822func (spm *SlimPolicyMetadata) UnmarshalJSON(body []byte) error { 2823 var m map[string]*json.RawMessage 2824 err := json.Unmarshal(body, &m) 2825 if err != nil { 2826 return err 2827 } 2828 for k, v := range m { 2829 switch k { 2830 case "properties": 2831 if v != nil { 2832 var policyMetadataSlimProperties PolicyMetadataSlimProperties 2833 err = json.Unmarshal(*v, &policyMetadataSlimProperties) 2834 if err != nil { 2835 return err 2836 } 2837 spm.PolicyMetadataSlimProperties = &policyMetadataSlimProperties 2838 } 2839 case "id": 2840 if v != nil { 2841 var ID string 2842 err = json.Unmarshal(*v, &ID) 2843 if err != nil { 2844 return err 2845 } 2846 spm.ID = &ID 2847 } 2848 case "type": 2849 if v != nil { 2850 var typeVar string 2851 err = json.Unmarshal(*v, &typeVar) 2852 if err != nil { 2853 return err 2854 } 2855 spm.Type = &typeVar 2856 } 2857 case "name": 2858 if v != nil { 2859 var name string 2860 err = json.Unmarshal(*v, &name) 2861 if err != nil { 2862 return err 2863 } 2864 spm.Name = &name 2865 } 2866 } 2867 } 2868 2869 return nil 2870} 2871 2872// SummarizeResults summarize action results. 2873type SummarizeResults struct { 2874 autorest.Response `json:"-"` 2875 // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. 2876 OdataContext *string `json:"@odata.context,omitempty"` 2877 // OdataCount - OData entity count; represents the number of summaries returned; always set to 1. 2878 OdataCount *int32 `json:"@odata.count,omitempty"` 2879 // Value - Summarize action results. 2880 Value *[]Summary `json:"value,omitempty"` 2881} 2882 2883// Summary summary results. 2884type Summary struct { 2885 // OdataID - OData entity ID; always set to null since summaries do not have an entity ID. 2886 OdataID *string `json:"@odata.id,omitempty"` 2887 // OdataContext - OData context string; used by OData clients to resolve type information based on metadata. 2888 OdataContext *string `json:"@odata.context,omitempty"` 2889 // Results - Compliance summary for all policy assignments. 2890 Results *SummaryResults `json:"results,omitempty"` 2891 // PolicyAssignments - Policy assignments summary. 2892 PolicyAssignments *[]PolicyAssignmentSummary `json:"policyAssignments,omitempty"` 2893} 2894 2895// SummaryResults compliance summary on a particular summary level. 2896type SummaryResults struct { 2897 // QueryResultsURI - HTTP POST URI for queryResults action on Microsoft.PolicyInsights to retrieve raw results for the compliance summary. This property will not be available by default in future API versions, but could be queried explicitly. 2898 QueryResultsURI *string `json:"queryResultsUri,omitempty"` 2899 // NonCompliantResources - Number of non-compliant resources. 2900 NonCompliantResources *int32 `json:"nonCompliantResources,omitempty"` 2901 // NonCompliantPolicies - Number of non-compliant policies. 2902 NonCompliantPolicies *int32 `json:"nonCompliantPolicies,omitempty"` 2903 // ResourceDetails - The resources summary at this level. 2904 ResourceDetails *[]ComplianceDetail `json:"resourceDetails,omitempty"` 2905 // PolicyDetails - The policy artifact summary at this level. For query scope level, it represents policy assignment summary. For policy assignment level, it represents policy definitions summary. 2906 PolicyDetails *[]ComplianceDetail `json:"policyDetails,omitempty"` 2907 // PolicyGroupDetails - The policy definition group summary at this level. 2908 PolicyGroupDetails *[]ComplianceDetail `json:"policyGroupDetails,omitempty"` 2909} 2910 2911// TrackedResourceModificationDetails the details of the policy triggered deployment that created or 2912// modified the tracked resource. 2913type TrackedResourceModificationDetails struct { 2914 // PolicyDetails - READ-ONLY; The details of the policy that created or modified the tracked resource. 2915 PolicyDetails *PolicyDetails `json:"policyDetails,omitempty"` 2916 // DeploymentID - READ-ONLY; The ID of the deployment that created or modified the tracked resource. 2917 DeploymentID *string `json:"deploymentId,omitempty"` 2918 // DeploymentTime - READ-ONLY; Timestamp of the deployment that created or modified the tracked resource. 2919 DeploymentTime *date.Time `json:"deploymentTime,omitempty"` 2920} 2921 2922// TypedErrorInfo scenario specific error details. 2923type TypedErrorInfo struct { 2924 // Type - READ-ONLY; The type of included error details. 2925 Type *string `json:"type,omitempty"` 2926 // Info - READ-ONLY; The scenario specific error details. 2927 Info interface{} `json:"info,omitempty"` 2928} 2929