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