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/tracing" 25 "net/http" 26) 27 28// DeletedWebAppsClient is the webSite Management Client 29type DeletedWebAppsClient struct { 30 BaseClient 31} 32 33// NewDeletedWebAppsClient creates an instance of the DeletedWebAppsClient client. 34func NewDeletedWebAppsClient(subscriptionID string) DeletedWebAppsClient { 35 return NewDeletedWebAppsClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewDeletedWebAppsClientWithBaseURI creates an instance of the DeletedWebAppsClient client using a custom endpoint. 39// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 40func NewDeletedWebAppsClientWithBaseURI(baseURI string, subscriptionID string) DeletedWebAppsClient { 41 return DeletedWebAppsClient{NewWithBaseURI(baseURI, subscriptionID)} 42} 43 44// GetDeletedWebAppByLocation description for Get deleted app for a subscription at location. 45// Parameters: 46// deletedSiteID - the numeric ID of the deleted app, e.g. 12345 47func (client DeletedWebAppsClient) GetDeletedWebAppByLocation(ctx context.Context, location string, deletedSiteID string) (result DeletedSite, err error) { 48 if tracing.IsEnabled() { 49 ctx = tracing.StartSpan(ctx, fqdn+"/DeletedWebAppsClient.GetDeletedWebAppByLocation") 50 defer func() { 51 sc := -1 52 if result.Response.Response != nil { 53 sc = result.Response.Response.StatusCode 54 } 55 tracing.EndSpan(ctx, sc, err) 56 }() 57 } 58 req, err := client.GetDeletedWebAppByLocationPreparer(ctx, location, deletedSiteID) 59 if err != nil { 60 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "GetDeletedWebAppByLocation", nil, "Failure preparing request") 61 return 62 } 63 64 resp, err := client.GetDeletedWebAppByLocationSender(req) 65 if err != nil { 66 result.Response = autorest.Response{Response: resp} 67 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "GetDeletedWebAppByLocation", resp, "Failure sending request") 68 return 69 } 70 71 result, err = client.GetDeletedWebAppByLocationResponder(resp) 72 if err != nil { 73 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "GetDeletedWebAppByLocation", resp, "Failure responding to request") 74 } 75 76 return 77} 78 79// GetDeletedWebAppByLocationPreparer prepares the GetDeletedWebAppByLocation request. 80func (client DeletedWebAppsClient) GetDeletedWebAppByLocationPreparer(ctx context.Context, location string, deletedSiteID string) (*http.Request, error) { 81 pathParameters := map[string]interface{}{ 82 "deletedSiteId": autorest.Encode("path", deletedSiteID), 83 "location": autorest.Encode("path", location), 84 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 85 } 86 87 const APIVersion = "2019-08-01" 88 queryParameters := map[string]interface{}{ 89 "api-version": APIVersion, 90 } 91 92 preparer := autorest.CreatePreparer( 93 autorest.AsGet(), 94 autorest.WithBaseURL(client.BaseURI), 95 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Web/locations/{location}/deletedSites/{deletedSiteId}", pathParameters), 96 autorest.WithQueryParameters(queryParameters)) 97 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 98} 99 100// GetDeletedWebAppByLocationSender sends the GetDeletedWebAppByLocation request. The method will close the 101// http.Response Body if it receives an error. 102func (client DeletedWebAppsClient) GetDeletedWebAppByLocationSender(req *http.Request) (*http.Response, error) { 103 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 104} 105 106// GetDeletedWebAppByLocationResponder handles the response to the GetDeletedWebAppByLocation request. The method always 107// closes the http.Response Body. 108func (client DeletedWebAppsClient) GetDeletedWebAppByLocationResponder(resp *http.Response) (result DeletedSite, err error) { 109 err = autorest.Respond( 110 resp, 111 client.ByInspecting(), 112 azure.WithErrorUnlessStatusCode(http.StatusOK), 113 autorest.ByUnmarshallingJSON(&result), 114 autorest.ByClosing()) 115 result.Response = autorest.Response{Response: resp} 116 return 117} 118 119// List description for Get all deleted apps for a subscription. 120func (client DeletedWebAppsClient) List(ctx context.Context) (result DeletedWebAppCollectionPage, err error) { 121 if tracing.IsEnabled() { 122 ctx = tracing.StartSpan(ctx, fqdn+"/DeletedWebAppsClient.List") 123 defer func() { 124 sc := -1 125 if result.dwac.Response.Response != nil { 126 sc = result.dwac.Response.Response.StatusCode 127 } 128 tracing.EndSpan(ctx, sc, err) 129 }() 130 } 131 result.fn = client.listNextResults 132 req, err := client.ListPreparer(ctx) 133 if err != nil { 134 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "List", nil, "Failure preparing request") 135 return 136 } 137 138 resp, err := client.ListSender(req) 139 if err != nil { 140 result.dwac.Response = autorest.Response{Response: resp} 141 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "List", resp, "Failure sending request") 142 return 143 } 144 145 result.dwac, err = client.ListResponder(resp) 146 if err != nil { 147 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "List", resp, "Failure responding to request") 148 } 149 150 return 151} 152 153// ListPreparer prepares the List request. 154func (client DeletedWebAppsClient) ListPreparer(ctx context.Context) (*http.Request, error) { 155 pathParameters := map[string]interface{}{ 156 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 157 } 158 159 const APIVersion = "2019-08-01" 160 queryParameters := map[string]interface{}{ 161 "api-version": APIVersion, 162 } 163 164 preparer := autorest.CreatePreparer( 165 autorest.AsGet(), 166 autorest.WithBaseURL(client.BaseURI), 167 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Web/deletedSites", pathParameters), 168 autorest.WithQueryParameters(queryParameters)) 169 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 170} 171 172// ListSender sends the List request. The method will close the 173// http.Response Body if it receives an error. 174func (client DeletedWebAppsClient) ListSender(req *http.Request) (*http.Response, error) { 175 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 176} 177 178// ListResponder handles the response to the List request. The method always 179// closes the http.Response Body. 180func (client DeletedWebAppsClient) ListResponder(resp *http.Response) (result DeletedWebAppCollection, err error) { 181 err = autorest.Respond( 182 resp, 183 client.ByInspecting(), 184 azure.WithErrorUnlessStatusCode(http.StatusOK), 185 autorest.ByUnmarshallingJSON(&result), 186 autorest.ByClosing()) 187 result.Response = autorest.Response{Response: resp} 188 return 189} 190 191// listNextResults retrieves the next set of results, if any. 192func (client DeletedWebAppsClient) listNextResults(ctx context.Context, lastResults DeletedWebAppCollection) (result DeletedWebAppCollection, err error) { 193 req, err := lastResults.deletedWebAppCollectionPreparer(ctx) 194 if err != nil { 195 return result, autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "listNextResults", nil, "Failure preparing next results request") 196 } 197 if req == nil { 198 return 199 } 200 resp, err := client.ListSender(req) 201 if err != nil { 202 result.Response = autorest.Response{Response: resp} 203 return result, autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "listNextResults", resp, "Failure sending next results request") 204 } 205 result, err = client.ListResponder(resp) 206 if err != nil { 207 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "listNextResults", resp, "Failure responding to next results request") 208 } 209 return 210} 211 212// ListComplete enumerates all values, automatically crossing page boundaries as required. 213func (client DeletedWebAppsClient) ListComplete(ctx context.Context) (result DeletedWebAppCollectionIterator, err error) { 214 if tracing.IsEnabled() { 215 ctx = tracing.StartSpan(ctx, fqdn+"/DeletedWebAppsClient.List") 216 defer func() { 217 sc := -1 218 if result.Response().Response.Response != nil { 219 sc = result.page.Response().Response.Response.StatusCode 220 } 221 tracing.EndSpan(ctx, sc, err) 222 }() 223 } 224 result.page, err = client.List(ctx) 225 return 226} 227 228// ListByLocation description for Get all deleted apps for a subscription at location 229func (client DeletedWebAppsClient) ListByLocation(ctx context.Context, location string) (result DeletedWebAppCollectionPage, err error) { 230 if tracing.IsEnabled() { 231 ctx = tracing.StartSpan(ctx, fqdn+"/DeletedWebAppsClient.ListByLocation") 232 defer func() { 233 sc := -1 234 if result.dwac.Response.Response != nil { 235 sc = result.dwac.Response.Response.StatusCode 236 } 237 tracing.EndSpan(ctx, sc, err) 238 }() 239 } 240 result.fn = client.listByLocationNextResults 241 req, err := client.ListByLocationPreparer(ctx, location) 242 if err != nil { 243 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "ListByLocation", nil, "Failure preparing request") 244 return 245 } 246 247 resp, err := client.ListByLocationSender(req) 248 if err != nil { 249 result.dwac.Response = autorest.Response{Response: resp} 250 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "ListByLocation", resp, "Failure sending request") 251 return 252 } 253 254 result.dwac, err = client.ListByLocationResponder(resp) 255 if err != nil { 256 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "ListByLocation", resp, "Failure responding to request") 257 } 258 259 return 260} 261 262// ListByLocationPreparer prepares the ListByLocation request. 263func (client DeletedWebAppsClient) ListByLocationPreparer(ctx context.Context, location string) (*http.Request, error) { 264 pathParameters := map[string]interface{}{ 265 "location": autorest.Encode("path", location), 266 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 267 } 268 269 const APIVersion = "2019-08-01" 270 queryParameters := map[string]interface{}{ 271 "api-version": APIVersion, 272 } 273 274 preparer := autorest.CreatePreparer( 275 autorest.AsGet(), 276 autorest.WithBaseURL(client.BaseURI), 277 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Web/locations/{location}/deletedSites", pathParameters), 278 autorest.WithQueryParameters(queryParameters)) 279 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 280} 281 282// ListByLocationSender sends the ListByLocation request. The method will close the 283// http.Response Body if it receives an error. 284func (client DeletedWebAppsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { 285 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 286} 287 288// ListByLocationResponder handles the response to the ListByLocation request. The method always 289// closes the http.Response Body. 290func (client DeletedWebAppsClient) ListByLocationResponder(resp *http.Response) (result DeletedWebAppCollection, err error) { 291 err = autorest.Respond( 292 resp, 293 client.ByInspecting(), 294 azure.WithErrorUnlessStatusCode(http.StatusOK), 295 autorest.ByUnmarshallingJSON(&result), 296 autorest.ByClosing()) 297 result.Response = autorest.Response{Response: resp} 298 return 299} 300 301// listByLocationNextResults retrieves the next set of results, if any. 302func (client DeletedWebAppsClient) listByLocationNextResults(ctx context.Context, lastResults DeletedWebAppCollection) (result DeletedWebAppCollection, err error) { 303 req, err := lastResults.deletedWebAppCollectionPreparer(ctx) 304 if err != nil { 305 return result, autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "listByLocationNextResults", nil, "Failure preparing next results request") 306 } 307 if req == nil { 308 return 309 } 310 resp, err := client.ListByLocationSender(req) 311 if err != nil { 312 result.Response = autorest.Response{Response: resp} 313 return result, autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "listByLocationNextResults", resp, "Failure sending next results request") 314 } 315 result, err = client.ListByLocationResponder(resp) 316 if err != nil { 317 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "listByLocationNextResults", resp, "Failure responding to next results request") 318 } 319 return 320} 321 322// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. 323func (client DeletedWebAppsClient) ListByLocationComplete(ctx context.Context, location string) (result DeletedWebAppCollectionIterator, err error) { 324 if tracing.IsEnabled() { 325 ctx = tracing.StartSpan(ctx, fqdn+"/DeletedWebAppsClient.ListByLocation") 326 defer func() { 327 sc := -1 328 if result.Response().Response.Response != nil { 329 sc = result.page.Response().Response.Response.StatusCode 330 } 331 tracing.EndSpan(ctx, sc, err) 332 }() 333 } 334 result.page, err = client.ListByLocation(ctx, location) 335 return 336} 337