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