1package web 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// RecommendationsClient is the webSite Management Client 19type RecommendationsClient struct { 20 BaseClient 21} 22 23// NewRecommendationsClient creates an instance of the RecommendationsClient client. 24func NewRecommendationsClient(subscriptionID string) RecommendationsClient { 25 return NewRecommendationsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewRecommendationsClientWithBaseURI creates an instance of the RecommendationsClient client using a custom endpoint. 29// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewRecommendationsClientWithBaseURI(baseURI string, subscriptionID string) RecommendationsClient { 31 return RecommendationsClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// DisableAllForWebApp disable all recommendations for an app. 35// Parameters: 36// resourceGroupName - name of the resource group to which the resource belongs. 37// siteName - name of the app. 38func (client RecommendationsClient) DisableAllForWebApp(ctx context.Context, resourceGroupName string, siteName string) (result autorest.Response, err error) { 39 if tracing.IsEnabled() { 40 ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.DisableAllForWebApp") 41 defer func() { 42 sc := -1 43 if result.Response != nil { 44 sc = result.Response.StatusCode 45 } 46 tracing.EndSpan(ctx, sc, err) 47 }() 48 } 49 if err := validation.Validate([]validation.Validation{ 50 {TargetValue: resourceGroupName, 51 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 52 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 53 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+[^\.]$`, Chain: nil}}}}); err != nil { 54 return result, validation.NewError("web.RecommendationsClient", "DisableAllForWebApp", err.Error()) 55 } 56 57 req, err := client.DisableAllForWebAppPreparer(ctx, resourceGroupName, siteName) 58 if err != nil { 59 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "DisableAllForWebApp", nil, "Failure preparing request") 60 return 61 } 62 63 resp, err := client.DisableAllForWebAppSender(req) 64 if err != nil { 65 result.Response = resp 66 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "DisableAllForWebApp", resp, "Failure sending request") 67 return 68 } 69 70 result, err = client.DisableAllForWebAppResponder(resp) 71 if err != nil { 72 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "DisableAllForWebApp", resp, "Failure responding to request") 73 return 74 } 75 76 return 77} 78 79// DisableAllForWebAppPreparer prepares the DisableAllForWebApp request. 80func (client RecommendationsClient) DisableAllForWebAppPreparer(ctx context.Context, resourceGroupName string, siteName string) (*http.Request, error) { 81 pathParameters := map[string]interface{}{ 82 "resourceGroupName": autorest.Encode("path", resourceGroupName), 83 "siteName": autorest.Encode("path", siteName), 84 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 85 } 86 87 const APIVersion = "2016-03-01" 88 queryParameters := map[string]interface{}{ 89 "api-version": APIVersion, 90 } 91 92 preparer := autorest.CreatePreparer( 93 autorest.AsPost(), 94 autorest.WithBaseURL(client.BaseURI), 95 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations/disable", pathParameters), 96 autorest.WithQueryParameters(queryParameters)) 97 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 98} 99 100// DisableAllForWebAppSender sends the DisableAllForWebApp request. The method will close the 101// http.Response Body if it receives an error. 102func (client RecommendationsClient) DisableAllForWebAppSender(req *http.Request) (*http.Response, error) { 103 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 104} 105 106// DisableAllForWebAppResponder handles the response to the DisableAllForWebApp request. The method always 107// closes the http.Response Body. 108func (client RecommendationsClient) DisableAllForWebAppResponder(resp *http.Response) (result autorest.Response, err error) { 109 err = autorest.Respond( 110 resp, 111 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 112 autorest.ByClosing()) 113 result.Response = resp 114 return 115} 116 117// DisableRecommendationForSite disables the specific rule for a web site permanently. 118// Parameters: 119// resourceGroupName - name of the resource group to which the resource belongs. 120// siteName - site name 121// name - rule name 122func (client RecommendationsClient) DisableRecommendationForSite(ctx context.Context, resourceGroupName string, siteName string, name string) (result autorest.Response, err error) { 123 if tracing.IsEnabled() { 124 ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.DisableRecommendationForSite") 125 defer func() { 126 sc := -1 127 if result.Response != nil { 128 sc = result.Response.StatusCode 129 } 130 tracing.EndSpan(ctx, sc, err) 131 }() 132 } 133 if err := validation.Validate([]validation.Validation{ 134 {TargetValue: resourceGroupName, 135 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 136 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 137 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+[^\.]$`, Chain: nil}}}}); err != nil { 138 return result, validation.NewError("web.RecommendationsClient", "DisableRecommendationForSite", err.Error()) 139 } 140 141 req, err := client.DisableRecommendationForSitePreparer(ctx, resourceGroupName, siteName, name) 142 if err != nil { 143 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "DisableRecommendationForSite", nil, "Failure preparing request") 144 return 145 } 146 147 resp, err := client.DisableRecommendationForSiteSender(req) 148 if err != nil { 149 result.Response = resp 150 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "DisableRecommendationForSite", resp, "Failure sending request") 151 return 152 } 153 154 result, err = client.DisableRecommendationForSiteResponder(resp) 155 if err != nil { 156 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "DisableRecommendationForSite", resp, "Failure responding to request") 157 return 158 } 159 160 return 161} 162 163// DisableRecommendationForSitePreparer prepares the DisableRecommendationForSite request. 164func (client RecommendationsClient) DisableRecommendationForSitePreparer(ctx context.Context, resourceGroupName string, siteName string, name string) (*http.Request, error) { 165 pathParameters := map[string]interface{}{ 166 "name": autorest.Encode("path", name), 167 "resourceGroupName": autorest.Encode("path", resourceGroupName), 168 "siteName": autorest.Encode("path", siteName), 169 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 170 } 171 172 const APIVersion = "2016-03-01" 173 queryParameters := map[string]interface{}{ 174 "api-version": APIVersion, 175 } 176 177 preparer := autorest.CreatePreparer( 178 autorest.AsPost(), 179 autorest.WithBaseURL(client.BaseURI), 180 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations/{name}/disable", pathParameters), 181 autorest.WithQueryParameters(queryParameters)) 182 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 183} 184 185// DisableRecommendationForSiteSender sends the DisableRecommendationForSite request. The method will close the 186// http.Response Body if it receives an error. 187func (client RecommendationsClient) DisableRecommendationForSiteSender(req *http.Request) (*http.Response, error) { 188 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 189} 190 191// DisableRecommendationForSiteResponder handles the response to the DisableRecommendationForSite request. The method always 192// closes the http.Response Body. 193func (client RecommendationsClient) DisableRecommendationForSiteResponder(resp *http.Response) (result autorest.Response, err error) { 194 err = autorest.Respond( 195 resp, 196 azure.WithErrorUnlessStatusCode(http.StatusOK), 197 autorest.ByClosing()) 198 result.Response = resp 199 return 200} 201 202// DisableRecommendationForSubscription disables the specified rule so it will not apply to a subscription in the 203// future. 204// Parameters: 205// name - rule name 206func (client RecommendationsClient) DisableRecommendationForSubscription(ctx context.Context, name string) (result autorest.Response, err error) { 207 if tracing.IsEnabled() { 208 ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.DisableRecommendationForSubscription") 209 defer func() { 210 sc := -1 211 if result.Response != nil { 212 sc = result.Response.StatusCode 213 } 214 tracing.EndSpan(ctx, sc, err) 215 }() 216 } 217 req, err := client.DisableRecommendationForSubscriptionPreparer(ctx, name) 218 if err != nil { 219 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "DisableRecommendationForSubscription", nil, "Failure preparing request") 220 return 221 } 222 223 resp, err := client.DisableRecommendationForSubscriptionSender(req) 224 if err != nil { 225 result.Response = resp 226 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "DisableRecommendationForSubscription", resp, "Failure sending request") 227 return 228 } 229 230 result, err = client.DisableRecommendationForSubscriptionResponder(resp) 231 if err != nil { 232 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "DisableRecommendationForSubscription", resp, "Failure responding to request") 233 return 234 } 235 236 return 237} 238 239// DisableRecommendationForSubscriptionPreparer prepares the DisableRecommendationForSubscription request. 240func (client RecommendationsClient) DisableRecommendationForSubscriptionPreparer(ctx context.Context, name string) (*http.Request, error) { 241 pathParameters := map[string]interface{}{ 242 "name": autorest.Encode("path", name), 243 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 244 } 245 246 const APIVersion = "2016-03-01" 247 queryParameters := map[string]interface{}{ 248 "api-version": APIVersion, 249 } 250 251 preparer := autorest.CreatePreparer( 252 autorest.AsPost(), 253 autorest.WithBaseURL(client.BaseURI), 254 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Web/recommendations/{name}/disable", pathParameters), 255 autorest.WithQueryParameters(queryParameters)) 256 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 257} 258 259// DisableRecommendationForSubscriptionSender sends the DisableRecommendationForSubscription request. The method will close the 260// http.Response Body if it receives an error. 261func (client RecommendationsClient) DisableRecommendationForSubscriptionSender(req *http.Request) (*http.Response, error) { 262 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 263} 264 265// DisableRecommendationForSubscriptionResponder handles the response to the DisableRecommendationForSubscription request. The method always 266// closes the http.Response Body. 267func (client RecommendationsClient) DisableRecommendationForSubscriptionResponder(resp *http.Response) (result autorest.Response, err error) { 268 err = autorest.Respond( 269 resp, 270 azure.WithErrorUnlessStatusCode(http.StatusOK), 271 autorest.ByClosing()) 272 result.Response = resp 273 return 274} 275 276// GetRuleDetailsByWebApp get a recommendation rule for an app. 277// Parameters: 278// resourceGroupName - name of the resource group to which the resource belongs. 279// siteName - name of the app. 280// name - name of the recommendation. 281// updateSeen - specify <code>true</code> to update the last-seen timestamp of the recommendation object. 282// recommendationID - the GUID of the recommendation object if you query an expired one. You don't need to 283// specify it to query an active entry. 284func (client RecommendationsClient) GetRuleDetailsByWebApp(ctx context.Context, resourceGroupName string, siteName string, name string, updateSeen *bool, recommendationID string) (result RecommendationRule, err error) { 285 if tracing.IsEnabled() { 286 ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.GetRuleDetailsByWebApp") 287 defer func() { 288 sc := -1 289 if result.Response.Response != nil { 290 sc = result.Response.Response.StatusCode 291 } 292 tracing.EndSpan(ctx, sc, err) 293 }() 294 } 295 if err := validation.Validate([]validation.Validation{ 296 {TargetValue: resourceGroupName, 297 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 298 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 299 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+[^\.]$`, Chain: nil}}}}); err != nil { 300 return result, validation.NewError("web.RecommendationsClient", "GetRuleDetailsByWebApp", err.Error()) 301 } 302 303 req, err := client.GetRuleDetailsByWebAppPreparer(ctx, resourceGroupName, siteName, name, updateSeen, recommendationID) 304 if err != nil { 305 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "GetRuleDetailsByWebApp", nil, "Failure preparing request") 306 return 307 } 308 309 resp, err := client.GetRuleDetailsByWebAppSender(req) 310 if err != nil { 311 result.Response = autorest.Response{Response: resp} 312 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "GetRuleDetailsByWebApp", resp, "Failure sending request") 313 return 314 } 315 316 result, err = client.GetRuleDetailsByWebAppResponder(resp) 317 if err != nil { 318 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "GetRuleDetailsByWebApp", resp, "Failure responding to request") 319 return 320 } 321 322 return 323} 324 325// GetRuleDetailsByWebAppPreparer prepares the GetRuleDetailsByWebApp request. 326func (client RecommendationsClient) GetRuleDetailsByWebAppPreparer(ctx context.Context, resourceGroupName string, siteName string, name string, updateSeen *bool, recommendationID string) (*http.Request, error) { 327 pathParameters := map[string]interface{}{ 328 "name": autorest.Encode("path", name), 329 "resourceGroupName": autorest.Encode("path", resourceGroupName), 330 "siteName": autorest.Encode("path", siteName), 331 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 332 } 333 334 const APIVersion = "2016-03-01" 335 queryParameters := map[string]interface{}{ 336 "api-version": APIVersion, 337 } 338 if updateSeen != nil { 339 queryParameters["updateSeen"] = autorest.Encode("query", *updateSeen) 340 } 341 if len(recommendationID) > 0 { 342 queryParameters["recommendationId"] = autorest.Encode("query", recommendationID) 343 } 344 345 preparer := autorest.CreatePreparer( 346 autorest.AsGet(), 347 autorest.WithBaseURL(client.BaseURI), 348 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations/{name}", pathParameters), 349 autorest.WithQueryParameters(queryParameters)) 350 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 351} 352 353// GetRuleDetailsByWebAppSender sends the GetRuleDetailsByWebApp request. The method will close the 354// http.Response Body if it receives an error. 355func (client RecommendationsClient) GetRuleDetailsByWebAppSender(req *http.Request) (*http.Response, error) { 356 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 357} 358 359// GetRuleDetailsByWebAppResponder handles the response to the GetRuleDetailsByWebApp request. The method always 360// closes the http.Response Body. 361func (client RecommendationsClient) GetRuleDetailsByWebAppResponder(resp *http.Response) (result RecommendationRule, err error) { 362 err = autorest.Respond( 363 resp, 364 azure.WithErrorUnlessStatusCode(http.StatusOK), 365 autorest.ByUnmarshallingJSON(&result), 366 autorest.ByClosing()) 367 result.Response = autorest.Response{Response: resp} 368 return 369} 370 371// List list all recommendations for a subscription. 372// Parameters: 373// featured - specify <code>true</code> to return only the most critical recommendations. The default is 374// <code>false</code>, which returns all recommendations. 375// filter - filter is specified by using OData syntax. Example: $filter=channels eq 'Api' or channel eq 376// 'Notification' and startTime eq '2014-01-01T00:00:00Z' and endTime eq '2014-12-31T23:59:59Z' and timeGrain 377// eq duration'[PT1H|PT1M|P1D] 378func (client RecommendationsClient) List(ctx context.Context, featured *bool, filter string) (result RecommendationCollectionPage, err error) { 379 if tracing.IsEnabled() { 380 ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.List") 381 defer func() { 382 sc := -1 383 if result.rc.Response.Response != nil { 384 sc = result.rc.Response.Response.StatusCode 385 } 386 tracing.EndSpan(ctx, sc, err) 387 }() 388 } 389 result.fn = client.listNextResults 390 req, err := client.ListPreparer(ctx, featured, filter) 391 if err != nil { 392 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "List", nil, "Failure preparing request") 393 return 394 } 395 396 resp, err := client.ListSender(req) 397 if err != nil { 398 result.rc.Response = autorest.Response{Response: resp} 399 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "List", resp, "Failure sending request") 400 return 401 } 402 403 result.rc, err = client.ListResponder(resp) 404 if err != nil { 405 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "List", resp, "Failure responding to request") 406 return 407 } 408 if result.rc.hasNextLink() && result.rc.IsEmpty() { 409 err = result.NextWithContext(ctx) 410 return 411 } 412 413 return 414} 415 416// ListPreparer prepares the List request. 417func (client RecommendationsClient) ListPreparer(ctx context.Context, featured *bool, filter string) (*http.Request, error) { 418 pathParameters := map[string]interface{}{ 419 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 420 } 421 422 const APIVersion = "2016-03-01" 423 queryParameters := map[string]interface{}{ 424 "api-version": APIVersion, 425 } 426 if featured != nil { 427 queryParameters["featured"] = autorest.Encode("query", *featured) 428 } 429 if len(filter) > 0 { 430 queryParameters["$filter"] = filter 431 } 432 433 preparer := autorest.CreatePreparer( 434 autorest.AsGet(), 435 autorest.WithBaseURL(client.BaseURI), 436 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Web/recommendations", pathParameters), 437 autorest.WithQueryParameters(queryParameters)) 438 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 439} 440 441// ListSender sends the List request. The method will close the 442// http.Response Body if it receives an error. 443func (client RecommendationsClient) ListSender(req *http.Request) (*http.Response, error) { 444 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 445} 446 447// ListResponder handles the response to the List request. The method always 448// closes the http.Response Body. 449func (client RecommendationsClient) ListResponder(resp *http.Response) (result RecommendationCollection, err error) { 450 err = autorest.Respond( 451 resp, 452 azure.WithErrorUnlessStatusCode(http.StatusOK), 453 autorest.ByUnmarshallingJSON(&result), 454 autorest.ByClosing()) 455 result.Response = autorest.Response{Response: resp} 456 return 457} 458 459// listNextResults retrieves the next set of results, if any. 460func (client RecommendationsClient) listNextResults(ctx context.Context, lastResults RecommendationCollection) (result RecommendationCollection, err error) { 461 req, err := lastResults.recommendationCollectionPreparer(ctx) 462 if err != nil { 463 return result, autorest.NewErrorWithError(err, "web.RecommendationsClient", "listNextResults", nil, "Failure preparing next results request") 464 } 465 if req == nil { 466 return 467 } 468 resp, err := client.ListSender(req) 469 if err != nil { 470 result.Response = autorest.Response{Response: resp} 471 return result, autorest.NewErrorWithError(err, "web.RecommendationsClient", "listNextResults", resp, "Failure sending next results request") 472 } 473 result, err = client.ListResponder(resp) 474 if err != nil { 475 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "listNextResults", resp, "Failure responding to next results request") 476 } 477 return 478} 479 480// ListComplete enumerates all values, automatically crossing page boundaries as required. 481func (client RecommendationsClient) ListComplete(ctx context.Context, featured *bool, filter string) (result RecommendationCollectionIterator, err error) { 482 if tracing.IsEnabled() { 483 ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.List") 484 defer func() { 485 sc := -1 486 if result.Response().Response.Response != nil { 487 sc = result.page.Response().Response.Response.StatusCode 488 } 489 tracing.EndSpan(ctx, sc, err) 490 }() 491 } 492 result.page, err = client.List(ctx, featured, filter) 493 return 494} 495 496// ListHistoryForWebApp get past recommendations for an app, optionally specified by the time range. 497// Parameters: 498// resourceGroupName - name of the resource group to which the resource belongs. 499// siteName - name of the app. 500// filter - filter is specified by using OData syntax. Example: $filter=channels eq 'Api' or channel eq 501// 'Notification' and startTime eq '2014-01-01T00:00:00Z' and endTime eq '2014-12-31T23:59:59Z' and timeGrain 502// eq duration'[PT1H|PT1M|P1D] 503func (client RecommendationsClient) ListHistoryForWebApp(ctx context.Context, resourceGroupName string, siteName string, filter string) (result RecommendationCollectionPage, err error) { 504 if tracing.IsEnabled() { 505 ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.ListHistoryForWebApp") 506 defer func() { 507 sc := -1 508 if result.rc.Response.Response != nil { 509 sc = result.rc.Response.Response.StatusCode 510 } 511 tracing.EndSpan(ctx, sc, err) 512 }() 513 } 514 if err := validation.Validate([]validation.Validation{ 515 {TargetValue: resourceGroupName, 516 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 517 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 518 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+[^\.]$`, Chain: nil}}}}); err != nil { 519 return result, validation.NewError("web.RecommendationsClient", "ListHistoryForWebApp", err.Error()) 520 } 521 522 result.fn = client.listHistoryForWebAppNextResults 523 req, err := client.ListHistoryForWebAppPreparer(ctx, resourceGroupName, siteName, filter) 524 if err != nil { 525 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "ListHistoryForWebApp", nil, "Failure preparing request") 526 return 527 } 528 529 resp, err := client.ListHistoryForWebAppSender(req) 530 if err != nil { 531 result.rc.Response = autorest.Response{Response: resp} 532 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "ListHistoryForWebApp", resp, "Failure sending request") 533 return 534 } 535 536 result.rc, err = client.ListHistoryForWebAppResponder(resp) 537 if err != nil { 538 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "ListHistoryForWebApp", resp, "Failure responding to request") 539 return 540 } 541 if result.rc.hasNextLink() && result.rc.IsEmpty() { 542 err = result.NextWithContext(ctx) 543 return 544 } 545 546 return 547} 548 549// ListHistoryForWebAppPreparer prepares the ListHistoryForWebApp request. 550func (client RecommendationsClient) ListHistoryForWebAppPreparer(ctx context.Context, resourceGroupName string, siteName string, filter string) (*http.Request, error) { 551 pathParameters := map[string]interface{}{ 552 "resourceGroupName": autorest.Encode("path", resourceGroupName), 553 "siteName": autorest.Encode("path", siteName), 554 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 555 } 556 557 const APIVersion = "2016-03-01" 558 queryParameters := map[string]interface{}{ 559 "api-version": APIVersion, 560 } 561 if len(filter) > 0 { 562 queryParameters["$filter"] = filter 563 } 564 565 preparer := autorest.CreatePreparer( 566 autorest.AsGet(), 567 autorest.WithBaseURL(client.BaseURI), 568 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendationHistory", pathParameters), 569 autorest.WithQueryParameters(queryParameters)) 570 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 571} 572 573// ListHistoryForWebAppSender sends the ListHistoryForWebApp request. The method will close the 574// http.Response Body if it receives an error. 575func (client RecommendationsClient) ListHistoryForWebAppSender(req *http.Request) (*http.Response, error) { 576 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 577} 578 579// ListHistoryForWebAppResponder handles the response to the ListHistoryForWebApp request. The method always 580// closes the http.Response Body. 581func (client RecommendationsClient) ListHistoryForWebAppResponder(resp *http.Response) (result RecommendationCollection, err error) { 582 err = autorest.Respond( 583 resp, 584 azure.WithErrorUnlessStatusCode(http.StatusOK), 585 autorest.ByUnmarshallingJSON(&result), 586 autorest.ByClosing()) 587 result.Response = autorest.Response{Response: resp} 588 return 589} 590 591// listHistoryForWebAppNextResults retrieves the next set of results, if any. 592func (client RecommendationsClient) listHistoryForWebAppNextResults(ctx context.Context, lastResults RecommendationCollection) (result RecommendationCollection, err error) { 593 req, err := lastResults.recommendationCollectionPreparer(ctx) 594 if err != nil { 595 return result, autorest.NewErrorWithError(err, "web.RecommendationsClient", "listHistoryForWebAppNextResults", nil, "Failure preparing next results request") 596 } 597 if req == nil { 598 return 599 } 600 resp, err := client.ListHistoryForWebAppSender(req) 601 if err != nil { 602 result.Response = autorest.Response{Response: resp} 603 return result, autorest.NewErrorWithError(err, "web.RecommendationsClient", "listHistoryForWebAppNextResults", resp, "Failure sending next results request") 604 } 605 result, err = client.ListHistoryForWebAppResponder(resp) 606 if err != nil { 607 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "listHistoryForWebAppNextResults", resp, "Failure responding to next results request") 608 } 609 return 610} 611 612// ListHistoryForWebAppComplete enumerates all values, automatically crossing page boundaries as required. 613func (client RecommendationsClient) ListHistoryForWebAppComplete(ctx context.Context, resourceGroupName string, siteName string, filter string) (result RecommendationCollectionIterator, err error) { 614 if tracing.IsEnabled() { 615 ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.ListHistoryForWebApp") 616 defer func() { 617 sc := -1 618 if result.Response().Response.Response != nil { 619 sc = result.page.Response().Response.Response.StatusCode 620 } 621 tracing.EndSpan(ctx, sc, err) 622 }() 623 } 624 result.page, err = client.ListHistoryForWebApp(ctx, resourceGroupName, siteName, filter) 625 return 626} 627 628// ListRecommendedRulesForWebApp get all recommendations for an app. 629// Parameters: 630// resourceGroupName - name of the resource group to which the resource belongs. 631// siteName - name of the app. 632// featured - specify <code>true</code> to return only the most critical recommendations. The default is 633// <code>false</code>, which returns all recommendations. 634// filter - return only channels specified in the filter. Filter is specified by using OData syntax. Example: 635// $filter=channels eq 'Api' or channel eq 'Notification' 636func (client RecommendationsClient) ListRecommendedRulesForWebApp(ctx context.Context, resourceGroupName string, siteName string, featured *bool, filter string) (result RecommendationCollectionPage, err error) { 637 if tracing.IsEnabled() { 638 ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.ListRecommendedRulesForWebApp") 639 defer func() { 640 sc := -1 641 if result.rc.Response.Response != nil { 642 sc = result.rc.Response.Response.StatusCode 643 } 644 tracing.EndSpan(ctx, sc, err) 645 }() 646 } 647 if err := validation.Validate([]validation.Validation{ 648 {TargetValue: resourceGroupName, 649 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 650 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 651 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+[^\.]$`, Chain: nil}}}}); err != nil { 652 return result, validation.NewError("web.RecommendationsClient", "ListRecommendedRulesForWebApp", err.Error()) 653 } 654 655 result.fn = client.listRecommendedRulesForWebAppNextResults 656 req, err := client.ListRecommendedRulesForWebAppPreparer(ctx, resourceGroupName, siteName, featured, filter) 657 if err != nil { 658 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "ListRecommendedRulesForWebApp", nil, "Failure preparing request") 659 return 660 } 661 662 resp, err := client.ListRecommendedRulesForWebAppSender(req) 663 if err != nil { 664 result.rc.Response = autorest.Response{Response: resp} 665 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "ListRecommendedRulesForWebApp", resp, "Failure sending request") 666 return 667 } 668 669 result.rc, err = client.ListRecommendedRulesForWebAppResponder(resp) 670 if err != nil { 671 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "ListRecommendedRulesForWebApp", resp, "Failure responding to request") 672 return 673 } 674 if result.rc.hasNextLink() && result.rc.IsEmpty() { 675 err = result.NextWithContext(ctx) 676 return 677 } 678 679 return 680} 681 682// ListRecommendedRulesForWebAppPreparer prepares the ListRecommendedRulesForWebApp request. 683func (client RecommendationsClient) ListRecommendedRulesForWebAppPreparer(ctx context.Context, resourceGroupName string, siteName string, featured *bool, filter string) (*http.Request, error) { 684 pathParameters := map[string]interface{}{ 685 "resourceGroupName": autorest.Encode("path", resourceGroupName), 686 "siteName": autorest.Encode("path", siteName), 687 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 688 } 689 690 const APIVersion = "2016-03-01" 691 queryParameters := map[string]interface{}{ 692 "api-version": APIVersion, 693 } 694 if featured != nil { 695 queryParameters["featured"] = autorest.Encode("query", *featured) 696 } 697 if len(filter) > 0 { 698 queryParameters["$filter"] = filter 699 } 700 701 preparer := autorest.CreatePreparer( 702 autorest.AsGet(), 703 autorest.WithBaseURL(client.BaseURI), 704 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations", pathParameters), 705 autorest.WithQueryParameters(queryParameters)) 706 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 707} 708 709// ListRecommendedRulesForWebAppSender sends the ListRecommendedRulesForWebApp request. The method will close the 710// http.Response Body if it receives an error. 711func (client RecommendationsClient) ListRecommendedRulesForWebAppSender(req *http.Request) (*http.Response, error) { 712 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 713} 714 715// ListRecommendedRulesForWebAppResponder handles the response to the ListRecommendedRulesForWebApp request. The method always 716// closes the http.Response Body. 717func (client RecommendationsClient) ListRecommendedRulesForWebAppResponder(resp *http.Response) (result RecommendationCollection, err error) { 718 err = autorest.Respond( 719 resp, 720 azure.WithErrorUnlessStatusCode(http.StatusOK), 721 autorest.ByUnmarshallingJSON(&result), 722 autorest.ByClosing()) 723 result.Response = autorest.Response{Response: resp} 724 return 725} 726 727// listRecommendedRulesForWebAppNextResults retrieves the next set of results, if any. 728func (client RecommendationsClient) listRecommendedRulesForWebAppNextResults(ctx context.Context, lastResults RecommendationCollection) (result RecommendationCollection, err error) { 729 req, err := lastResults.recommendationCollectionPreparer(ctx) 730 if err != nil { 731 return result, autorest.NewErrorWithError(err, "web.RecommendationsClient", "listRecommendedRulesForWebAppNextResults", nil, "Failure preparing next results request") 732 } 733 if req == nil { 734 return 735 } 736 resp, err := client.ListRecommendedRulesForWebAppSender(req) 737 if err != nil { 738 result.Response = autorest.Response{Response: resp} 739 return result, autorest.NewErrorWithError(err, "web.RecommendationsClient", "listRecommendedRulesForWebAppNextResults", resp, "Failure sending next results request") 740 } 741 result, err = client.ListRecommendedRulesForWebAppResponder(resp) 742 if err != nil { 743 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "listRecommendedRulesForWebAppNextResults", resp, "Failure responding to next results request") 744 } 745 return 746} 747 748// ListRecommendedRulesForWebAppComplete enumerates all values, automatically crossing page boundaries as required. 749func (client RecommendationsClient) ListRecommendedRulesForWebAppComplete(ctx context.Context, resourceGroupName string, siteName string, featured *bool, filter string) (result RecommendationCollectionIterator, err error) { 750 if tracing.IsEnabled() { 751 ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.ListRecommendedRulesForWebApp") 752 defer func() { 753 sc := -1 754 if result.Response().Response.Response != nil { 755 sc = result.page.Response().Response.Response.StatusCode 756 } 757 tracing.EndSpan(ctx, sc, err) 758 }() 759 } 760 result.page, err = client.ListRecommendedRulesForWebApp(ctx, resourceGroupName, siteName, featured, filter) 761 return 762} 763 764// ResetAllFilters reset all recommendation opt-out settings for a subscription. 765func (client RecommendationsClient) ResetAllFilters(ctx context.Context) (result autorest.Response, err error) { 766 if tracing.IsEnabled() { 767 ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.ResetAllFilters") 768 defer func() { 769 sc := -1 770 if result.Response != nil { 771 sc = result.Response.StatusCode 772 } 773 tracing.EndSpan(ctx, sc, err) 774 }() 775 } 776 req, err := client.ResetAllFiltersPreparer(ctx) 777 if err != nil { 778 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "ResetAllFilters", nil, "Failure preparing request") 779 return 780 } 781 782 resp, err := client.ResetAllFiltersSender(req) 783 if err != nil { 784 result.Response = resp 785 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "ResetAllFilters", resp, "Failure sending request") 786 return 787 } 788 789 result, err = client.ResetAllFiltersResponder(resp) 790 if err != nil { 791 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "ResetAllFilters", resp, "Failure responding to request") 792 return 793 } 794 795 return 796} 797 798// ResetAllFiltersPreparer prepares the ResetAllFilters request. 799func (client RecommendationsClient) ResetAllFiltersPreparer(ctx context.Context) (*http.Request, error) { 800 pathParameters := map[string]interface{}{ 801 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 802 } 803 804 const APIVersion = "2016-03-01" 805 queryParameters := map[string]interface{}{ 806 "api-version": APIVersion, 807 } 808 809 preparer := autorest.CreatePreparer( 810 autorest.AsPost(), 811 autorest.WithBaseURL(client.BaseURI), 812 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Web/recommendations/reset", pathParameters), 813 autorest.WithQueryParameters(queryParameters)) 814 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 815} 816 817// ResetAllFiltersSender sends the ResetAllFilters request. The method will close the 818// http.Response Body if it receives an error. 819func (client RecommendationsClient) ResetAllFiltersSender(req *http.Request) (*http.Response, error) { 820 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 821} 822 823// ResetAllFiltersResponder handles the response to the ResetAllFilters request. The method always 824// closes the http.Response Body. 825func (client RecommendationsClient) ResetAllFiltersResponder(resp *http.Response) (result autorest.Response, err error) { 826 err = autorest.Respond( 827 resp, 828 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 829 autorest.ByClosing()) 830 result.Response = resp 831 return 832} 833 834// ResetAllFiltersForWebApp reset all recommendation opt-out settings for an app. 835// Parameters: 836// resourceGroupName - name of the resource group to which the resource belongs. 837// siteName - name of the app. 838func (client RecommendationsClient) ResetAllFiltersForWebApp(ctx context.Context, resourceGroupName string, siteName string) (result autorest.Response, err error) { 839 if tracing.IsEnabled() { 840 ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationsClient.ResetAllFiltersForWebApp") 841 defer func() { 842 sc := -1 843 if result.Response != nil { 844 sc = result.Response.StatusCode 845 } 846 tracing.EndSpan(ctx, sc, err) 847 }() 848 } 849 if err := validation.Validate([]validation.Validation{ 850 {TargetValue: resourceGroupName, 851 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 852 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 853 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+[^\.]$`, Chain: nil}}}}); err != nil { 854 return result, validation.NewError("web.RecommendationsClient", "ResetAllFiltersForWebApp", err.Error()) 855 } 856 857 req, err := client.ResetAllFiltersForWebAppPreparer(ctx, resourceGroupName, siteName) 858 if err != nil { 859 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "ResetAllFiltersForWebApp", nil, "Failure preparing request") 860 return 861 } 862 863 resp, err := client.ResetAllFiltersForWebAppSender(req) 864 if err != nil { 865 result.Response = resp 866 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "ResetAllFiltersForWebApp", resp, "Failure sending request") 867 return 868 } 869 870 result, err = client.ResetAllFiltersForWebAppResponder(resp) 871 if err != nil { 872 err = autorest.NewErrorWithError(err, "web.RecommendationsClient", "ResetAllFiltersForWebApp", resp, "Failure responding to request") 873 return 874 } 875 876 return 877} 878 879// ResetAllFiltersForWebAppPreparer prepares the ResetAllFiltersForWebApp request. 880func (client RecommendationsClient) ResetAllFiltersForWebAppPreparer(ctx context.Context, resourceGroupName string, siteName string) (*http.Request, error) { 881 pathParameters := map[string]interface{}{ 882 "resourceGroupName": autorest.Encode("path", resourceGroupName), 883 "siteName": autorest.Encode("path", siteName), 884 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 885 } 886 887 const APIVersion = "2016-03-01" 888 queryParameters := map[string]interface{}{ 889 "api-version": APIVersion, 890 } 891 892 preparer := autorest.CreatePreparer( 893 autorest.AsPost(), 894 autorest.WithBaseURL(client.BaseURI), 895 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations/reset", pathParameters), 896 autorest.WithQueryParameters(queryParameters)) 897 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 898} 899 900// ResetAllFiltersForWebAppSender sends the ResetAllFiltersForWebApp request. The method will close the 901// http.Response Body if it receives an error. 902func (client RecommendationsClient) ResetAllFiltersForWebAppSender(req *http.Request) (*http.Response, error) { 903 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 904} 905 906// ResetAllFiltersForWebAppResponder handles the response to the ResetAllFiltersForWebApp request. The method always 907// closes the http.Response Body. 908func (client RecommendationsClient) ResetAllFiltersForWebAppResponder(resp *http.Response) (result autorest.Response, err error) { 909 err = autorest.Respond( 910 resp, 911 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 912 autorest.ByClosing()) 913 result.Response = resp 914 return 915} 916