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 using a custom 40// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 41// stack). 42func NewConnectionMonitorsClientWithBaseURI(baseURI string, subscriptionID string) ConnectionMonitorsClient { 43 return ConnectionMonitorsClient{NewWithBaseURI(baseURI, subscriptionID)} 44} 45 46// CreateOrUpdate create or update a connection monitor. 47// Parameters: 48// resourceGroupName - the name of the resource group containing Network Watcher. 49// networkWatcherName - the name of the Network Watcher resource. 50// connectionMonitorName - the name of the connection monitor. 51// parameters - parameters that define the operation to create a connection monitor. 52func (client ConnectionMonitorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string, parameters ConnectionMonitor) (result ConnectionMonitorsCreateOrUpdateFuture, err error) { 53 if tracing.IsEnabled() { 54 ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorsClient.CreateOrUpdate") 55 defer func() { 56 sc := -1 57 if result.Response() != nil { 58 sc = result.Response().StatusCode 59 } 60 tracing.EndSpan(ctx, sc, err) 61 }() 62 } 63 if err := validation.Validate([]validation.Validation{ 64 {TargetValue: parameters, 65 Constraints: []validation.Constraint{{Target: "parameters.ConnectionMonitorParameters", Name: validation.Null, Rule: true, 66 Chain: []validation.Constraint{{Target: "parameters.ConnectionMonitorParameters.Source", Name: validation.Null, Rule: false, 67 Chain: []validation.Constraint{{Target: "parameters.ConnectionMonitorParameters.Source.ResourceID", Name: validation.Null, Rule: true, Chain: nil}}}, 68 }}}}}); err != nil { 69 return result, validation.NewError("network.ConnectionMonitorsClient", "CreateOrUpdate", err.Error()) 70 } 71 72 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, networkWatcherName, connectionMonitorName, parameters) 73 if err != nil { 74 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "CreateOrUpdate", nil, "Failure preparing request") 75 return 76 } 77 78 result, err = client.CreateOrUpdateSender(req) 79 if err != nil { 80 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "CreateOrUpdate", result.Response(), "Failure sending request") 81 return 82 } 83 84 return 85} 86 87// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 88func (client ConnectionMonitorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string, parameters ConnectionMonitor) (*http.Request, error) { 89 pathParameters := map[string]interface{}{ 90 "connectionMonitorName": autorest.Encode("path", connectionMonitorName), 91 "networkWatcherName": autorest.Encode("path", networkWatcherName), 92 "resourceGroupName": autorest.Encode("path", resourceGroupName), 93 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 94 } 95 96 const APIVersion = "2019-11-01" 97 queryParameters := map[string]interface{}{ 98 "api-version": APIVersion, 99 } 100 101 preparer := autorest.CreatePreparer( 102 autorest.AsContentType("application/json; charset=utf-8"), 103 autorest.AsPut(), 104 autorest.WithBaseURL(client.BaseURI), 105 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}", pathParameters), 106 autorest.WithJSON(parameters), 107 autorest.WithQueryParameters(queryParameters)) 108 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 109} 110 111// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 112// http.Response Body if it receives an error. 113func (client ConnectionMonitorsClient) CreateOrUpdateSender(req *http.Request) (future ConnectionMonitorsCreateOrUpdateFuture, err error) { 114 var resp *http.Response 115 resp, err = client.Send(req, 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 = "2019-11-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 = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 194 if err != nil { 195 return 196 } 197 future.Future, err = azure.NewFutureFromResponse(resp) 198 return 199} 200 201// DeleteResponder handles the response to the Delete request. The method always 202// closes the http.Response Body. 203func (client ConnectionMonitorsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 204 err = autorest.Respond( 205 resp, 206 client.ByInspecting(), 207 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 208 autorest.ByClosing()) 209 result.Response = resp 210 return 211} 212 213// Get gets a connection monitor by name. 214// Parameters: 215// resourceGroupName - the name of the resource group containing Network Watcher. 216// networkWatcherName - the name of the Network Watcher resource. 217// connectionMonitorName - the name of the connection monitor. 218func (client ConnectionMonitorsClient) Get(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string) (result ConnectionMonitorResult, err error) { 219 if tracing.IsEnabled() { 220 ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorsClient.Get") 221 defer func() { 222 sc := -1 223 if result.Response.Response != nil { 224 sc = result.Response.Response.StatusCode 225 } 226 tracing.EndSpan(ctx, sc, err) 227 }() 228 } 229 req, err := client.GetPreparer(ctx, resourceGroupName, networkWatcherName, connectionMonitorName) 230 if err != nil { 231 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "Get", nil, "Failure preparing request") 232 return 233 } 234 235 resp, err := client.GetSender(req) 236 if err != nil { 237 result.Response = autorest.Response{Response: resp} 238 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "Get", resp, "Failure sending request") 239 return 240 } 241 242 result, err = client.GetResponder(resp) 243 if err != nil { 244 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "Get", resp, "Failure responding to request") 245 } 246 247 return 248} 249 250// GetPreparer prepares the Get request. 251func (client ConnectionMonitorsClient) GetPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string) (*http.Request, error) { 252 pathParameters := map[string]interface{}{ 253 "connectionMonitorName": autorest.Encode("path", connectionMonitorName), 254 "networkWatcherName": autorest.Encode("path", networkWatcherName), 255 "resourceGroupName": autorest.Encode("path", resourceGroupName), 256 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 257 } 258 259 const APIVersion = "2019-11-01" 260 queryParameters := map[string]interface{}{ 261 "api-version": APIVersion, 262 } 263 264 preparer := autorest.CreatePreparer( 265 autorest.AsGet(), 266 autorest.WithBaseURL(client.BaseURI), 267 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}", pathParameters), 268 autorest.WithQueryParameters(queryParameters)) 269 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 270} 271 272// GetSender sends the Get request. The method will close the 273// http.Response Body if it receives an error. 274func (client ConnectionMonitorsClient) GetSender(req *http.Request) (*http.Response, error) { 275 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 276} 277 278// GetResponder handles the response to the Get request. The method always 279// closes the http.Response Body. 280func (client ConnectionMonitorsClient) GetResponder(resp *http.Response) (result ConnectionMonitorResult, err error) { 281 err = autorest.Respond( 282 resp, 283 client.ByInspecting(), 284 azure.WithErrorUnlessStatusCode(http.StatusOK), 285 autorest.ByUnmarshallingJSON(&result), 286 autorest.ByClosing()) 287 result.Response = autorest.Response{Response: resp} 288 return 289} 290 291// List lists all connection monitors for the specified Network Watcher. 292// Parameters: 293// resourceGroupName - the name of the resource group containing Network Watcher. 294// networkWatcherName - the name of the Network Watcher resource. 295func (client ConnectionMonitorsClient) List(ctx context.Context, resourceGroupName string, networkWatcherName string) (result ConnectionMonitorListResult, err error) { 296 if tracing.IsEnabled() { 297 ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorsClient.List") 298 defer func() { 299 sc := -1 300 if result.Response.Response != nil { 301 sc = result.Response.Response.StatusCode 302 } 303 tracing.EndSpan(ctx, sc, err) 304 }() 305 } 306 req, err := client.ListPreparer(ctx, resourceGroupName, networkWatcherName) 307 if err != nil { 308 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "List", nil, "Failure preparing request") 309 return 310 } 311 312 resp, err := client.ListSender(req) 313 if err != nil { 314 result.Response = autorest.Response{Response: resp} 315 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "List", resp, "Failure sending request") 316 return 317 } 318 319 result, err = client.ListResponder(resp) 320 if err != nil { 321 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "List", resp, "Failure responding to request") 322 } 323 324 return 325} 326 327// ListPreparer prepares the List request. 328func (client ConnectionMonitorsClient) ListPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string) (*http.Request, error) { 329 pathParameters := map[string]interface{}{ 330 "networkWatcherName": autorest.Encode("path", networkWatcherName), 331 "resourceGroupName": autorest.Encode("path", resourceGroupName), 332 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 333 } 334 335 const APIVersion = "2019-11-01" 336 queryParameters := map[string]interface{}{ 337 "api-version": APIVersion, 338 } 339 340 preparer := autorest.CreatePreparer( 341 autorest.AsGet(), 342 autorest.WithBaseURL(client.BaseURI), 343 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors", pathParameters), 344 autorest.WithQueryParameters(queryParameters)) 345 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 346} 347 348// ListSender sends the List request. The method will close the 349// http.Response Body if it receives an error. 350func (client ConnectionMonitorsClient) ListSender(req *http.Request) (*http.Response, error) { 351 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 352} 353 354// ListResponder handles the response to the List request. The method always 355// closes the http.Response Body. 356func (client ConnectionMonitorsClient) ListResponder(resp *http.Response) (result ConnectionMonitorListResult, err error) { 357 err = autorest.Respond( 358 resp, 359 client.ByInspecting(), 360 azure.WithErrorUnlessStatusCode(http.StatusOK), 361 autorest.ByUnmarshallingJSON(&result), 362 autorest.ByClosing()) 363 result.Response = autorest.Response{Response: resp} 364 return 365} 366 367// Query query a snapshot of the most recent connection states. 368// Parameters: 369// resourceGroupName - the name of the resource group containing Network Watcher. 370// networkWatcherName - the name of the Network Watcher resource. 371// connectionMonitorName - the name given to the connection monitor. 372func (client ConnectionMonitorsClient) Query(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string) (result ConnectionMonitorsQueryFuture, err error) { 373 if tracing.IsEnabled() { 374 ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorsClient.Query") 375 defer func() { 376 sc := -1 377 if result.Response() != nil { 378 sc = result.Response().StatusCode 379 } 380 tracing.EndSpan(ctx, sc, err) 381 }() 382 } 383 req, err := client.QueryPreparer(ctx, resourceGroupName, networkWatcherName, connectionMonitorName) 384 if err != nil { 385 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "Query", nil, "Failure preparing request") 386 return 387 } 388 389 result, err = client.QuerySender(req) 390 if err != nil { 391 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "Query", result.Response(), "Failure sending request") 392 return 393 } 394 395 return 396} 397 398// QueryPreparer prepares the Query request. 399func (client ConnectionMonitorsClient) QueryPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string) (*http.Request, error) { 400 pathParameters := map[string]interface{}{ 401 "connectionMonitorName": autorest.Encode("path", connectionMonitorName), 402 "networkWatcherName": autorest.Encode("path", networkWatcherName), 403 "resourceGroupName": autorest.Encode("path", resourceGroupName), 404 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 405 } 406 407 const APIVersion = "2019-11-01" 408 queryParameters := map[string]interface{}{ 409 "api-version": APIVersion, 410 } 411 412 preparer := autorest.CreatePreparer( 413 autorest.AsPost(), 414 autorest.WithBaseURL(client.BaseURI), 415 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}/query", pathParameters), 416 autorest.WithQueryParameters(queryParameters)) 417 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 418} 419 420// QuerySender sends the Query request. The method will close the 421// http.Response Body if it receives an error. 422func (client ConnectionMonitorsClient) QuerySender(req *http.Request) (future ConnectionMonitorsQueryFuture, err error) { 423 var resp *http.Response 424 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 425 if err != nil { 426 return 427 } 428 future.Future, err = azure.NewFutureFromResponse(resp) 429 return 430} 431 432// QueryResponder handles the response to the Query request. The method always 433// closes the http.Response Body. 434func (client ConnectionMonitorsClient) QueryResponder(resp *http.Response) (result ConnectionMonitorQueryResult, err error) { 435 err = autorest.Respond( 436 resp, 437 client.ByInspecting(), 438 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 439 autorest.ByUnmarshallingJSON(&result), 440 autorest.ByClosing()) 441 result.Response = autorest.Response{Response: resp} 442 return 443} 444 445// Start starts the specified connection monitor. 446// Parameters: 447// resourceGroupName - the name of the resource group containing Network Watcher. 448// networkWatcherName - the name of the Network Watcher resource. 449// connectionMonitorName - the name of the connection monitor. 450func (client ConnectionMonitorsClient) Start(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string) (result ConnectionMonitorsStartFuture, err error) { 451 if tracing.IsEnabled() { 452 ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorsClient.Start") 453 defer func() { 454 sc := -1 455 if result.Response() != nil { 456 sc = result.Response().StatusCode 457 } 458 tracing.EndSpan(ctx, sc, err) 459 }() 460 } 461 req, err := client.StartPreparer(ctx, resourceGroupName, networkWatcherName, connectionMonitorName) 462 if err != nil { 463 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "Start", nil, "Failure preparing request") 464 return 465 } 466 467 result, err = client.StartSender(req) 468 if err != nil { 469 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "Start", result.Response(), "Failure sending request") 470 return 471 } 472 473 return 474} 475 476// StartPreparer prepares the Start request. 477func (client ConnectionMonitorsClient) StartPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string) (*http.Request, error) { 478 pathParameters := map[string]interface{}{ 479 "connectionMonitorName": autorest.Encode("path", connectionMonitorName), 480 "networkWatcherName": autorest.Encode("path", networkWatcherName), 481 "resourceGroupName": autorest.Encode("path", resourceGroupName), 482 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 483 } 484 485 const APIVersion = "2019-11-01" 486 queryParameters := map[string]interface{}{ 487 "api-version": APIVersion, 488 } 489 490 preparer := autorest.CreatePreparer( 491 autorest.AsPost(), 492 autorest.WithBaseURL(client.BaseURI), 493 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}/start", pathParameters), 494 autorest.WithQueryParameters(queryParameters)) 495 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 496} 497 498// StartSender sends the Start request. The method will close the 499// http.Response Body if it receives an error. 500func (client ConnectionMonitorsClient) StartSender(req *http.Request) (future ConnectionMonitorsStartFuture, err error) { 501 var resp *http.Response 502 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 503 if err != nil { 504 return 505 } 506 future.Future, err = azure.NewFutureFromResponse(resp) 507 return 508} 509 510// StartResponder handles the response to the Start request. The method always 511// closes the http.Response Body. 512func (client ConnectionMonitorsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { 513 err = autorest.Respond( 514 resp, 515 client.ByInspecting(), 516 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 517 autorest.ByClosing()) 518 result.Response = resp 519 return 520} 521 522// Stop stops the specified connection monitor. 523// Parameters: 524// resourceGroupName - the name of the resource group containing Network Watcher. 525// networkWatcherName - the name of the Network Watcher resource. 526// connectionMonitorName - the name of the connection monitor. 527func (client ConnectionMonitorsClient) Stop(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string) (result ConnectionMonitorsStopFuture, err error) { 528 if tracing.IsEnabled() { 529 ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorsClient.Stop") 530 defer func() { 531 sc := -1 532 if result.Response() != nil { 533 sc = result.Response().StatusCode 534 } 535 tracing.EndSpan(ctx, sc, err) 536 }() 537 } 538 req, err := client.StopPreparer(ctx, resourceGroupName, networkWatcherName, connectionMonitorName) 539 if err != nil { 540 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "Stop", nil, "Failure preparing request") 541 return 542 } 543 544 result, err = client.StopSender(req) 545 if err != nil { 546 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "Stop", result.Response(), "Failure sending request") 547 return 548 } 549 550 return 551} 552 553// StopPreparer prepares the Stop request. 554func (client ConnectionMonitorsClient) StopPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string) (*http.Request, error) { 555 pathParameters := map[string]interface{}{ 556 "connectionMonitorName": autorest.Encode("path", connectionMonitorName), 557 "networkWatcherName": autorest.Encode("path", networkWatcherName), 558 "resourceGroupName": autorest.Encode("path", resourceGroupName), 559 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 560 } 561 562 const APIVersion = "2019-11-01" 563 queryParameters := map[string]interface{}{ 564 "api-version": APIVersion, 565 } 566 567 preparer := autorest.CreatePreparer( 568 autorest.AsPost(), 569 autorest.WithBaseURL(client.BaseURI), 570 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}/stop", pathParameters), 571 autorest.WithQueryParameters(queryParameters)) 572 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 573} 574 575// StopSender sends the Stop request. The method will close the 576// http.Response Body if it receives an error. 577func (client ConnectionMonitorsClient) StopSender(req *http.Request) (future ConnectionMonitorsStopFuture, err error) { 578 var resp *http.Response 579 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 580 if err != nil { 581 return 582 } 583 future.Future, err = azure.NewFutureFromResponse(resp) 584 return 585} 586 587// StopResponder handles the response to the Stop request. The method always 588// closes the http.Response Body. 589func (client ConnectionMonitorsClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { 590 err = autorest.Respond( 591 resp, 592 client.ByInspecting(), 593 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 594 autorest.ByClosing()) 595 result.Response = resp 596 return 597} 598 599// UpdateTags update tags of the specified connection monitor. 600// Parameters: 601// resourceGroupName - the name of the resource group. 602// networkWatcherName - the name of the network watcher. 603// connectionMonitorName - the name of the connection monitor. 604// parameters - parameters supplied to update connection monitor tags. 605func (client ConnectionMonitorsClient) UpdateTags(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string, parameters TagsObject) (result ConnectionMonitorResult, err error) { 606 if tracing.IsEnabled() { 607 ctx = tracing.StartSpan(ctx, fqdn+"/ConnectionMonitorsClient.UpdateTags") 608 defer func() { 609 sc := -1 610 if result.Response.Response != nil { 611 sc = result.Response.Response.StatusCode 612 } 613 tracing.EndSpan(ctx, sc, err) 614 }() 615 } 616 req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, networkWatcherName, connectionMonitorName, parameters) 617 if err != nil { 618 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "UpdateTags", nil, "Failure preparing request") 619 return 620 } 621 622 resp, err := client.UpdateTagsSender(req) 623 if err != nil { 624 result.Response = autorest.Response{Response: resp} 625 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "UpdateTags", resp, "Failure sending request") 626 return 627 } 628 629 result, err = client.UpdateTagsResponder(resp) 630 if err != nil { 631 err = autorest.NewErrorWithError(err, "network.ConnectionMonitorsClient", "UpdateTags", resp, "Failure responding to request") 632 } 633 634 return 635} 636 637// UpdateTagsPreparer prepares the UpdateTags request. 638func (client ConnectionMonitorsClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, connectionMonitorName string, parameters TagsObject) (*http.Request, error) { 639 pathParameters := map[string]interface{}{ 640 "connectionMonitorName": autorest.Encode("path", connectionMonitorName), 641 "networkWatcherName": autorest.Encode("path", networkWatcherName), 642 "resourceGroupName": autorest.Encode("path", resourceGroupName), 643 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 644 } 645 646 const APIVersion = "2019-11-01" 647 queryParameters := map[string]interface{}{ 648 "api-version": APIVersion, 649 } 650 651 preparer := autorest.CreatePreparer( 652 autorest.AsContentType("application/json; charset=utf-8"), 653 autorest.AsPatch(), 654 autorest.WithBaseURL(client.BaseURI), 655 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}", pathParameters), 656 autorest.WithJSON(parameters), 657 autorest.WithQueryParameters(queryParameters)) 658 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 659} 660 661// UpdateTagsSender sends the UpdateTags request. The method will close the 662// http.Response Body if it receives an error. 663func (client ConnectionMonitorsClient) UpdateTagsSender(req *http.Request) (*http.Response, error) { 664 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 665} 666 667// UpdateTagsResponder handles the response to the UpdateTags request. The method always 668// closes the http.Response Body. 669func (client ConnectionMonitorsClient) UpdateTagsResponder(resp *http.Response) (result ConnectionMonitorResult, err error) { 670 err = autorest.Respond( 671 resp, 672 client.ByInspecting(), 673 azure.WithErrorUnlessStatusCode(http.StatusOK), 674 autorest.ByUnmarshallingJSON(&result), 675 autorest.ByClosing()) 676 result.Response = autorest.Response{Response: resp} 677 return 678} 679