1package policyinsights 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/autorest/date" 14 "github.com/Azure/go-autorest/autorest/validation" 15 "github.com/Azure/go-autorest/tracing" 16 "net/http" 17) 18 19// PolicyStatesClient is the client for the PolicyStates methods of the Policyinsights service. 20type PolicyStatesClient struct { 21 BaseClient 22} 23 24// NewPolicyStatesClient creates an instance of the PolicyStatesClient client. 25func NewPolicyStatesClient() PolicyStatesClient { 26 return NewPolicyStatesClientWithBaseURI(DefaultBaseURI) 27} 28 29// NewPolicyStatesClientWithBaseURI creates an instance of the PolicyStatesClient client using a custom endpoint. Use 30// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 31func NewPolicyStatesClientWithBaseURI(baseURI string) PolicyStatesClient { 32 return PolicyStatesClient{NewWithBaseURI(baseURI)} 33} 34 35// GetMetadata gets OData metadata XML document. 36// Parameters: 37// scope - a valid scope, i.e. management group, subscription, resource group, or resource ID. Scope used has 38// no effect on metadata returned. 39func (client PolicyStatesClient) GetMetadata(ctx context.Context, scope string) (result String, err error) { 40 if tracing.IsEnabled() { 41 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.GetMetadata") 42 defer func() { 43 sc := -1 44 if result.Response.Response != nil { 45 sc = result.Response.Response.StatusCode 46 } 47 tracing.EndSpan(ctx, sc, err) 48 }() 49 } 50 req, err := client.GetMetadataPreparer(ctx, scope) 51 if err != nil { 52 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "GetMetadata", nil, "Failure preparing request") 53 return 54 } 55 56 resp, err := client.GetMetadataSender(req) 57 if err != nil { 58 result.Response = autorest.Response{Response: resp} 59 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "GetMetadata", resp, "Failure sending request") 60 return 61 } 62 63 result, err = client.GetMetadataResponder(resp) 64 if err != nil { 65 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "GetMetadata", resp, "Failure responding to request") 66 return 67 } 68 69 return 70} 71 72// GetMetadataPreparer prepares the GetMetadata request. 73func (client PolicyStatesClient) GetMetadataPreparer(ctx context.Context, scope string) (*http.Request, error) { 74 pathParameters := map[string]interface{}{ 75 "scope": scope, 76 } 77 78 const APIVersion = "2018-04-04" 79 queryParameters := map[string]interface{}{ 80 "api-version": APIVersion, 81 } 82 83 preparer := autorest.CreatePreparer( 84 autorest.AsGet(), 85 autorest.WithBaseURL(client.BaseURI), 86 autorest.WithPathParameters("/{scope}/providers/Microsoft.PolicyInsights/policyStates/$metadata", pathParameters), 87 autorest.WithQueryParameters(queryParameters)) 88 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 89} 90 91// GetMetadataSender sends the GetMetadata request. The method will close the 92// http.Response Body if it receives an error. 93func (client PolicyStatesClient) GetMetadataSender(req *http.Request) (*http.Response, error) { 94 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 95} 96 97// GetMetadataResponder handles the response to the GetMetadata request. The method always 98// closes the http.Response Body. 99func (client PolicyStatesClient) GetMetadataResponder(resp *http.Response) (result String, err error) { 100 err = autorest.Respond( 101 resp, 102 azure.WithErrorUnlessStatusCode(http.StatusOK), 103 autorest.ByUnmarshallingJSON(&result.Value), 104 autorest.ByClosing()) 105 result.Response = autorest.Response{Response: resp} 106 return 107} 108 109// ListQueryResultsForManagementGroup queries policy states for the resources under the management group. 110// Parameters: 111// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, 112// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). 113// managementGroupName - management group name. 114// top - maximum number of records to return. 115// orderBy - ordering expression using OData notation. One or more comma-separated column names with an 116// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". 117// selectParameter - select expression using OData notation. Limits the columns on each record to just those 118// requested, e.g. "$select=PolicyAssignmentId, ResourceId". 119// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 120// the service uses ($to - 1-day). 121// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 122// specified, the service uses request time. 123// filter - oData filter expression. 124// apply - oData apply expression for aggregations. 125func (client PolicyStatesClient) ListQueryResultsForManagementGroup(ctx context.Context, policyStatesResource PolicyStatesResource, managementGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { 126 if tracing.IsEnabled() { 127 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForManagementGroup") 128 defer func() { 129 sc := -1 130 if result.Response.Response != nil { 131 sc = result.Response.Response.StatusCode 132 } 133 tracing.EndSpan(ctx, sc, err) 134 }() 135 } 136 if err := validation.Validate([]validation.Validation{ 137 {TargetValue: top, 138 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 139 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 140 return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForManagementGroup", err.Error()) 141 } 142 143 req, err := client.ListQueryResultsForManagementGroupPreparer(ctx, policyStatesResource, managementGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply) 144 if err != nil { 145 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForManagementGroup", nil, "Failure preparing request") 146 return 147 } 148 149 resp, err := client.ListQueryResultsForManagementGroupSender(req) 150 if err != nil { 151 result.Response = autorest.Response{Response: resp} 152 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForManagementGroup", resp, "Failure sending request") 153 return 154 } 155 156 result, err = client.ListQueryResultsForManagementGroupResponder(resp) 157 if err != nil { 158 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForManagementGroup", resp, "Failure responding to request") 159 return 160 } 161 162 return 163} 164 165// ListQueryResultsForManagementGroupPreparer prepares the ListQueryResultsForManagementGroup request. 166func (client PolicyStatesClient) ListQueryResultsForManagementGroupPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, managementGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { 167 pathParameters := map[string]interface{}{ 168 "managementGroupName": autorest.Encode("path", managementGroupName), 169 "managementGroupsNamespace": autorest.Encode("path", "Microsoft.Management"), 170 "policyStatesResource": autorest.Encode("path", policyStatesResource), 171 } 172 173 const APIVersion = "2018-04-04" 174 queryParameters := map[string]interface{}{ 175 "api-version": APIVersion, 176 } 177 if top != nil { 178 queryParameters["$top"] = autorest.Encode("query", *top) 179 } 180 if len(orderBy) > 0 { 181 queryParameters["$orderby"] = autorest.Encode("query", orderBy) 182 } 183 if len(selectParameter) > 0 { 184 queryParameters["$select"] = autorest.Encode("query", selectParameter) 185 } 186 if from != nil { 187 queryParameters["$from"] = autorest.Encode("query", *from) 188 } 189 if toParameter != nil { 190 queryParameters["$to"] = autorest.Encode("query", *toParameter) 191 } 192 if len(filter) > 0 { 193 queryParameters["$filter"] = autorest.Encode("query", filter) 194 } 195 if len(apply) > 0 { 196 queryParameters["$apply"] = autorest.Encode("query", apply) 197 } 198 199 preparer := autorest.CreatePreparer( 200 autorest.AsPost(), 201 autorest.WithBaseURL(client.BaseURI), 202 autorest.WithPathParameters("/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), 203 autorest.WithQueryParameters(queryParameters)) 204 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 205} 206 207// ListQueryResultsForManagementGroupSender sends the ListQueryResultsForManagementGroup request. The method will close the 208// http.Response Body if it receives an error. 209func (client PolicyStatesClient) ListQueryResultsForManagementGroupSender(req *http.Request) (*http.Response, error) { 210 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 211} 212 213// ListQueryResultsForManagementGroupResponder handles the response to the ListQueryResultsForManagementGroup request. The method always 214// closes the http.Response Body. 215func (client PolicyStatesClient) ListQueryResultsForManagementGroupResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { 216 err = autorest.Respond( 217 resp, 218 azure.WithErrorUnlessStatusCode(http.StatusOK), 219 autorest.ByUnmarshallingJSON(&result), 220 autorest.ByClosing()) 221 result.Response = autorest.Response{Response: resp} 222 return 223} 224 225// ListQueryResultsForPolicyDefinition queries policy states for the subscription level policy definition. 226// Parameters: 227// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, 228// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). 229// subscriptionID - microsoft Azure subscription ID. 230// policyDefinitionName - policy definition name. 231// top - maximum number of records to return. 232// orderBy - ordering expression using OData notation. One or more comma-separated column names with an 233// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". 234// selectParameter - select expression using OData notation. Limits the columns on each record to just those 235// requested, e.g. "$select=PolicyAssignmentId, ResourceId". 236// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 237// the service uses ($to - 1-day). 238// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 239// specified, the service uses request time. 240// filter - oData filter expression. 241// apply - oData apply expression for aggregations. 242func (client PolicyStatesClient) ListQueryResultsForPolicyDefinition(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, policyDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { 243 if tracing.IsEnabled() { 244 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForPolicyDefinition") 245 defer func() { 246 sc := -1 247 if result.Response.Response != nil { 248 sc = result.Response.Response.StatusCode 249 } 250 tracing.EndSpan(ctx, sc, err) 251 }() 252 } 253 if err := validation.Validate([]validation.Validation{ 254 {TargetValue: top, 255 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 256 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 257 return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForPolicyDefinition", err.Error()) 258 } 259 260 req, err := client.ListQueryResultsForPolicyDefinitionPreparer(ctx, policyStatesResource, subscriptionID, policyDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply) 261 if err != nil { 262 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicyDefinition", nil, "Failure preparing request") 263 return 264 } 265 266 resp, err := client.ListQueryResultsForPolicyDefinitionSender(req) 267 if err != nil { 268 result.Response = autorest.Response{Response: resp} 269 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicyDefinition", resp, "Failure sending request") 270 return 271 } 272 273 result, err = client.ListQueryResultsForPolicyDefinitionResponder(resp) 274 if err != nil { 275 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicyDefinition", resp, "Failure responding to request") 276 return 277 } 278 279 return 280} 281 282// ListQueryResultsForPolicyDefinitionPreparer prepares the ListQueryResultsForPolicyDefinition request. 283func (client PolicyStatesClient) ListQueryResultsForPolicyDefinitionPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, policyDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { 284 pathParameters := map[string]interface{}{ 285 "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), 286 "policyDefinitionName": autorest.Encode("path", policyDefinitionName), 287 "policyStatesResource": autorest.Encode("path", policyStatesResource), 288 "subscriptionId": autorest.Encode("path", subscriptionID), 289 } 290 291 const APIVersion = "2018-04-04" 292 queryParameters := map[string]interface{}{ 293 "api-version": APIVersion, 294 } 295 if top != nil { 296 queryParameters["$top"] = autorest.Encode("query", *top) 297 } 298 if len(orderBy) > 0 { 299 queryParameters["$orderby"] = autorest.Encode("query", orderBy) 300 } 301 if len(selectParameter) > 0 { 302 queryParameters["$select"] = autorest.Encode("query", selectParameter) 303 } 304 if from != nil { 305 queryParameters["$from"] = autorest.Encode("query", *from) 306 } 307 if toParameter != nil { 308 queryParameters["$to"] = autorest.Encode("query", *toParameter) 309 } 310 if len(filter) > 0 { 311 queryParameters["$filter"] = autorest.Encode("query", filter) 312 } 313 if len(apply) > 0 { 314 queryParameters["$apply"] = autorest.Encode("query", apply) 315 } 316 317 preparer := autorest.CreatePreparer( 318 autorest.AsPost(), 319 autorest.WithBaseURL(client.BaseURI), 320 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), 321 autorest.WithQueryParameters(queryParameters)) 322 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 323} 324 325// ListQueryResultsForPolicyDefinitionSender sends the ListQueryResultsForPolicyDefinition request. The method will close the 326// http.Response Body if it receives an error. 327func (client PolicyStatesClient) ListQueryResultsForPolicyDefinitionSender(req *http.Request) (*http.Response, error) { 328 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 329} 330 331// ListQueryResultsForPolicyDefinitionResponder handles the response to the ListQueryResultsForPolicyDefinition request. The method always 332// closes the http.Response Body. 333func (client PolicyStatesClient) ListQueryResultsForPolicyDefinitionResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { 334 err = autorest.Respond( 335 resp, 336 azure.WithErrorUnlessStatusCode(http.StatusOK), 337 autorest.ByUnmarshallingJSON(&result), 338 autorest.ByClosing()) 339 result.Response = autorest.Response{Response: resp} 340 return 341} 342 343// ListQueryResultsForPolicySetDefinition queries policy states for the subscription level policy set definition. 344// Parameters: 345// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, 346// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). 347// subscriptionID - microsoft Azure subscription ID. 348// policySetDefinitionName - policy set definition name. 349// top - maximum number of records to return. 350// orderBy - ordering expression using OData notation. One or more comma-separated column names with an 351// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". 352// selectParameter - select expression using OData notation. Limits the columns on each record to just those 353// requested, e.g. "$select=PolicyAssignmentId, ResourceId". 354// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 355// the service uses ($to - 1-day). 356// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 357// specified, the service uses request time. 358// filter - oData filter expression. 359// apply - oData apply expression for aggregations. 360func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinition(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, policySetDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { 361 if tracing.IsEnabled() { 362 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForPolicySetDefinition") 363 defer func() { 364 sc := -1 365 if result.Response.Response != nil { 366 sc = result.Response.Response.StatusCode 367 } 368 tracing.EndSpan(ctx, sc, err) 369 }() 370 } 371 if err := validation.Validate([]validation.Validation{ 372 {TargetValue: top, 373 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 374 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 375 return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForPolicySetDefinition", err.Error()) 376 } 377 378 req, err := client.ListQueryResultsForPolicySetDefinitionPreparer(ctx, policyStatesResource, subscriptionID, policySetDefinitionName, top, orderBy, selectParameter, from, toParameter, filter, apply) 379 if err != nil { 380 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicySetDefinition", nil, "Failure preparing request") 381 return 382 } 383 384 resp, err := client.ListQueryResultsForPolicySetDefinitionSender(req) 385 if err != nil { 386 result.Response = autorest.Response{Response: resp} 387 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicySetDefinition", resp, "Failure sending request") 388 return 389 } 390 391 result, err = client.ListQueryResultsForPolicySetDefinitionResponder(resp) 392 if err != nil { 393 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForPolicySetDefinition", resp, "Failure responding to request") 394 return 395 } 396 397 return 398} 399 400// ListQueryResultsForPolicySetDefinitionPreparer prepares the ListQueryResultsForPolicySetDefinition request. 401func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinitionPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, policySetDefinitionName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { 402 pathParameters := map[string]interface{}{ 403 "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), 404 "policySetDefinitionName": autorest.Encode("path", policySetDefinitionName), 405 "policyStatesResource": autorest.Encode("path", policyStatesResource), 406 "subscriptionId": autorest.Encode("path", subscriptionID), 407 } 408 409 const APIVersion = "2018-04-04" 410 queryParameters := map[string]interface{}{ 411 "api-version": APIVersion, 412 } 413 if top != nil { 414 queryParameters["$top"] = autorest.Encode("query", *top) 415 } 416 if len(orderBy) > 0 { 417 queryParameters["$orderby"] = autorest.Encode("query", orderBy) 418 } 419 if len(selectParameter) > 0 { 420 queryParameters["$select"] = autorest.Encode("query", selectParameter) 421 } 422 if from != nil { 423 queryParameters["$from"] = autorest.Encode("query", *from) 424 } 425 if toParameter != nil { 426 queryParameters["$to"] = autorest.Encode("query", *toParameter) 427 } 428 if len(filter) > 0 { 429 queryParameters["$filter"] = autorest.Encode("query", filter) 430 } 431 if len(apply) > 0 { 432 queryParameters["$apply"] = autorest.Encode("query", apply) 433 } 434 435 preparer := autorest.CreatePreparer( 436 autorest.AsPost(), 437 autorest.WithBaseURL(client.BaseURI), 438 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), 439 autorest.WithQueryParameters(queryParameters)) 440 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 441} 442 443// ListQueryResultsForPolicySetDefinitionSender sends the ListQueryResultsForPolicySetDefinition request. The method will close the 444// http.Response Body if it receives an error. 445func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinitionSender(req *http.Request) (*http.Response, error) { 446 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 447} 448 449// ListQueryResultsForPolicySetDefinitionResponder handles the response to the ListQueryResultsForPolicySetDefinition request. The method always 450// closes the http.Response Body. 451func (client PolicyStatesClient) ListQueryResultsForPolicySetDefinitionResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { 452 err = autorest.Respond( 453 resp, 454 azure.WithErrorUnlessStatusCode(http.StatusOK), 455 autorest.ByUnmarshallingJSON(&result), 456 autorest.ByClosing()) 457 result.Response = autorest.Response{Response: resp} 458 return 459} 460 461// ListQueryResultsForResource queries policy states for the resource. 462// Parameters: 463// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, 464// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). 465// resourceID - resource ID. 466// top - maximum number of records to return. 467// orderBy - ordering expression using OData notation. One or more comma-separated column names with an 468// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". 469// selectParameter - select expression using OData notation. Limits the columns on each record to just those 470// requested, e.g. "$select=PolicyAssignmentId, ResourceId". 471// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 472// the service uses ($to - 1-day). 473// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 474// specified, the service uses request time. 475// filter - oData filter expression. 476// apply - oData apply expression for aggregations. 477func (client PolicyStatesClient) ListQueryResultsForResource(ctx context.Context, policyStatesResource PolicyStatesResource, resourceID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { 478 if tracing.IsEnabled() { 479 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForResource") 480 defer func() { 481 sc := -1 482 if result.Response.Response != nil { 483 sc = result.Response.Response.StatusCode 484 } 485 tracing.EndSpan(ctx, sc, err) 486 }() 487 } 488 if err := validation.Validate([]validation.Validation{ 489 {TargetValue: top, 490 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 491 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 492 return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForResource", err.Error()) 493 } 494 495 req, err := client.ListQueryResultsForResourcePreparer(ctx, policyStatesResource, resourceID, top, orderBy, selectParameter, from, toParameter, filter, apply) 496 if err != nil { 497 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResource", nil, "Failure preparing request") 498 return 499 } 500 501 resp, err := client.ListQueryResultsForResourceSender(req) 502 if err != nil { 503 result.Response = autorest.Response{Response: resp} 504 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResource", resp, "Failure sending request") 505 return 506 } 507 508 result, err = client.ListQueryResultsForResourceResponder(resp) 509 if err != nil { 510 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResource", resp, "Failure responding to request") 511 return 512 } 513 514 return 515} 516 517// ListQueryResultsForResourcePreparer prepares the ListQueryResultsForResource request. 518func (client PolicyStatesClient) ListQueryResultsForResourcePreparer(ctx context.Context, policyStatesResource PolicyStatesResource, resourceID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { 519 pathParameters := map[string]interface{}{ 520 "policyStatesResource": autorest.Encode("path", policyStatesResource), 521 "resourceId": resourceID, 522 } 523 524 const APIVersion = "2018-04-04" 525 queryParameters := map[string]interface{}{ 526 "api-version": APIVersion, 527 } 528 if top != nil { 529 queryParameters["$top"] = autorest.Encode("query", *top) 530 } 531 if len(orderBy) > 0 { 532 queryParameters["$orderby"] = autorest.Encode("query", orderBy) 533 } 534 if len(selectParameter) > 0 { 535 queryParameters["$select"] = autorest.Encode("query", selectParameter) 536 } 537 if from != nil { 538 queryParameters["$from"] = autorest.Encode("query", *from) 539 } 540 if toParameter != nil { 541 queryParameters["$to"] = autorest.Encode("query", *toParameter) 542 } 543 if len(filter) > 0 { 544 queryParameters["$filter"] = autorest.Encode("query", filter) 545 } 546 if len(apply) > 0 { 547 queryParameters["$apply"] = autorest.Encode("query", apply) 548 } 549 550 preparer := autorest.CreatePreparer( 551 autorest.AsPost(), 552 autorest.WithBaseURL(client.BaseURI), 553 autorest.WithPathParameters("/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), 554 autorest.WithQueryParameters(queryParameters)) 555 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 556} 557 558// ListQueryResultsForResourceSender sends the ListQueryResultsForResource request. The method will close the 559// http.Response Body if it receives an error. 560func (client PolicyStatesClient) ListQueryResultsForResourceSender(req *http.Request) (*http.Response, error) { 561 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 562} 563 564// ListQueryResultsForResourceResponder handles the response to the ListQueryResultsForResource request. The method always 565// closes the http.Response Body. 566func (client PolicyStatesClient) ListQueryResultsForResourceResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { 567 err = autorest.Respond( 568 resp, 569 azure.WithErrorUnlessStatusCode(http.StatusOK), 570 autorest.ByUnmarshallingJSON(&result), 571 autorest.ByClosing()) 572 result.Response = autorest.Response{Response: resp} 573 return 574} 575 576// ListQueryResultsForResourceGroup queries policy states for the resources under the resource group. 577// Parameters: 578// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, 579// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). 580// subscriptionID - microsoft Azure subscription ID. 581// resourceGroupName - resource group name. 582// top - maximum number of records to return. 583// orderBy - ordering expression using OData notation. One or more comma-separated column names with an 584// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". 585// selectParameter - select expression using OData notation. Limits the columns on each record to just those 586// requested, e.g. "$select=PolicyAssignmentId, ResourceId". 587// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 588// the service uses ($to - 1-day). 589// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 590// specified, the service uses request time. 591// filter - oData filter expression. 592// apply - oData apply expression for aggregations. 593func (client PolicyStatesClient) ListQueryResultsForResourceGroup(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, resourceGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { 594 if tracing.IsEnabled() { 595 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForResourceGroup") 596 defer func() { 597 sc := -1 598 if result.Response.Response != nil { 599 sc = result.Response.Response.StatusCode 600 } 601 tracing.EndSpan(ctx, sc, err) 602 }() 603 } 604 if err := validation.Validate([]validation.Validation{ 605 {TargetValue: top, 606 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 607 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 608 return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroup", err.Error()) 609 } 610 611 req, err := client.ListQueryResultsForResourceGroupPreparer(ctx, policyStatesResource, subscriptionID, resourceGroupName, top, orderBy, selectParameter, from, toParameter, filter, apply) 612 if err != nil { 613 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroup", nil, "Failure preparing request") 614 return 615 } 616 617 resp, err := client.ListQueryResultsForResourceGroupSender(req) 618 if err != nil { 619 result.Response = autorest.Response{Response: resp} 620 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroup", resp, "Failure sending request") 621 return 622 } 623 624 result, err = client.ListQueryResultsForResourceGroupResponder(resp) 625 if err != nil { 626 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroup", resp, "Failure responding to request") 627 return 628 } 629 630 return 631} 632 633// ListQueryResultsForResourceGroupPreparer prepares the ListQueryResultsForResourceGroup request. 634func (client PolicyStatesClient) ListQueryResultsForResourceGroupPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, resourceGroupName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { 635 pathParameters := map[string]interface{}{ 636 "policyStatesResource": autorest.Encode("path", policyStatesResource), 637 "resourceGroupName": autorest.Encode("path", resourceGroupName), 638 "subscriptionId": autorest.Encode("path", subscriptionID), 639 } 640 641 const APIVersion = "2018-04-04" 642 queryParameters := map[string]interface{}{ 643 "api-version": APIVersion, 644 } 645 if top != nil { 646 queryParameters["$top"] = autorest.Encode("query", *top) 647 } 648 if len(orderBy) > 0 { 649 queryParameters["$orderby"] = autorest.Encode("query", orderBy) 650 } 651 if len(selectParameter) > 0 { 652 queryParameters["$select"] = autorest.Encode("query", selectParameter) 653 } 654 if from != nil { 655 queryParameters["$from"] = autorest.Encode("query", *from) 656 } 657 if toParameter != nil { 658 queryParameters["$to"] = autorest.Encode("query", *toParameter) 659 } 660 if len(filter) > 0 { 661 queryParameters["$filter"] = autorest.Encode("query", filter) 662 } 663 if len(apply) > 0 { 664 queryParameters["$apply"] = autorest.Encode("query", apply) 665 } 666 667 preparer := autorest.CreatePreparer( 668 autorest.AsPost(), 669 autorest.WithBaseURL(client.BaseURI), 670 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), 671 autorest.WithQueryParameters(queryParameters)) 672 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 673} 674 675// ListQueryResultsForResourceGroupSender sends the ListQueryResultsForResourceGroup request. The method will close the 676// http.Response Body if it receives an error. 677func (client PolicyStatesClient) ListQueryResultsForResourceGroupSender(req *http.Request) (*http.Response, error) { 678 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 679} 680 681// ListQueryResultsForResourceGroupResponder handles the response to the ListQueryResultsForResourceGroup request. The method always 682// closes the http.Response Body. 683func (client PolicyStatesClient) ListQueryResultsForResourceGroupResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { 684 err = autorest.Respond( 685 resp, 686 azure.WithErrorUnlessStatusCode(http.StatusOK), 687 autorest.ByUnmarshallingJSON(&result), 688 autorest.ByClosing()) 689 result.Response = autorest.Response{Response: resp} 690 return 691} 692 693// ListQueryResultsForResourceGroupLevelPolicyAssignment queries policy states for the resource group level policy 694// assignment. 695// Parameters: 696// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, 697// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). 698// subscriptionID - microsoft Azure subscription ID. 699// resourceGroupName - resource group name. 700// policyAssignmentName - policy assignment name. 701// top - maximum number of records to return. 702// orderBy - ordering expression using OData notation. One or more comma-separated column names with an 703// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". 704// selectParameter - select expression using OData notation. Limits the columns on each record to just those 705// requested, e.g. "$select=PolicyAssignmentId, ResourceId". 706// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 707// the service uses ($to - 1-day). 708// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 709// specified, the service uses request time. 710// filter - oData filter expression. 711// apply - oData apply expression for aggregations. 712func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignment(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, resourceGroupName string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { 713 if tracing.IsEnabled() { 714 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForResourceGroupLevelPolicyAssignment") 715 defer func() { 716 sc := -1 717 if result.Response.Response != nil { 718 sc = result.Response.Response.StatusCode 719 } 720 tracing.EndSpan(ctx, sc, err) 721 }() 722 } 723 if err := validation.Validate([]validation.Validation{ 724 {TargetValue: top, 725 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 726 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 727 return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", err.Error()) 728 } 729 730 req, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentPreparer(ctx, policyStatesResource, subscriptionID, resourceGroupName, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply) 731 if err != nil { 732 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", nil, "Failure preparing request") 733 return 734 } 735 736 resp, err := client.ListQueryResultsForResourceGroupLevelPolicyAssignmentSender(req) 737 if err != nil { 738 result.Response = autorest.Response{Response: resp} 739 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", resp, "Failure sending request") 740 return 741 } 742 743 result, err = client.ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder(resp) 744 if err != nil { 745 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForResourceGroupLevelPolicyAssignment", resp, "Failure responding to request") 746 return 747 } 748 749 return 750} 751 752// ListQueryResultsForResourceGroupLevelPolicyAssignmentPreparer prepares the ListQueryResultsForResourceGroupLevelPolicyAssignment request. 753func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, resourceGroupName string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { 754 pathParameters := map[string]interface{}{ 755 "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), 756 "policyAssignmentName": autorest.Encode("path", policyAssignmentName), 757 "policyStatesResource": autorest.Encode("path", policyStatesResource), 758 "resourceGroupName": autorest.Encode("path", resourceGroupName), 759 "subscriptionId": autorest.Encode("path", subscriptionID), 760 } 761 762 const APIVersion = "2018-04-04" 763 queryParameters := map[string]interface{}{ 764 "api-version": APIVersion, 765 } 766 if top != nil { 767 queryParameters["$top"] = autorest.Encode("query", *top) 768 } 769 if len(orderBy) > 0 { 770 queryParameters["$orderby"] = autorest.Encode("query", orderBy) 771 } 772 if len(selectParameter) > 0 { 773 queryParameters["$select"] = autorest.Encode("query", selectParameter) 774 } 775 if from != nil { 776 queryParameters["$from"] = autorest.Encode("query", *from) 777 } 778 if toParameter != nil { 779 queryParameters["$to"] = autorest.Encode("query", *toParameter) 780 } 781 if len(filter) > 0 { 782 queryParameters["$filter"] = autorest.Encode("query", filter) 783 } 784 if len(apply) > 0 { 785 queryParameters["$apply"] = autorest.Encode("query", apply) 786 } 787 788 preparer := autorest.CreatePreparer( 789 autorest.AsPost(), 790 autorest.WithBaseURL(client.BaseURI), 791 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), 792 autorest.WithQueryParameters(queryParameters)) 793 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 794} 795 796// ListQueryResultsForResourceGroupLevelPolicyAssignmentSender sends the ListQueryResultsForResourceGroupLevelPolicyAssignment request. The method will close the 797// http.Response Body if it receives an error. 798func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentSender(req *http.Request) (*http.Response, error) { 799 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 800} 801 802// ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder handles the response to the ListQueryResultsForResourceGroupLevelPolicyAssignment request. The method always 803// closes the http.Response Body. 804func (client PolicyStatesClient) ListQueryResultsForResourceGroupLevelPolicyAssignmentResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { 805 err = autorest.Respond( 806 resp, 807 azure.WithErrorUnlessStatusCode(http.StatusOK), 808 autorest.ByUnmarshallingJSON(&result), 809 autorest.ByClosing()) 810 result.Response = autorest.Response{Response: resp} 811 return 812} 813 814// ListQueryResultsForSubscription queries policy states for the resources under the subscription. 815// Parameters: 816// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, 817// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). 818// subscriptionID - microsoft Azure subscription ID. 819// top - maximum number of records to return. 820// orderBy - ordering expression using OData notation. One or more comma-separated column names with an 821// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". 822// selectParameter - select expression using OData notation. Limits the columns on each record to just those 823// requested, e.g. "$select=PolicyAssignmentId, ResourceId". 824// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 825// the service uses ($to - 1-day). 826// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 827// specified, the service uses request time. 828// filter - oData filter expression. 829// apply - oData apply expression for aggregations. 830func (client PolicyStatesClient) ListQueryResultsForSubscription(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { 831 if tracing.IsEnabled() { 832 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForSubscription") 833 defer func() { 834 sc := -1 835 if result.Response.Response != nil { 836 sc = result.Response.Response.StatusCode 837 } 838 tracing.EndSpan(ctx, sc, err) 839 }() 840 } 841 if err := validation.Validate([]validation.Validation{ 842 {TargetValue: top, 843 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 844 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 845 return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForSubscription", err.Error()) 846 } 847 848 req, err := client.ListQueryResultsForSubscriptionPreparer(ctx, policyStatesResource, subscriptionID, top, orderBy, selectParameter, from, toParameter, filter, apply) 849 if err != nil { 850 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscription", nil, "Failure preparing request") 851 return 852 } 853 854 resp, err := client.ListQueryResultsForSubscriptionSender(req) 855 if err != nil { 856 result.Response = autorest.Response{Response: resp} 857 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscription", resp, "Failure sending request") 858 return 859 } 860 861 result, err = client.ListQueryResultsForSubscriptionResponder(resp) 862 if err != nil { 863 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscription", resp, "Failure responding to request") 864 return 865 } 866 867 return 868} 869 870// ListQueryResultsForSubscriptionPreparer prepares the ListQueryResultsForSubscription request. 871func (client PolicyStatesClient) ListQueryResultsForSubscriptionPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { 872 pathParameters := map[string]interface{}{ 873 "policyStatesResource": autorest.Encode("path", policyStatesResource), 874 "subscriptionId": autorest.Encode("path", subscriptionID), 875 } 876 877 const APIVersion = "2018-04-04" 878 queryParameters := map[string]interface{}{ 879 "api-version": APIVersion, 880 } 881 if top != nil { 882 queryParameters["$top"] = autorest.Encode("query", *top) 883 } 884 if len(orderBy) > 0 { 885 queryParameters["$orderby"] = autorest.Encode("query", orderBy) 886 } 887 if len(selectParameter) > 0 { 888 queryParameters["$select"] = autorest.Encode("query", selectParameter) 889 } 890 if from != nil { 891 queryParameters["$from"] = autorest.Encode("query", *from) 892 } 893 if toParameter != nil { 894 queryParameters["$to"] = autorest.Encode("query", *toParameter) 895 } 896 if len(filter) > 0 { 897 queryParameters["$filter"] = autorest.Encode("query", filter) 898 } 899 if len(apply) > 0 { 900 queryParameters["$apply"] = autorest.Encode("query", apply) 901 } 902 903 preparer := autorest.CreatePreparer( 904 autorest.AsPost(), 905 autorest.WithBaseURL(client.BaseURI), 906 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), 907 autorest.WithQueryParameters(queryParameters)) 908 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 909} 910 911// ListQueryResultsForSubscriptionSender sends the ListQueryResultsForSubscription request. The method will close the 912// http.Response Body if it receives an error. 913func (client PolicyStatesClient) ListQueryResultsForSubscriptionSender(req *http.Request) (*http.Response, error) { 914 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 915} 916 917// ListQueryResultsForSubscriptionResponder handles the response to the ListQueryResultsForSubscription request. The method always 918// closes the http.Response Body. 919func (client PolicyStatesClient) ListQueryResultsForSubscriptionResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { 920 err = autorest.Respond( 921 resp, 922 azure.WithErrorUnlessStatusCode(http.StatusOK), 923 autorest.ByUnmarshallingJSON(&result), 924 autorest.ByClosing()) 925 result.Response = autorest.Response{Response: resp} 926 return 927} 928 929// ListQueryResultsForSubscriptionLevelPolicyAssignment queries policy states for the subscription level policy 930// assignment. 931// Parameters: 932// policyStatesResource - the virtual resource under PolicyStates resource type. In a given time range, 933// 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). 934// subscriptionID - microsoft Azure subscription ID. 935// policyAssignmentName - policy assignment name. 936// top - maximum number of records to return. 937// orderBy - ordering expression using OData notation. One or more comma-separated column names with an 938// optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, ResourceId asc". 939// selectParameter - select expression using OData notation. Limits the columns on each record to just those 940// requested, e.g. "$select=PolicyAssignmentId, ResourceId". 941// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 942// the service uses ($to - 1-day). 943// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 944// specified, the service uses request time. 945// filter - oData filter expression. 946// apply - oData apply expression for aggregations. 947func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignment(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (result PolicyStatesQueryResults, err error) { 948 if tracing.IsEnabled() { 949 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.ListQueryResultsForSubscriptionLevelPolicyAssignment") 950 defer func() { 951 sc := -1 952 if result.Response.Response != nil { 953 sc = result.Response.Response.StatusCode 954 } 955 tracing.EndSpan(ctx, sc, err) 956 }() 957 } 958 if err := validation.Validate([]validation.Validation{ 959 {TargetValue: top, 960 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 961 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 962 return result, validation.NewError("policyinsights.PolicyStatesClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", err.Error()) 963 } 964 965 req, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentPreparer(ctx, policyStatesResource, subscriptionID, policyAssignmentName, top, orderBy, selectParameter, from, toParameter, filter, apply) 966 if err != nil { 967 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", nil, "Failure preparing request") 968 return 969 } 970 971 resp, err := client.ListQueryResultsForSubscriptionLevelPolicyAssignmentSender(req) 972 if err != nil { 973 result.Response = autorest.Response{Response: resp} 974 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", resp, "Failure sending request") 975 return 976 } 977 978 result, err = client.ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder(resp) 979 if err != nil { 980 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "ListQueryResultsForSubscriptionLevelPolicyAssignment", resp, "Failure responding to request") 981 return 982 } 983 984 return 985} 986 987// ListQueryResultsForSubscriptionLevelPolicyAssignmentPreparer prepares the ListQueryResultsForSubscriptionLevelPolicyAssignment request. 988func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentPreparer(ctx context.Context, policyStatesResource PolicyStatesResource, subscriptionID string, policyAssignmentName string, top *int32, orderBy string, selectParameter string, from *date.Time, toParameter *date.Time, filter string, apply string) (*http.Request, error) { 989 pathParameters := map[string]interface{}{ 990 "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), 991 "policyAssignmentName": autorest.Encode("path", policyAssignmentName), 992 "policyStatesResource": autorest.Encode("path", policyStatesResource), 993 "subscriptionId": autorest.Encode("path", subscriptionID), 994 } 995 996 const APIVersion = "2018-04-04" 997 queryParameters := map[string]interface{}{ 998 "api-version": APIVersion, 999 } 1000 if top != nil { 1001 queryParameters["$top"] = autorest.Encode("query", *top) 1002 } 1003 if len(orderBy) > 0 { 1004 queryParameters["$orderby"] = autorest.Encode("query", orderBy) 1005 } 1006 if len(selectParameter) > 0 { 1007 queryParameters["$select"] = autorest.Encode("query", selectParameter) 1008 } 1009 if from != nil { 1010 queryParameters["$from"] = autorest.Encode("query", *from) 1011 } 1012 if toParameter != nil { 1013 queryParameters["$to"] = autorest.Encode("query", *toParameter) 1014 } 1015 if len(filter) > 0 { 1016 queryParameters["$filter"] = autorest.Encode("query", filter) 1017 } 1018 if len(apply) > 0 { 1019 queryParameters["$apply"] = autorest.Encode("query", apply) 1020 } 1021 1022 preparer := autorest.CreatePreparer( 1023 autorest.AsPost(), 1024 autorest.WithBaseURL(client.BaseURI), 1025 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", pathParameters), 1026 autorest.WithQueryParameters(queryParameters)) 1027 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1028} 1029 1030// ListQueryResultsForSubscriptionLevelPolicyAssignmentSender sends the ListQueryResultsForSubscriptionLevelPolicyAssignment request. The method will close the 1031// http.Response Body if it receives an error. 1032func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentSender(req *http.Request) (*http.Response, error) { 1033 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1034} 1035 1036// ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder handles the response to the ListQueryResultsForSubscriptionLevelPolicyAssignment request. The method always 1037// closes the http.Response Body. 1038func (client PolicyStatesClient) ListQueryResultsForSubscriptionLevelPolicyAssignmentResponder(resp *http.Response) (result PolicyStatesQueryResults, err error) { 1039 err = autorest.Respond( 1040 resp, 1041 azure.WithErrorUnlessStatusCode(http.StatusOK), 1042 autorest.ByUnmarshallingJSON(&result), 1043 autorest.ByClosing()) 1044 result.Response = autorest.Response{Response: resp} 1045 return 1046} 1047 1048// SummarizeForManagementGroup summarizes policy states for the resources under the management group. 1049// Parameters: 1050// managementGroupName - management group name. 1051// top - maximum number of records to return. 1052// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 1053// the service uses ($to - 1-day). 1054// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 1055// specified, the service uses request time. 1056// filter - oData filter expression. 1057func (client PolicyStatesClient) SummarizeForManagementGroup(ctx context.Context, managementGroupName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { 1058 if tracing.IsEnabled() { 1059 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForManagementGroup") 1060 defer func() { 1061 sc := -1 1062 if result.Response.Response != nil { 1063 sc = result.Response.Response.StatusCode 1064 } 1065 tracing.EndSpan(ctx, sc, err) 1066 }() 1067 } 1068 if err := validation.Validate([]validation.Validation{ 1069 {TargetValue: top, 1070 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1071 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 1072 return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForManagementGroup", err.Error()) 1073 } 1074 1075 req, err := client.SummarizeForManagementGroupPreparer(ctx, managementGroupName, top, from, toParameter, filter) 1076 if err != nil { 1077 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForManagementGroup", nil, "Failure preparing request") 1078 return 1079 } 1080 1081 resp, err := client.SummarizeForManagementGroupSender(req) 1082 if err != nil { 1083 result.Response = autorest.Response{Response: resp} 1084 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForManagementGroup", resp, "Failure sending request") 1085 return 1086 } 1087 1088 result, err = client.SummarizeForManagementGroupResponder(resp) 1089 if err != nil { 1090 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForManagementGroup", resp, "Failure responding to request") 1091 return 1092 } 1093 1094 return 1095} 1096 1097// SummarizeForManagementGroupPreparer prepares the SummarizeForManagementGroup request. 1098func (client PolicyStatesClient) SummarizeForManagementGroupPreparer(ctx context.Context, managementGroupName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { 1099 pathParameters := map[string]interface{}{ 1100 "managementGroupName": autorest.Encode("path", managementGroupName), 1101 "managementGroupsNamespace": autorest.Encode("path", "Microsoft.Management"), 1102 "policyStatesSummaryResource": autorest.Encode("path", "latest"), 1103 } 1104 1105 const APIVersion = "2018-04-04" 1106 queryParameters := map[string]interface{}{ 1107 "api-version": APIVersion, 1108 } 1109 if top != nil { 1110 queryParameters["$top"] = autorest.Encode("query", *top) 1111 } 1112 if from != nil { 1113 queryParameters["$from"] = autorest.Encode("query", *from) 1114 } 1115 if toParameter != nil { 1116 queryParameters["$to"] = autorest.Encode("query", *toParameter) 1117 } 1118 if len(filter) > 0 { 1119 queryParameters["$filter"] = autorest.Encode("query", filter) 1120 } 1121 1122 preparer := autorest.CreatePreparer( 1123 autorest.AsPost(), 1124 autorest.WithBaseURL(client.BaseURI), 1125 autorest.WithPathParameters("/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), 1126 autorest.WithQueryParameters(queryParameters)) 1127 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1128} 1129 1130// SummarizeForManagementGroupSender sends the SummarizeForManagementGroup request. The method will close the 1131// http.Response Body if it receives an error. 1132func (client PolicyStatesClient) SummarizeForManagementGroupSender(req *http.Request) (*http.Response, error) { 1133 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1134} 1135 1136// SummarizeForManagementGroupResponder handles the response to the SummarizeForManagementGroup request. The method always 1137// closes the http.Response Body. 1138func (client PolicyStatesClient) SummarizeForManagementGroupResponder(resp *http.Response) (result SummarizeResults, err error) { 1139 err = autorest.Respond( 1140 resp, 1141 azure.WithErrorUnlessStatusCode(http.StatusOK), 1142 autorest.ByUnmarshallingJSON(&result), 1143 autorest.ByClosing()) 1144 result.Response = autorest.Response{Response: resp} 1145 return 1146} 1147 1148// SummarizeForPolicyDefinition summarizes policy states for the subscription level policy definition. 1149// Parameters: 1150// subscriptionID - microsoft Azure subscription ID. 1151// policyDefinitionName - policy definition name. 1152// top - maximum number of records to return. 1153// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 1154// the service uses ($to - 1-day). 1155// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 1156// specified, the service uses request time. 1157// filter - oData filter expression. 1158func (client PolicyStatesClient) SummarizeForPolicyDefinition(ctx context.Context, subscriptionID string, policyDefinitionName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { 1159 if tracing.IsEnabled() { 1160 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForPolicyDefinition") 1161 defer func() { 1162 sc := -1 1163 if result.Response.Response != nil { 1164 sc = result.Response.Response.StatusCode 1165 } 1166 tracing.EndSpan(ctx, sc, err) 1167 }() 1168 } 1169 if err := validation.Validate([]validation.Validation{ 1170 {TargetValue: top, 1171 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1172 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 1173 return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForPolicyDefinition", err.Error()) 1174 } 1175 1176 req, err := client.SummarizeForPolicyDefinitionPreparer(ctx, subscriptionID, policyDefinitionName, top, from, toParameter, filter) 1177 if err != nil { 1178 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForPolicyDefinition", nil, "Failure preparing request") 1179 return 1180 } 1181 1182 resp, err := client.SummarizeForPolicyDefinitionSender(req) 1183 if err != nil { 1184 result.Response = autorest.Response{Response: resp} 1185 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForPolicyDefinition", resp, "Failure sending request") 1186 return 1187 } 1188 1189 result, err = client.SummarizeForPolicyDefinitionResponder(resp) 1190 if err != nil { 1191 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForPolicyDefinition", resp, "Failure responding to request") 1192 return 1193 } 1194 1195 return 1196} 1197 1198// SummarizeForPolicyDefinitionPreparer prepares the SummarizeForPolicyDefinition request. 1199func (client PolicyStatesClient) SummarizeForPolicyDefinitionPreparer(ctx context.Context, subscriptionID string, policyDefinitionName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { 1200 pathParameters := map[string]interface{}{ 1201 "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), 1202 "policyDefinitionName": autorest.Encode("path", policyDefinitionName), 1203 "policyStatesSummaryResource": autorest.Encode("path", "latest"), 1204 "subscriptionId": autorest.Encode("path", subscriptionID), 1205 } 1206 1207 const APIVersion = "2018-04-04" 1208 queryParameters := map[string]interface{}{ 1209 "api-version": APIVersion, 1210 } 1211 if top != nil { 1212 queryParameters["$top"] = autorest.Encode("query", *top) 1213 } 1214 if from != nil { 1215 queryParameters["$from"] = autorest.Encode("query", *from) 1216 } 1217 if toParameter != nil { 1218 queryParameters["$to"] = autorest.Encode("query", *toParameter) 1219 } 1220 if len(filter) > 0 { 1221 queryParameters["$filter"] = autorest.Encode("query", filter) 1222 } 1223 1224 preparer := autorest.CreatePreparer( 1225 autorest.AsPost(), 1226 autorest.WithBaseURL(client.BaseURI), 1227 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), 1228 autorest.WithQueryParameters(queryParameters)) 1229 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1230} 1231 1232// SummarizeForPolicyDefinitionSender sends the SummarizeForPolicyDefinition request. The method will close the 1233// http.Response Body if it receives an error. 1234func (client PolicyStatesClient) SummarizeForPolicyDefinitionSender(req *http.Request) (*http.Response, error) { 1235 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1236} 1237 1238// SummarizeForPolicyDefinitionResponder handles the response to the SummarizeForPolicyDefinition request. The method always 1239// closes the http.Response Body. 1240func (client PolicyStatesClient) SummarizeForPolicyDefinitionResponder(resp *http.Response) (result SummarizeResults, err error) { 1241 err = autorest.Respond( 1242 resp, 1243 azure.WithErrorUnlessStatusCode(http.StatusOK), 1244 autorest.ByUnmarshallingJSON(&result), 1245 autorest.ByClosing()) 1246 result.Response = autorest.Response{Response: resp} 1247 return 1248} 1249 1250// SummarizeForPolicySetDefinition summarizes policy states for the subscription level policy set definition. 1251// Parameters: 1252// subscriptionID - microsoft Azure subscription ID. 1253// policySetDefinitionName - policy set definition name. 1254// top - maximum number of records to return. 1255// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 1256// the service uses ($to - 1-day). 1257// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 1258// specified, the service uses request time. 1259// filter - oData filter expression. 1260func (client PolicyStatesClient) SummarizeForPolicySetDefinition(ctx context.Context, subscriptionID string, policySetDefinitionName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { 1261 if tracing.IsEnabled() { 1262 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForPolicySetDefinition") 1263 defer func() { 1264 sc := -1 1265 if result.Response.Response != nil { 1266 sc = result.Response.Response.StatusCode 1267 } 1268 tracing.EndSpan(ctx, sc, err) 1269 }() 1270 } 1271 if err := validation.Validate([]validation.Validation{ 1272 {TargetValue: top, 1273 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1274 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 1275 return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForPolicySetDefinition", err.Error()) 1276 } 1277 1278 req, err := client.SummarizeForPolicySetDefinitionPreparer(ctx, subscriptionID, policySetDefinitionName, top, from, toParameter, filter) 1279 if err != nil { 1280 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForPolicySetDefinition", nil, "Failure preparing request") 1281 return 1282 } 1283 1284 resp, err := client.SummarizeForPolicySetDefinitionSender(req) 1285 if err != nil { 1286 result.Response = autorest.Response{Response: resp} 1287 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForPolicySetDefinition", resp, "Failure sending request") 1288 return 1289 } 1290 1291 result, err = client.SummarizeForPolicySetDefinitionResponder(resp) 1292 if err != nil { 1293 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForPolicySetDefinition", resp, "Failure responding to request") 1294 return 1295 } 1296 1297 return 1298} 1299 1300// SummarizeForPolicySetDefinitionPreparer prepares the SummarizeForPolicySetDefinition request. 1301func (client PolicyStatesClient) SummarizeForPolicySetDefinitionPreparer(ctx context.Context, subscriptionID string, policySetDefinitionName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { 1302 pathParameters := map[string]interface{}{ 1303 "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), 1304 "policySetDefinitionName": autorest.Encode("path", policySetDefinitionName), 1305 "policyStatesSummaryResource": autorest.Encode("path", "latest"), 1306 "subscriptionId": autorest.Encode("path", subscriptionID), 1307 } 1308 1309 const APIVersion = "2018-04-04" 1310 queryParameters := map[string]interface{}{ 1311 "api-version": APIVersion, 1312 } 1313 if top != nil { 1314 queryParameters["$top"] = autorest.Encode("query", *top) 1315 } 1316 if from != nil { 1317 queryParameters["$from"] = autorest.Encode("query", *from) 1318 } 1319 if toParameter != nil { 1320 queryParameters["$to"] = autorest.Encode("query", *toParameter) 1321 } 1322 if len(filter) > 0 { 1323 queryParameters["$filter"] = autorest.Encode("query", filter) 1324 } 1325 1326 preparer := autorest.CreatePreparer( 1327 autorest.AsPost(), 1328 autorest.WithBaseURL(client.BaseURI), 1329 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), 1330 autorest.WithQueryParameters(queryParameters)) 1331 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1332} 1333 1334// SummarizeForPolicySetDefinitionSender sends the SummarizeForPolicySetDefinition request. The method will close the 1335// http.Response Body if it receives an error. 1336func (client PolicyStatesClient) SummarizeForPolicySetDefinitionSender(req *http.Request) (*http.Response, error) { 1337 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1338} 1339 1340// SummarizeForPolicySetDefinitionResponder handles the response to the SummarizeForPolicySetDefinition request. The method always 1341// closes the http.Response Body. 1342func (client PolicyStatesClient) SummarizeForPolicySetDefinitionResponder(resp *http.Response) (result SummarizeResults, err error) { 1343 err = autorest.Respond( 1344 resp, 1345 azure.WithErrorUnlessStatusCode(http.StatusOK), 1346 autorest.ByUnmarshallingJSON(&result), 1347 autorest.ByClosing()) 1348 result.Response = autorest.Response{Response: resp} 1349 return 1350} 1351 1352// SummarizeForResource summarizes policy states for the resource. 1353// Parameters: 1354// resourceID - resource ID. 1355// top - maximum number of records to return. 1356// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 1357// the service uses ($to - 1-day). 1358// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 1359// specified, the service uses request time. 1360// filter - oData filter expression. 1361func (client PolicyStatesClient) SummarizeForResource(ctx context.Context, resourceID string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { 1362 if tracing.IsEnabled() { 1363 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForResource") 1364 defer func() { 1365 sc := -1 1366 if result.Response.Response != nil { 1367 sc = result.Response.Response.StatusCode 1368 } 1369 tracing.EndSpan(ctx, sc, err) 1370 }() 1371 } 1372 if err := validation.Validate([]validation.Validation{ 1373 {TargetValue: top, 1374 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1375 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 1376 return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForResource", err.Error()) 1377 } 1378 1379 req, err := client.SummarizeForResourcePreparer(ctx, resourceID, top, from, toParameter, filter) 1380 if err != nil { 1381 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResource", nil, "Failure preparing request") 1382 return 1383 } 1384 1385 resp, err := client.SummarizeForResourceSender(req) 1386 if err != nil { 1387 result.Response = autorest.Response{Response: resp} 1388 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResource", resp, "Failure sending request") 1389 return 1390 } 1391 1392 result, err = client.SummarizeForResourceResponder(resp) 1393 if err != nil { 1394 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResource", resp, "Failure responding to request") 1395 return 1396 } 1397 1398 return 1399} 1400 1401// SummarizeForResourcePreparer prepares the SummarizeForResource request. 1402func (client PolicyStatesClient) SummarizeForResourcePreparer(ctx context.Context, resourceID string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { 1403 pathParameters := map[string]interface{}{ 1404 "policyStatesSummaryResource": autorest.Encode("path", "latest"), 1405 "resourceId": resourceID, 1406 } 1407 1408 const APIVersion = "2018-04-04" 1409 queryParameters := map[string]interface{}{ 1410 "api-version": APIVersion, 1411 } 1412 if top != nil { 1413 queryParameters["$top"] = autorest.Encode("query", *top) 1414 } 1415 if from != nil { 1416 queryParameters["$from"] = autorest.Encode("query", *from) 1417 } 1418 if toParameter != nil { 1419 queryParameters["$to"] = autorest.Encode("query", *toParameter) 1420 } 1421 if len(filter) > 0 { 1422 queryParameters["$filter"] = autorest.Encode("query", filter) 1423 } 1424 1425 preparer := autorest.CreatePreparer( 1426 autorest.AsPost(), 1427 autorest.WithBaseURL(client.BaseURI), 1428 autorest.WithPathParameters("/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), 1429 autorest.WithQueryParameters(queryParameters)) 1430 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1431} 1432 1433// SummarizeForResourceSender sends the SummarizeForResource request. The method will close the 1434// http.Response Body if it receives an error. 1435func (client PolicyStatesClient) SummarizeForResourceSender(req *http.Request) (*http.Response, error) { 1436 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1437} 1438 1439// SummarizeForResourceResponder handles the response to the SummarizeForResource request. The method always 1440// closes the http.Response Body. 1441func (client PolicyStatesClient) SummarizeForResourceResponder(resp *http.Response) (result SummarizeResults, err error) { 1442 err = autorest.Respond( 1443 resp, 1444 azure.WithErrorUnlessStatusCode(http.StatusOK), 1445 autorest.ByUnmarshallingJSON(&result), 1446 autorest.ByClosing()) 1447 result.Response = autorest.Response{Response: resp} 1448 return 1449} 1450 1451// SummarizeForResourceGroup summarizes policy states for the resources under the resource group. 1452// Parameters: 1453// subscriptionID - microsoft Azure subscription ID. 1454// resourceGroupName - resource group name. 1455// top - maximum number of records to return. 1456// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 1457// the service uses ($to - 1-day). 1458// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 1459// specified, the service uses request time. 1460// filter - oData filter expression. 1461func (client PolicyStatesClient) SummarizeForResourceGroup(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { 1462 if tracing.IsEnabled() { 1463 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForResourceGroup") 1464 defer func() { 1465 sc := -1 1466 if result.Response.Response != nil { 1467 sc = result.Response.Response.StatusCode 1468 } 1469 tracing.EndSpan(ctx, sc, err) 1470 }() 1471 } 1472 if err := validation.Validate([]validation.Validation{ 1473 {TargetValue: top, 1474 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1475 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 1476 return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForResourceGroup", err.Error()) 1477 } 1478 1479 req, err := client.SummarizeForResourceGroupPreparer(ctx, subscriptionID, resourceGroupName, top, from, toParameter, filter) 1480 if err != nil { 1481 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResourceGroup", nil, "Failure preparing request") 1482 return 1483 } 1484 1485 resp, err := client.SummarizeForResourceGroupSender(req) 1486 if err != nil { 1487 result.Response = autorest.Response{Response: resp} 1488 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResourceGroup", resp, "Failure sending request") 1489 return 1490 } 1491 1492 result, err = client.SummarizeForResourceGroupResponder(resp) 1493 if err != nil { 1494 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResourceGroup", resp, "Failure responding to request") 1495 return 1496 } 1497 1498 return 1499} 1500 1501// SummarizeForResourceGroupPreparer prepares the SummarizeForResourceGroup request. 1502func (client PolicyStatesClient) SummarizeForResourceGroupPreparer(ctx context.Context, subscriptionID string, resourceGroupName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { 1503 pathParameters := map[string]interface{}{ 1504 "policyStatesSummaryResource": autorest.Encode("path", "latest"), 1505 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1506 "subscriptionId": autorest.Encode("path", subscriptionID), 1507 } 1508 1509 const APIVersion = "2018-04-04" 1510 queryParameters := map[string]interface{}{ 1511 "api-version": APIVersion, 1512 } 1513 if top != nil { 1514 queryParameters["$top"] = autorest.Encode("query", *top) 1515 } 1516 if from != nil { 1517 queryParameters["$from"] = autorest.Encode("query", *from) 1518 } 1519 if toParameter != nil { 1520 queryParameters["$to"] = autorest.Encode("query", *toParameter) 1521 } 1522 if len(filter) > 0 { 1523 queryParameters["$filter"] = autorest.Encode("query", filter) 1524 } 1525 1526 preparer := autorest.CreatePreparer( 1527 autorest.AsPost(), 1528 autorest.WithBaseURL(client.BaseURI), 1529 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), 1530 autorest.WithQueryParameters(queryParameters)) 1531 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1532} 1533 1534// SummarizeForResourceGroupSender sends the SummarizeForResourceGroup request. The method will close the 1535// http.Response Body if it receives an error. 1536func (client PolicyStatesClient) SummarizeForResourceGroupSender(req *http.Request) (*http.Response, error) { 1537 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1538} 1539 1540// SummarizeForResourceGroupResponder handles the response to the SummarizeForResourceGroup request. The method always 1541// closes the http.Response Body. 1542func (client PolicyStatesClient) SummarizeForResourceGroupResponder(resp *http.Response) (result SummarizeResults, err error) { 1543 err = autorest.Respond( 1544 resp, 1545 azure.WithErrorUnlessStatusCode(http.StatusOK), 1546 autorest.ByUnmarshallingJSON(&result), 1547 autorest.ByClosing()) 1548 result.Response = autorest.Response{Response: resp} 1549 return 1550} 1551 1552// SummarizeForResourceGroupLevelPolicyAssignment summarizes policy states for the resource group level policy 1553// assignment. 1554// Parameters: 1555// subscriptionID - microsoft Azure subscription ID. 1556// resourceGroupName - resource group name. 1557// policyAssignmentName - policy assignment name. 1558// top - maximum number of records to return. 1559// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 1560// the service uses ($to - 1-day). 1561// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 1562// specified, the service uses request time. 1563// filter - oData filter expression. 1564func (client PolicyStatesClient) SummarizeForResourceGroupLevelPolicyAssignment(ctx context.Context, subscriptionID string, resourceGroupName string, policyAssignmentName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { 1565 if tracing.IsEnabled() { 1566 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForResourceGroupLevelPolicyAssignment") 1567 defer func() { 1568 sc := -1 1569 if result.Response.Response != nil { 1570 sc = result.Response.Response.StatusCode 1571 } 1572 tracing.EndSpan(ctx, sc, err) 1573 }() 1574 } 1575 if err := validation.Validate([]validation.Validation{ 1576 {TargetValue: top, 1577 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1578 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 1579 return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForResourceGroupLevelPolicyAssignment", err.Error()) 1580 } 1581 1582 req, err := client.SummarizeForResourceGroupLevelPolicyAssignmentPreparer(ctx, subscriptionID, resourceGroupName, policyAssignmentName, top, from, toParameter, filter) 1583 if err != nil { 1584 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResourceGroupLevelPolicyAssignment", nil, "Failure preparing request") 1585 return 1586 } 1587 1588 resp, err := client.SummarizeForResourceGroupLevelPolicyAssignmentSender(req) 1589 if err != nil { 1590 result.Response = autorest.Response{Response: resp} 1591 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResourceGroupLevelPolicyAssignment", resp, "Failure sending request") 1592 return 1593 } 1594 1595 result, err = client.SummarizeForResourceGroupLevelPolicyAssignmentResponder(resp) 1596 if err != nil { 1597 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForResourceGroupLevelPolicyAssignment", resp, "Failure responding to request") 1598 return 1599 } 1600 1601 return 1602} 1603 1604// SummarizeForResourceGroupLevelPolicyAssignmentPreparer prepares the SummarizeForResourceGroupLevelPolicyAssignment request. 1605func (client PolicyStatesClient) SummarizeForResourceGroupLevelPolicyAssignmentPreparer(ctx context.Context, subscriptionID string, resourceGroupName string, policyAssignmentName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { 1606 pathParameters := map[string]interface{}{ 1607 "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), 1608 "policyAssignmentName": autorest.Encode("path", policyAssignmentName), 1609 "policyStatesSummaryResource": autorest.Encode("path", "latest"), 1610 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1611 "subscriptionId": autorest.Encode("path", subscriptionID), 1612 } 1613 1614 const APIVersion = "2018-04-04" 1615 queryParameters := map[string]interface{}{ 1616 "api-version": APIVersion, 1617 } 1618 if top != nil { 1619 queryParameters["$top"] = autorest.Encode("query", *top) 1620 } 1621 if from != nil { 1622 queryParameters["$from"] = autorest.Encode("query", *from) 1623 } 1624 if toParameter != nil { 1625 queryParameters["$to"] = autorest.Encode("query", *toParameter) 1626 } 1627 if len(filter) > 0 { 1628 queryParameters["$filter"] = autorest.Encode("query", filter) 1629 } 1630 1631 preparer := autorest.CreatePreparer( 1632 autorest.AsPost(), 1633 autorest.WithBaseURL(client.BaseURI), 1634 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), 1635 autorest.WithQueryParameters(queryParameters)) 1636 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1637} 1638 1639// SummarizeForResourceGroupLevelPolicyAssignmentSender sends the SummarizeForResourceGroupLevelPolicyAssignment request. The method will close the 1640// http.Response Body if it receives an error. 1641func (client PolicyStatesClient) SummarizeForResourceGroupLevelPolicyAssignmentSender(req *http.Request) (*http.Response, error) { 1642 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1643} 1644 1645// SummarizeForResourceGroupLevelPolicyAssignmentResponder handles the response to the SummarizeForResourceGroupLevelPolicyAssignment request. The method always 1646// closes the http.Response Body. 1647func (client PolicyStatesClient) SummarizeForResourceGroupLevelPolicyAssignmentResponder(resp *http.Response) (result SummarizeResults, err error) { 1648 err = autorest.Respond( 1649 resp, 1650 azure.WithErrorUnlessStatusCode(http.StatusOK), 1651 autorest.ByUnmarshallingJSON(&result), 1652 autorest.ByClosing()) 1653 result.Response = autorest.Response{Response: resp} 1654 return 1655} 1656 1657// SummarizeForSubscription summarizes policy states for the resources under the subscription. 1658// Parameters: 1659// subscriptionID - microsoft Azure subscription ID. 1660// top - maximum number of records to return. 1661// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 1662// the service uses ($to - 1-day). 1663// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 1664// specified, the service uses request time. 1665// filter - oData filter expression. 1666func (client PolicyStatesClient) SummarizeForSubscription(ctx context.Context, subscriptionID string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { 1667 if tracing.IsEnabled() { 1668 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForSubscription") 1669 defer func() { 1670 sc := -1 1671 if result.Response.Response != nil { 1672 sc = result.Response.Response.StatusCode 1673 } 1674 tracing.EndSpan(ctx, sc, err) 1675 }() 1676 } 1677 if err := validation.Validate([]validation.Validation{ 1678 {TargetValue: top, 1679 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1680 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 1681 return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForSubscription", err.Error()) 1682 } 1683 1684 req, err := client.SummarizeForSubscriptionPreparer(ctx, subscriptionID, top, from, toParameter, filter) 1685 if err != nil { 1686 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForSubscription", nil, "Failure preparing request") 1687 return 1688 } 1689 1690 resp, err := client.SummarizeForSubscriptionSender(req) 1691 if err != nil { 1692 result.Response = autorest.Response{Response: resp} 1693 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForSubscription", resp, "Failure sending request") 1694 return 1695 } 1696 1697 result, err = client.SummarizeForSubscriptionResponder(resp) 1698 if err != nil { 1699 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForSubscription", resp, "Failure responding to request") 1700 return 1701 } 1702 1703 return 1704} 1705 1706// SummarizeForSubscriptionPreparer prepares the SummarizeForSubscription request. 1707func (client PolicyStatesClient) SummarizeForSubscriptionPreparer(ctx context.Context, subscriptionID string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { 1708 pathParameters := map[string]interface{}{ 1709 "policyStatesSummaryResource": autorest.Encode("path", "latest"), 1710 "subscriptionId": autorest.Encode("path", subscriptionID), 1711 } 1712 1713 const APIVersion = "2018-04-04" 1714 queryParameters := map[string]interface{}{ 1715 "api-version": APIVersion, 1716 } 1717 if top != nil { 1718 queryParameters["$top"] = autorest.Encode("query", *top) 1719 } 1720 if from != nil { 1721 queryParameters["$from"] = autorest.Encode("query", *from) 1722 } 1723 if toParameter != nil { 1724 queryParameters["$to"] = autorest.Encode("query", *toParameter) 1725 } 1726 if len(filter) > 0 { 1727 queryParameters["$filter"] = autorest.Encode("query", filter) 1728 } 1729 1730 preparer := autorest.CreatePreparer( 1731 autorest.AsPost(), 1732 autorest.WithBaseURL(client.BaseURI), 1733 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), 1734 autorest.WithQueryParameters(queryParameters)) 1735 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1736} 1737 1738// SummarizeForSubscriptionSender sends the SummarizeForSubscription request. The method will close the 1739// http.Response Body if it receives an error. 1740func (client PolicyStatesClient) SummarizeForSubscriptionSender(req *http.Request) (*http.Response, error) { 1741 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1742} 1743 1744// SummarizeForSubscriptionResponder handles the response to the SummarizeForSubscription request. The method always 1745// closes the http.Response Body. 1746func (client PolicyStatesClient) SummarizeForSubscriptionResponder(resp *http.Response) (result SummarizeResults, err error) { 1747 err = autorest.Respond( 1748 resp, 1749 azure.WithErrorUnlessStatusCode(http.StatusOK), 1750 autorest.ByUnmarshallingJSON(&result), 1751 autorest.ByClosing()) 1752 result.Response = autorest.Response{Response: resp} 1753 return 1754} 1755 1756// SummarizeForSubscriptionLevelPolicyAssignment summarizes policy states for the subscription level policy assignment. 1757// Parameters: 1758// subscriptionID - microsoft Azure subscription ID. 1759// policyAssignmentName - policy assignment name. 1760// top - maximum number of records to return. 1761// from - ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, 1762// the service uses ($to - 1-day). 1763// toParameter - ISO 8601 formatted timestamp specifying the end time of the interval to query. When not 1764// specified, the service uses request time. 1765// filter - oData filter expression. 1766func (client PolicyStatesClient) SummarizeForSubscriptionLevelPolicyAssignment(ctx context.Context, subscriptionID string, policyAssignmentName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (result SummarizeResults, err error) { 1767 if tracing.IsEnabled() { 1768 ctx = tracing.StartSpan(ctx, fqdn+"/PolicyStatesClient.SummarizeForSubscriptionLevelPolicyAssignment") 1769 defer func() { 1770 sc := -1 1771 if result.Response.Response != nil { 1772 sc = result.Response.Response.StatusCode 1773 } 1774 tracing.EndSpan(ctx, sc, err) 1775 }() 1776 } 1777 if err := validation.Validate([]validation.Validation{ 1778 {TargetValue: top, 1779 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 1780 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 1781 return result, validation.NewError("policyinsights.PolicyStatesClient", "SummarizeForSubscriptionLevelPolicyAssignment", err.Error()) 1782 } 1783 1784 req, err := client.SummarizeForSubscriptionLevelPolicyAssignmentPreparer(ctx, subscriptionID, policyAssignmentName, top, from, toParameter, filter) 1785 if err != nil { 1786 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForSubscriptionLevelPolicyAssignment", nil, "Failure preparing request") 1787 return 1788 } 1789 1790 resp, err := client.SummarizeForSubscriptionLevelPolicyAssignmentSender(req) 1791 if err != nil { 1792 result.Response = autorest.Response{Response: resp} 1793 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForSubscriptionLevelPolicyAssignment", resp, "Failure sending request") 1794 return 1795 } 1796 1797 result, err = client.SummarizeForSubscriptionLevelPolicyAssignmentResponder(resp) 1798 if err != nil { 1799 err = autorest.NewErrorWithError(err, "policyinsights.PolicyStatesClient", "SummarizeForSubscriptionLevelPolicyAssignment", resp, "Failure responding to request") 1800 return 1801 } 1802 1803 return 1804} 1805 1806// SummarizeForSubscriptionLevelPolicyAssignmentPreparer prepares the SummarizeForSubscriptionLevelPolicyAssignment request. 1807func (client PolicyStatesClient) SummarizeForSubscriptionLevelPolicyAssignmentPreparer(ctx context.Context, subscriptionID string, policyAssignmentName string, top *int32, from *date.Time, toParameter *date.Time, filter string) (*http.Request, error) { 1808 pathParameters := map[string]interface{}{ 1809 "authorizationNamespace": autorest.Encode("path", "Microsoft.Authorization"), 1810 "policyAssignmentName": autorest.Encode("path", policyAssignmentName), 1811 "policyStatesSummaryResource": autorest.Encode("path", "latest"), 1812 "subscriptionId": autorest.Encode("path", subscriptionID), 1813 } 1814 1815 const APIVersion = "2018-04-04" 1816 queryParameters := map[string]interface{}{ 1817 "api-version": APIVersion, 1818 } 1819 if top != nil { 1820 queryParameters["$top"] = autorest.Encode("query", *top) 1821 } 1822 if from != nil { 1823 queryParameters["$from"] = autorest.Encode("query", *from) 1824 } 1825 if toParameter != nil { 1826 queryParameters["$to"] = autorest.Encode("query", *toParameter) 1827 } 1828 if len(filter) > 0 { 1829 queryParameters["$filter"] = autorest.Encode("query", filter) 1830 } 1831 1832 preparer := autorest.CreatePreparer( 1833 autorest.AsPost(), 1834 autorest.WithBaseURL(client.BaseURI), 1835 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", pathParameters), 1836 autorest.WithQueryParameters(queryParameters)) 1837 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1838} 1839 1840// SummarizeForSubscriptionLevelPolicyAssignmentSender sends the SummarizeForSubscriptionLevelPolicyAssignment request. The method will close the 1841// http.Response Body if it receives an error. 1842func (client PolicyStatesClient) SummarizeForSubscriptionLevelPolicyAssignmentSender(req *http.Request) (*http.Response, error) { 1843 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1844} 1845 1846// SummarizeForSubscriptionLevelPolicyAssignmentResponder handles the response to the SummarizeForSubscriptionLevelPolicyAssignment request. The method always 1847// closes the http.Response Body. 1848func (client PolicyStatesClient) SummarizeForSubscriptionLevelPolicyAssignmentResponder(resp *http.Response) (result SummarizeResults, err error) { 1849 err = autorest.Respond( 1850 resp, 1851 azure.WithErrorUnlessStatusCode(http.StatusOK), 1852 autorest.ByUnmarshallingJSON(&result), 1853 autorest.ByClosing()) 1854 result.Response = autorest.Response{Response: resp} 1855 return 1856} 1857