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