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