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