1package network
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// PacketCapturesClient is the network Client
30type PacketCapturesClient struct {
31	BaseClient
32}
33
34// NewPacketCapturesClient creates an instance of the PacketCapturesClient client.
35func NewPacketCapturesClient(subscriptionID string) PacketCapturesClient {
36	return NewPacketCapturesClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// NewPacketCapturesClientWithBaseURI creates an instance of the PacketCapturesClient 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 NewPacketCapturesClientWithBaseURI(baseURI string, subscriptionID string) PacketCapturesClient {
42	return PacketCapturesClient{NewWithBaseURI(baseURI, subscriptionID)}
43}
44
45// Create create and start a packet capture on the specified VM.
46// Parameters:
47// resourceGroupName - the name of the resource group.
48// networkWatcherName - the name of the network watcher.
49// packetCaptureName - the name of the packet capture session.
50// parameters - parameters that define the create packet capture operation.
51func (client PacketCapturesClient) Create(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string, parameters PacketCapture) (result PacketCapturesCreateFuture, err error) {
52	if tracing.IsEnabled() {
53		ctx = tracing.StartSpan(ctx, fqdn+"/PacketCapturesClient.Create")
54		defer func() {
55			sc := -1
56			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
57				sc = result.FutureAPI.Response().StatusCode
58			}
59			tracing.EndSpan(ctx, sc, err)
60		}()
61	}
62	if err := validation.Validate([]validation.Validation{
63		{TargetValue: parameters,
64			Constraints: []validation.Constraint{{Target: "parameters.PacketCaptureParameters", Name: validation.Null, Rule: true,
65				Chain: []validation.Constraint{{Target: "parameters.PacketCaptureParameters.Target", Name: validation.Null, Rule: true, Chain: nil},
66					{Target: "parameters.PacketCaptureParameters.StorageLocation", Name: validation.Null, Rule: true, Chain: nil},
67				}}}}}); err != nil {
68		return result, validation.NewError("network.PacketCapturesClient", "Create", err.Error())
69	}
70
71	req, err := client.CreatePreparer(ctx, resourceGroupName, networkWatcherName, packetCaptureName, parameters)
72	if err != nil {
73		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Create", nil, "Failure preparing request")
74		return
75	}
76
77	result, err = client.CreateSender(req)
78	if err != nil {
79		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Create", nil, "Failure sending request")
80		return
81	}
82
83	return
84}
85
86// CreatePreparer prepares the Create request.
87func (client PacketCapturesClient) CreatePreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string, parameters PacketCapture) (*http.Request, error) {
88	pathParameters := map[string]interface{}{
89		"networkWatcherName": autorest.Encode("path", networkWatcherName),
90		"packetCaptureName":  autorest.Encode("path", packetCaptureName),
91		"resourceGroupName":  autorest.Encode("path", resourceGroupName),
92		"subscriptionId":     autorest.Encode("path", client.SubscriptionID),
93	}
94
95	const APIVersion = "2018-02-01"
96	queryParameters := map[string]interface{}{
97		"api-version": APIVersion,
98	}
99
100	preparer := autorest.CreatePreparer(
101		autorest.AsContentType("application/json; charset=utf-8"),
102		autorest.AsPut(),
103		autorest.WithBaseURL(client.BaseURI),
104		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}", pathParameters),
105		autorest.WithJSON(parameters),
106		autorest.WithQueryParameters(queryParameters))
107	return preparer.Prepare((&http.Request{}).WithContext(ctx))
108}
109
110// CreateSender sends the Create request. The method will close the
111// http.Response Body if it receives an error.
112func (client PacketCapturesClient) CreateSender(req *http.Request) (future PacketCapturesCreateFuture, err error) {
113	var resp *http.Response
114	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
115	if err != nil {
116		return
117	}
118	var azf azure.Future
119	azf, err = azure.NewFutureFromResponse(resp)
120	future.FutureAPI = &azf
121	future.Result = func(client PacketCapturesClient) (pcr PacketCaptureResult, err error) {
122		var done bool
123		done, err = future.DoneWithContext(context.Background(), client)
124		if err != nil {
125			err = autorest.NewErrorWithError(err, "network.PacketCapturesCreateFuture", "Result", future.Response(), "Polling failure")
126			return
127		}
128		if !done {
129			err = azure.NewAsyncOpIncompleteError("network.PacketCapturesCreateFuture")
130			return
131		}
132		sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
133		pcr.Response.Response, err = future.GetResult(sender)
134		if pcr.Response.Response == nil && err == nil {
135			err = autorest.NewErrorWithError(err, "network.PacketCapturesCreateFuture", "Result", nil, "received nil response and error")
136		}
137		if err == nil && pcr.Response.Response.StatusCode != http.StatusNoContent {
138			pcr, err = client.CreateResponder(pcr.Response.Response)
139			if err != nil {
140				err = autorest.NewErrorWithError(err, "network.PacketCapturesCreateFuture", "Result", pcr.Response.Response, "Failure responding to request")
141			}
142		}
143		return
144	}
145	return
146}
147
148// CreateResponder handles the response to the Create request. The method always
149// closes the http.Response Body.
150func (client PacketCapturesClient) CreateResponder(resp *http.Response) (result PacketCaptureResult, err error) {
151	err = autorest.Respond(
152		resp,
153		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
154		autorest.ByUnmarshallingJSON(&result),
155		autorest.ByClosing())
156	result.Response = autorest.Response{Response: resp}
157	return
158}
159
160// Delete deletes the specified packet capture session.
161// Parameters:
162// resourceGroupName - the name of the resource group.
163// networkWatcherName - the name of the network watcher.
164// packetCaptureName - the name of the packet capture session.
165func (client PacketCapturesClient) Delete(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string) (result PacketCapturesDeleteFuture, err error) {
166	if tracing.IsEnabled() {
167		ctx = tracing.StartSpan(ctx, fqdn+"/PacketCapturesClient.Delete")
168		defer func() {
169			sc := -1
170			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
171				sc = result.FutureAPI.Response().StatusCode
172			}
173			tracing.EndSpan(ctx, sc, err)
174		}()
175	}
176	req, err := client.DeletePreparer(ctx, resourceGroupName, networkWatcherName, packetCaptureName)
177	if err != nil {
178		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Delete", nil, "Failure preparing request")
179		return
180	}
181
182	result, err = client.DeleteSender(req)
183	if err != nil {
184		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Delete", nil, "Failure sending request")
185		return
186	}
187
188	return
189}
190
191// DeletePreparer prepares the Delete request.
192func (client PacketCapturesClient) DeletePreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string) (*http.Request, error) {
193	pathParameters := map[string]interface{}{
194		"networkWatcherName": autorest.Encode("path", networkWatcherName),
195		"packetCaptureName":  autorest.Encode("path", packetCaptureName),
196		"resourceGroupName":  autorest.Encode("path", resourceGroupName),
197		"subscriptionId":     autorest.Encode("path", client.SubscriptionID),
198	}
199
200	const APIVersion = "2018-02-01"
201	queryParameters := map[string]interface{}{
202		"api-version": APIVersion,
203	}
204
205	preparer := autorest.CreatePreparer(
206		autorest.AsDelete(),
207		autorest.WithBaseURL(client.BaseURI),
208		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}", pathParameters),
209		autorest.WithQueryParameters(queryParameters))
210	return preparer.Prepare((&http.Request{}).WithContext(ctx))
211}
212
213// DeleteSender sends the Delete request. The method will close the
214// http.Response Body if it receives an error.
215func (client PacketCapturesClient) DeleteSender(req *http.Request) (future PacketCapturesDeleteFuture, err error) {
216	var resp *http.Response
217	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
218	if err != nil {
219		return
220	}
221	var azf azure.Future
222	azf, err = azure.NewFutureFromResponse(resp)
223	future.FutureAPI = &azf
224	future.Result = func(client PacketCapturesClient) (ar autorest.Response, err error) {
225		var done bool
226		done, err = future.DoneWithContext(context.Background(), client)
227		if err != nil {
228			err = autorest.NewErrorWithError(err, "network.PacketCapturesDeleteFuture", "Result", future.Response(), "Polling failure")
229			return
230		}
231		if !done {
232			err = azure.NewAsyncOpIncompleteError("network.PacketCapturesDeleteFuture")
233			return
234		}
235		ar.Response = future.Response()
236		return
237	}
238	return
239}
240
241// DeleteResponder handles the response to the Delete request. The method always
242// closes the http.Response Body.
243func (client PacketCapturesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
244	err = autorest.Respond(
245		resp,
246		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
247		autorest.ByClosing())
248	result.Response = resp
249	return
250}
251
252// Get gets a packet capture session by name.
253// Parameters:
254// resourceGroupName - the name of the resource group.
255// networkWatcherName - the name of the network watcher.
256// packetCaptureName - the name of the packet capture session.
257func (client PacketCapturesClient) Get(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string) (result PacketCaptureResult, err error) {
258	if tracing.IsEnabled() {
259		ctx = tracing.StartSpan(ctx, fqdn+"/PacketCapturesClient.Get")
260		defer func() {
261			sc := -1
262			if result.Response.Response != nil {
263				sc = result.Response.Response.StatusCode
264			}
265			tracing.EndSpan(ctx, sc, err)
266		}()
267	}
268	req, err := client.GetPreparer(ctx, resourceGroupName, networkWatcherName, packetCaptureName)
269	if err != nil {
270		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Get", nil, "Failure preparing request")
271		return
272	}
273
274	resp, err := client.GetSender(req)
275	if err != nil {
276		result.Response = autorest.Response{Response: resp}
277		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Get", resp, "Failure sending request")
278		return
279	}
280
281	result, err = client.GetResponder(resp)
282	if err != nil {
283		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Get", resp, "Failure responding to request")
284		return
285	}
286
287	return
288}
289
290// GetPreparer prepares the Get request.
291func (client PacketCapturesClient) GetPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string) (*http.Request, error) {
292	pathParameters := map[string]interface{}{
293		"networkWatcherName": autorest.Encode("path", networkWatcherName),
294		"packetCaptureName":  autorest.Encode("path", packetCaptureName),
295		"resourceGroupName":  autorest.Encode("path", resourceGroupName),
296		"subscriptionId":     autorest.Encode("path", client.SubscriptionID),
297	}
298
299	const APIVersion = "2018-02-01"
300	queryParameters := map[string]interface{}{
301		"api-version": APIVersion,
302	}
303
304	preparer := autorest.CreatePreparer(
305		autorest.AsGet(),
306		autorest.WithBaseURL(client.BaseURI),
307		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}", pathParameters),
308		autorest.WithQueryParameters(queryParameters))
309	return preparer.Prepare((&http.Request{}).WithContext(ctx))
310}
311
312// GetSender sends the Get request. The method will close the
313// http.Response Body if it receives an error.
314func (client PacketCapturesClient) GetSender(req *http.Request) (*http.Response, error) {
315	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
316}
317
318// GetResponder handles the response to the Get request. The method always
319// closes the http.Response Body.
320func (client PacketCapturesClient) GetResponder(resp *http.Response) (result PacketCaptureResult, err error) {
321	err = autorest.Respond(
322		resp,
323		azure.WithErrorUnlessStatusCode(http.StatusOK),
324		autorest.ByUnmarshallingJSON(&result),
325		autorest.ByClosing())
326	result.Response = autorest.Response{Response: resp}
327	return
328}
329
330// GetStatus query the status of a running packet capture session.
331// Parameters:
332// resourceGroupName - the name of the resource group.
333// networkWatcherName - the name of the Network Watcher resource.
334// packetCaptureName - the name given to the packet capture session.
335func (client PacketCapturesClient) GetStatus(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string) (result PacketCapturesGetStatusFuture, err error) {
336	if tracing.IsEnabled() {
337		ctx = tracing.StartSpan(ctx, fqdn+"/PacketCapturesClient.GetStatus")
338		defer func() {
339			sc := -1
340			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
341				sc = result.FutureAPI.Response().StatusCode
342			}
343			tracing.EndSpan(ctx, sc, err)
344		}()
345	}
346	req, err := client.GetStatusPreparer(ctx, resourceGroupName, networkWatcherName, packetCaptureName)
347	if err != nil {
348		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "GetStatus", nil, "Failure preparing request")
349		return
350	}
351
352	result, err = client.GetStatusSender(req)
353	if err != nil {
354		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "GetStatus", nil, "Failure sending request")
355		return
356	}
357
358	return
359}
360
361// GetStatusPreparer prepares the GetStatus request.
362func (client PacketCapturesClient) GetStatusPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string) (*http.Request, error) {
363	pathParameters := map[string]interface{}{
364		"networkWatcherName": autorest.Encode("path", networkWatcherName),
365		"packetCaptureName":  autorest.Encode("path", packetCaptureName),
366		"resourceGroupName":  autorest.Encode("path", resourceGroupName),
367		"subscriptionId":     autorest.Encode("path", client.SubscriptionID),
368	}
369
370	const APIVersion = "2018-02-01"
371	queryParameters := map[string]interface{}{
372		"api-version": APIVersion,
373	}
374
375	preparer := autorest.CreatePreparer(
376		autorest.AsPost(),
377		autorest.WithBaseURL(client.BaseURI),
378		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}/queryStatus", pathParameters),
379		autorest.WithQueryParameters(queryParameters))
380	return preparer.Prepare((&http.Request{}).WithContext(ctx))
381}
382
383// GetStatusSender sends the GetStatus request. The method will close the
384// http.Response Body if it receives an error.
385func (client PacketCapturesClient) GetStatusSender(req *http.Request) (future PacketCapturesGetStatusFuture, err error) {
386	var resp *http.Response
387	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
388	if err != nil {
389		return
390	}
391	var azf azure.Future
392	azf, err = azure.NewFutureFromResponse(resp)
393	future.FutureAPI = &azf
394	future.Result = func(client PacketCapturesClient) (pcqsr PacketCaptureQueryStatusResult, err error) {
395		var done bool
396		done, err = future.DoneWithContext(context.Background(), client)
397		if err != nil {
398			err = autorest.NewErrorWithError(err, "network.PacketCapturesGetStatusFuture", "Result", future.Response(), "Polling failure")
399			return
400		}
401		if !done {
402			err = azure.NewAsyncOpIncompleteError("network.PacketCapturesGetStatusFuture")
403			return
404		}
405		sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
406		pcqsr.Response.Response, err = future.GetResult(sender)
407		if pcqsr.Response.Response == nil && err == nil {
408			err = autorest.NewErrorWithError(err, "network.PacketCapturesGetStatusFuture", "Result", nil, "received nil response and error")
409		}
410		if err == nil && pcqsr.Response.Response.StatusCode != http.StatusNoContent {
411			pcqsr, err = client.GetStatusResponder(pcqsr.Response.Response)
412			if err != nil {
413				err = autorest.NewErrorWithError(err, "network.PacketCapturesGetStatusFuture", "Result", pcqsr.Response.Response, "Failure responding to request")
414			}
415		}
416		return
417	}
418	return
419}
420
421// GetStatusResponder handles the response to the GetStatus request. The method always
422// closes the http.Response Body.
423func (client PacketCapturesClient) GetStatusResponder(resp *http.Response) (result PacketCaptureQueryStatusResult, err error) {
424	err = autorest.Respond(
425		resp,
426		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
427		autorest.ByUnmarshallingJSON(&result),
428		autorest.ByClosing())
429	result.Response = autorest.Response{Response: resp}
430	return
431}
432
433// List lists all packet capture sessions within the specified resource group.
434// Parameters:
435// resourceGroupName - the name of the resource group.
436// networkWatcherName - the name of the Network Watcher resource.
437func (client PacketCapturesClient) List(ctx context.Context, resourceGroupName string, networkWatcherName string) (result PacketCaptureListResult, err error) {
438	if tracing.IsEnabled() {
439		ctx = tracing.StartSpan(ctx, fqdn+"/PacketCapturesClient.List")
440		defer func() {
441			sc := -1
442			if result.Response.Response != nil {
443				sc = result.Response.Response.StatusCode
444			}
445			tracing.EndSpan(ctx, sc, err)
446		}()
447	}
448	req, err := client.ListPreparer(ctx, resourceGroupName, networkWatcherName)
449	if err != nil {
450		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "List", nil, "Failure preparing request")
451		return
452	}
453
454	resp, err := client.ListSender(req)
455	if err != nil {
456		result.Response = autorest.Response{Response: resp}
457		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "List", resp, "Failure sending request")
458		return
459	}
460
461	result, err = client.ListResponder(resp)
462	if err != nil {
463		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "List", resp, "Failure responding to request")
464		return
465	}
466
467	return
468}
469
470// ListPreparer prepares the List request.
471func (client PacketCapturesClient) ListPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string) (*http.Request, error) {
472	pathParameters := map[string]interface{}{
473		"networkWatcherName": autorest.Encode("path", networkWatcherName),
474		"resourceGroupName":  autorest.Encode("path", resourceGroupName),
475		"subscriptionId":     autorest.Encode("path", client.SubscriptionID),
476	}
477
478	const APIVersion = "2018-02-01"
479	queryParameters := map[string]interface{}{
480		"api-version": APIVersion,
481	}
482
483	preparer := autorest.CreatePreparer(
484		autorest.AsGet(),
485		autorest.WithBaseURL(client.BaseURI),
486		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures", pathParameters),
487		autorest.WithQueryParameters(queryParameters))
488	return preparer.Prepare((&http.Request{}).WithContext(ctx))
489}
490
491// ListSender sends the List request. The method will close the
492// http.Response Body if it receives an error.
493func (client PacketCapturesClient) ListSender(req *http.Request) (*http.Response, error) {
494	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
495}
496
497// ListResponder handles the response to the List request. The method always
498// closes the http.Response Body.
499func (client PacketCapturesClient) ListResponder(resp *http.Response) (result PacketCaptureListResult, err error) {
500	err = autorest.Respond(
501		resp,
502		azure.WithErrorUnlessStatusCode(http.StatusOK),
503		autorest.ByUnmarshallingJSON(&result),
504		autorest.ByClosing())
505	result.Response = autorest.Response{Response: resp}
506	return
507}
508
509// Stop stops a specified packet capture session.
510// Parameters:
511// resourceGroupName - the name of the resource group.
512// networkWatcherName - the name of the network watcher.
513// packetCaptureName - the name of the packet capture session.
514func (client PacketCapturesClient) Stop(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string) (result PacketCapturesStopFuture, err error) {
515	if tracing.IsEnabled() {
516		ctx = tracing.StartSpan(ctx, fqdn+"/PacketCapturesClient.Stop")
517		defer func() {
518			sc := -1
519			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
520				sc = result.FutureAPI.Response().StatusCode
521			}
522			tracing.EndSpan(ctx, sc, err)
523		}()
524	}
525	req, err := client.StopPreparer(ctx, resourceGroupName, networkWatcherName, packetCaptureName)
526	if err != nil {
527		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Stop", nil, "Failure preparing request")
528		return
529	}
530
531	result, err = client.StopSender(req)
532	if err != nil {
533		err = autorest.NewErrorWithError(err, "network.PacketCapturesClient", "Stop", nil, "Failure sending request")
534		return
535	}
536
537	return
538}
539
540// StopPreparer prepares the Stop request.
541func (client PacketCapturesClient) StopPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, packetCaptureName string) (*http.Request, error) {
542	pathParameters := map[string]interface{}{
543		"networkWatcherName": autorest.Encode("path", networkWatcherName),
544		"packetCaptureName":  autorest.Encode("path", packetCaptureName),
545		"resourceGroupName":  autorest.Encode("path", resourceGroupName),
546		"subscriptionId":     autorest.Encode("path", client.SubscriptionID),
547	}
548
549	const APIVersion = "2018-02-01"
550	queryParameters := map[string]interface{}{
551		"api-version": APIVersion,
552	}
553
554	preparer := autorest.CreatePreparer(
555		autorest.AsPost(),
556		autorest.WithBaseURL(client.BaseURI),
557		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}/stop", pathParameters),
558		autorest.WithQueryParameters(queryParameters))
559	return preparer.Prepare((&http.Request{}).WithContext(ctx))
560}
561
562// StopSender sends the Stop request. The method will close the
563// http.Response Body if it receives an error.
564func (client PacketCapturesClient) StopSender(req *http.Request) (future PacketCapturesStopFuture, err error) {
565	var resp *http.Response
566	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
567	if err != nil {
568		return
569	}
570	var azf azure.Future
571	azf, err = azure.NewFutureFromResponse(resp)
572	future.FutureAPI = &azf
573	future.Result = func(client PacketCapturesClient) (ar autorest.Response, err error) {
574		var done bool
575		done, err = future.DoneWithContext(context.Background(), client)
576		if err != nil {
577			err = autorest.NewErrorWithError(err, "network.PacketCapturesStopFuture", "Result", future.Response(), "Polling failure")
578			return
579		}
580		if !done {
581			err = azure.NewAsyncOpIncompleteError("network.PacketCapturesStopFuture")
582			return
583		}
584		ar.Response = future.Response()
585		return
586	}
587	return
588}
589
590// StopResponder handles the response to the Stop request. The method always
591// closes the http.Response Body.
592func (client PacketCapturesClient) StopResponder(resp *http.Response) (result autorest.Response, err error) {
593	err = autorest.Respond(
594		resp,
595		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
596		autorest.ByClosing())
597	result.Response = resp
598	return
599}
600