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. 39func NewDeletedWebAppsClientWithBaseURI(baseURI string, subscriptionID string) DeletedWebAppsClient { 40 return DeletedWebAppsClient{NewWithBaseURI(baseURI, subscriptionID)} 41} 42 43// GetDeletedWebAppByLocation description for Get deleted app for a subscription at location. 44// Parameters: 45// deletedSiteID - the numeric ID of the deleted app, e.g. 12345 46func (client DeletedWebAppsClient) GetDeletedWebAppByLocation(ctx context.Context, location string, deletedSiteID string) (result DeletedSite, err error) { 47 if tracing.IsEnabled() { 48 ctx = tracing.StartSpan(ctx, fqdn+"/DeletedWebAppsClient.GetDeletedWebAppByLocation") 49 defer func() { 50 sc := -1 51 if result.Response.Response != nil { 52 sc = result.Response.Response.StatusCode 53 } 54 tracing.EndSpan(ctx, sc, err) 55 }() 56 } 57 req, err := client.GetDeletedWebAppByLocationPreparer(ctx, location, deletedSiteID) 58 if err != nil { 59 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "GetDeletedWebAppByLocation", nil, "Failure preparing request") 60 return 61 } 62 63 resp, err := client.GetDeletedWebAppByLocationSender(req) 64 if err != nil { 65 result.Response = autorest.Response{Response: resp} 66 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "GetDeletedWebAppByLocation", resp, "Failure sending request") 67 return 68 } 69 70 result, err = client.GetDeletedWebAppByLocationResponder(resp) 71 if err != nil { 72 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "GetDeletedWebAppByLocation", resp, "Failure responding to request") 73 } 74 75 return 76} 77 78// GetDeletedWebAppByLocationPreparer prepares the GetDeletedWebAppByLocation request. 79func (client DeletedWebAppsClient) GetDeletedWebAppByLocationPreparer(ctx context.Context, location string, deletedSiteID string) (*http.Request, error) { 80 pathParameters := map[string]interface{}{ 81 "deletedSiteId": autorest.Encode("path", deletedSiteID), 82 "location": autorest.Encode("path", location), 83 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 84 } 85 86 const APIVersion = "2019-08-01" 87 queryParameters := map[string]interface{}{ 88 "api-version": APIVersion, 89 } 90 91 preparer := autorest.CreatePreparer( 92 autorest.AsGet(), 93 autorest.WithBaseURL(client.BaseURI), 94 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Web/locations/{location}/deletedSites/{deletedSiteId}", pathParameters), 95 autorest.WithQueryParameters(queryParameters)) 96 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 97} 98 99// GetDeletedWebAppByLocationSender sends the GetDeletedWebAppByLocation request. The method will close the 100// http.Response Body if it receives an error. 101func (client DeletedWebAppsClient) GetDeletedWebAppByLocationSender(req *http.Request) (*http.Response, error) { 102 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 103 return autorest.SendWithSender(client, req, sd...) 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 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 176 return autorest.SendWithSender(client, req, sd...) 177} 178 179// ListResponder handles the response to the List request. The method always 180// closes the http.Response Body. 181func (client DeletedWebAppsClient) ListResponder(resp *http.Response) (result DeletedWebAppCollection, err error) { 182 err = autorest.Respond( 183 resp, 184 client.ByInspecting(), 185 azure.WithErrorUnlessStatusCode(http.StatusOK), 186 autorest.ByUnmarshallingJSON(&result), 187 autorest.ByClosing()) 188 result.Response = autorest.Response{Response: resp} 189 return 190} 191 192// listNextResults retrieves the next set of results, if any. 193func (client DeletedWebAppsClient) listNextResults(ctx context.Context, lastResults DeletedWebAppCollection) (result DeletedWebAppCollection, err error) { 194 req, err := lastResults.deletedWebAppCollectionPreparer(ctx) 195 if err != nil { 196 return result, autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "listNextResults", nil, "Failure preparing next results request") 197 } 198 if req == nil { 199 return 200 } 201 resp, err := client.ListSender(req) 202 if err != nil { 203 result.Response = autorest.Response{Response: resp} 204 return result, autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "listNextResults", resp, "Failure sending next results request") 205 } 206 result, err = client.ListResponder(resp) 207 if err != nil { 208 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "listNextResults", resp, "Failure responding to next results request") 209 } 210 return 211} 212 213// ListComplete enumerates all values, automatically crossing page boundaries as required. 214func (client DeletedWebAppsClient) ListComplete(ctx context.Context) (result DeletedWebAppCollectionIterator, err error) { 215 if tracing.IsEnabled() { 216 ctx = tracing.StartSpan(ctx, fqdn+"/DeletedWebAppsClient.List") 217 defer func() { 218 sc := -1 219 if result.Response().Response.Response != nil { 220 sc = result.page.Response().Response.Response.StatusCode 221 } 222 tracing.EndSpan(ctx, sc, err) 223 }() 224 } 225 result.page, err = client.List(ctx) 226 return 227} 228 229// ListByLocation description for Get all deleted apps for a subscription at location 230func (client DeletedWebAppsClient) ListByLocation(ctx context.Context, location string) (result DeletedWebAppCollectionPage, err error) { 231 if tracing.IsEnabled() { 232 ctx = tracing.StartSpan(ctx, fqdn+"/DeletedWebAppsClient.ListByLocation") 233 defer func() { 234 sc := -1 235 if result.dwac.Response.Response != nil { 236 sc = result.dwac.Response.Response.StatusCode 237 } 238 tracing.EndSpan(ctx, sc, err) 239 }() 240 } 241 result.fn = client.listByLocationNextResults 242 req, err := client.ListByLocationPreparer(ctx, location) 243 if err != nil { 244 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "ListByLocation", nil, "Failure preparing request") 245 return 246 } 247 248 resp, err := client.ListByLocationSender(req) 249 if err != nil { 250 result.dwac.Response = autorest.Response{Response: resp} 251 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "ListByLocation", resp, "Failure sending request") 252 return 253 } 254 255 result.dwac, err = client.ListByLocationResponder(resp) 256 if err != nil { 257 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "ListByLocation", resp, "Failure responding to request") 258 } 259 260 return 261} 262 263// ListByLocationPreparer prepares the ListByLocation request. 264func (client DeletedWebAppsClient) ListByLocationPreparer(ctx context.Context, location string) (*http.Request, error) { 265 pathParameters := map[string]interface{}{ 266 "location": autorest.Encode("path", location), 267 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 268 } 269 270 const APIVersion = "2019-08-01" 271 queryParameters := map[string]interface{}{ 272 "api-version": APIVersion, 273 } 274 275 preparer := autorest.CreatePreparer( 276 autorest.AsGet(), 277 autorest.WithBaseURL(client.BaseURI), 278 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Web/locations/{location}/deletedSites", pathParameters), 279 autorest.WithQueryParameters(queryParameters)) 280 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 281} 282 283// ListByLocationSender sends the ListByLocation request. The method will close the 284// http.Response Body if it receives an error. 285func (client DeletedWebAppsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { 286 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 287 return autorest.SendWithSender(client, req, sd...) 288} 289 290// ListByLocationResponder handles the response to the ListByLocation request. The method always 291// closes the http.Response Body. 292func (client DeletedWebAppsClient) ListByLocationResponder(resp *http.Response) (result DeletedWebAppCollection, err error) { 293 err = autorest.Respond( 294 resp, 295 client.ByInspecting(), 296 azure.WithErrorUnlessStatusCode(http.StatusOK), 297 autorest.ByUnmarshallingJSON(&result), 298 autorest.ByClosing()) 299 result.Response = autorest.Response{Response: resp} 300 return 301} 302 303// listByLocationNextResults retrieves the next set of results, if any. 304func (client DeletedWebAppsClient) listByLocationNextResults(ctx context.Context, lastResults DeletedWebAppCollection) (result DeletedWebAppCollection, err error) { 305 req, err := lastResults.deletedWebAppCollectionPreparer(ctx) 306 if err != nil { 307 return result, autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "listByLocationNextResults", nil, "Failure preparing next results request") 308 } 309 if req == nil { 310 return 311 } 312 resp, err := client.ListByLocationSender(req) 313 if err != nil { 314 result.Response = autorest.Response{Response: resp} 315 return result, autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "listByLocationNextResults", resp, "Failure sending next results request") 316 } 317 result, err = client.ListByLocationResponder(resp) 318 if err != nil { 319 err = autorest.NewErrorWithError(err, "web.DeletedWebAppsClient", "listByLocationNextResults", resp, "Failure responding to next results request") 320 } 321 return 322} 323 324// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. 325func (client DeletedWebAppsClient) ListByLocationComplete(ctx context.Context, location string) (result DeletedWebAppCollectionIterator, err error) { 326 if tracing.IsEnabled() { 327 ctx = tracing.StartSpan(ctx, fqdn+"/DeletedWebAppsClient.ListByLocation") 328 defer func() { 329 sc := -1 330 if result.Response().Response.Response != nil { 331 sc = result.page.Response().Response.Response.StatusCode 332 } 333 tracing.EndSpan(ctx, sc, err) 334 }() 335 } 336 result.page, err = client.ListByLocation(ctx, location) 337 return 338} 339