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// WatchersClient is the network Client 30type WatchersClient struct { 31 BaseClient 32} 33 34// NewWatchersClient creates an instance of the WatchersClient client. 35func NewWatchersClient(subscriptionID string) WatchersClient { 36 return NewWatchersClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewWatchersClientWithBaseURI creates an instance of the WatchersClient client. 40func NewWatchersClientWithBaseURI(baseURI string, subscriptionID string) WatchersClient { 41 return WatchersClient{NewWithBaseURI(baseURI, subscriptionID)} 42} 43 44// CheckConnectivity verifies the possibility of establishing a direct TCP connection from a virtual machine to a given 45// endpoint including another VM or an arbitrary remote server. 46// Parameters: 47// resourceGroupName - the name of the network watcher resource group. 48// networkWatcherName - the name of the network watcher resource. 49// parameters - parameters that determine how the connectivity check will be performed. 50func (client WatchersClient) CheckConnectivity(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters ConnectivityParameters) (result WatchersCheckConnectivityFuture, err error) { 51 if tracing.IsEnabled() { 52 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.CheckConnectivity") 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.Source", Name: validation.Null, Rule: true, 64 Chain: []validation.Constraint{{Target: "parameters.Source.ResourceID", Name: validation.Null, Rule: true, Chain: nil}}}, 65 {Target: "parameters.Destination", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 66 return result, validation.NewError("network.WatchersClient", "CheckConnectivity", err.Error()) 67 } 68 69 req, err := client.CheckConnectivityPreparer(ctx, resourceGroupName, networkWatcherName, parameters) 70 if err != nil { 71 err = autorest.NewErrorWithError(err, "network.WatchersClient", "CheckConnectivity", nil, "Failure preparing request") 72 return 73 } 74 75 result, err = client.CheckConnectivitySender(req) 76 if err != nil { 77 err = autorest.NewErrorWithError(err, "network.WatchersClient", "CheckConnectivity", result.Response(), "Failure sending request") 78 return 79 } 80 81 return 82} 83 84// CheckConnectivityPreparer prepares the CheckConnectivity request. 85func (client WatchersClient) CheckConnectivityPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters ConnectivityParameters) (*http.Request, error) { 86 pathParameters := map[string]interface{}{ 87 "networkWatcherName": autorest.Encode("path", networkWatcherName), 88 "resourceGroupName": autorest.Encode("path", resourceGroupName), 89 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 90 } 91 92 const APIVersion = "2018-01-01" 93 queryParameters := map[string]interface{}{ 94 "api-version": APIVersion, 95 } 96 97 preparer := autorest.CreatePreparer( 98 autorest.AsContentType("application/json; charset=utf-8"), 99 autorest.AsPost(), 100 autorest.WithBaseURL(client.BaseURI), 101 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectivityCheck", pathParameters), 102 autorest.WithJSON(parameters), 103 autorest.WithQueryParameters(queryParameters)) 104 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 105} 106 107// CheckConnectivitySender sends the CheckConnectivity request. The method will close the 108// http.Response Body if it receives an error. 109func (client WatchersClient) CheckConnectivitySender(req *http.Request) (future WatchersCheckConnectivityFuture, err error) { 110 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 111 var resp *http.Response 112 resp, err = autorest.SendWithSender(client, req, sd...) 113 if err != nil { 114 return 115 } 116 future.Future, err = azure.NewFutureFromResponse(resp) 117 return 118} 119 120// CheckConnectivityResponder handles the response to the CheckConnectivity request. The method always 121// closes the http.Response Body. 122func (client WatchersClient) CheckConnectivityResponder(resp *http.Response) (result ConnectivityInformation, err error) { 123 err = autorest.Respond( 124 resp, 125 client.ByInspecting(), 126 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 127 autorest.ByUnmarshallingJSON(&result), 128 autorest.ByClosing()) 129 result.Response = autorest.Response{Response: resp} 130 return 131} 132 133// CreateOrUpdate creates or updates a network watcher in the specified resource group. 134// Parameters: 135// resourceGroupName - the name of the resource group. 136// networkWatcherName - the name of the network watcher. 137// parameters - parameters that define the network watcher resource. 138func (client WatchersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters Watcher) (result Watcher, err error) { 139 if tracing.IsEnabled() { 140 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.CreateOrUpdate") 141 defer func() { 142 sc := -1 143 if result.Response.Response != nil { 144 sc = result.Response.Response.StatusCode 145 } 146 tracing.EndSpan(ctx, sc, err) 147 }() 148 } 149 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, networkWatcherName, parameters) 150 if err != nil { 151 err = autorest.NewErrorWithError(err, "network.WatchersClient", "CreateOrUpdate", nil, "Failure preparing request") 152 return 153 } 154 155 resp, err := client.CreateOrUpdateSender(req) 156 if err != nil { 157 result.Response = autorest.Response{Response: resp} 158 err = autorest.NewErrorWithError(err, "network.WatchersClient", "CreateOrUpdate", resp, "Failure sending request") 159 return 160 } 161 162 result, err = client.CreateOrUpdateResponder(resp) 163 if err != nil { 164 err = autorest.NewErrorWithError(err, "network.WatchersClient", "CreateOrUpdate", resp, "Failure responding to request") 165 } 166 167 return 168} 169 170// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 171func (client WatchersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters Watcher) (*http.Request, error) { 172 pathParameters := map[string]interface{}{ 173 "networkWatcherName": autorest.Encode("path", networkWatcherName), 174 "resourceGroupName": autorest.Encode("path", resourceGroupName), 175 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 176 } 177 178 const APIVersion = "2018-01-01" 179 queryParameters := map[string]interface{}{ 180 "api-version": APIVersion, 181 } 182 183 preparer := autorest.CreatePreparer( 184 autorest.AsContentType("application/json; charset=utf-8"), 185 autorest.AsPut(), 186 autorest.WithBaseURL(client.BaseURI), 187 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}", pathParameters), 188 autorest.WithJSON(parameters), 189 autorest.WithQueryParameters(queryParameters)) 190 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 191} 192 193// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 194// http.Response Body if it receives an error. 195func (client WatchersClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 196 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 197 return autorest.SendWithSender(client, req, sd...) 198} 199 200// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 201// closes the http.Response Body. 202func (client WatchersClient) CreateOrUpdateResponder(resp *http.Response) (result Watcher, err error) { 203 err = autorest.Respond( 204 resp, 205 client.ByInspecting(), 206 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 207 autorest.ByUnmarshallingJSON(&result), 208 autorest.ByClosing()) 209 result.Response = autorest.Response{Response: resp} 210 return 211} 212 213// Delete deletes the specified network watcher resource. 214// Parameters: 215// resourceGroupName - the name of the resource group. 216// networkWatcherName - the name of the network watcher. 217func (client WatchersClient) Delete(ctx context.Context, resourceGroupName string, networkWatcherName string) (result WatchersDeleteFuture, err error) { 218 if tracing.IsEnabled() { 219 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.Delete") 220 defer func() { 221 sc := -1 222 if result.Response() != nil { 223 sc = result.Response().StatusCode 224 } 225 tracing.EndSpan(ctx, sc, err) 226 }() 227 } 228 req, err := client.DeletePreparer(ctx, resourceGroupName, networkWatcherName) 229 if err != nil { 230 err = autorest.NewErrorWithError(err, "network.WatchersClient", "Delete", nil, "Failure preparing request") 231 return 232 } 233 234 result, err = client.DeleteSender(req) 235 if err != nil { 236 err = autorest.NewErrorWithError(err, "network.WatchersClient", "Delete", result.Response(), "Failure sending request") 237 return 238 } 239 240 return 241} 242 243// DeletePreparer prepares the Delete request. 244func (client WatchersClient) DeletePreparer(ctx context.Context, resourceGroupName string, networkWatcherName string) (*http.Request, error) { 245 pathParameters := map[string]interface{}{ 246 "networkWatcherName": autorest.Encode("path", networkWatcherName), 247 "resourceGroupName": autorest.Encode("path", resourceGroupName), 248 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 249 } 250 251 const APIVersion = "2018-01-01" 252 queryParameters := map[string]interface{}{ 253 "api-version": APIVersion, 254 } 255 256 preparer := autorest.CreatePreparer( 257 autorest.AsDelete(), 258 autorest.WithBaseURL(client.BaseURI), 259 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}", pathParameters), 260 autorest.WithQueryParameters(queryParameters)) 261 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 262} 263 264// DeleteSender sends the Delete request. The method will close the 265// http.Response Body if it receives an error. 266func (client WatchersClient) DeleteSender(req *http.Request) (future WatchersDeleteFuture, err error) { 267 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 268 var resp *http.Response 269 resp, err = autorest.SendWithSender(client, req, sd...) 270 if err != nil { 271 return 272 } 273 future.Future, err = azure.NewFutureFromResponse(resp) 274 return 275} 276 277// DeleteResponder handles the response to the Delete request. The method always 278// closes the http.Response Body. 279func (client WatchersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 280 err = autorest.Respond( 281 resp, 282 client.ByInspecting(), 283 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 284 autorest.ByClosing()) 285 result.Response = resp 286 return 287} 288 289// Get gets the specified network watcher by resource group. 290// Parameters: 291// resourceGroupName - the name of the resource group. 292// networkWatcherName - the name of the network watcher. 293func (client WatchersClient) Get(ctx context.Context, resourceGroupName string, networkWatcherName string) (result Watcher, err error) { 294 if tracing.IsEnabled() { 295 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.Get") 296 defer func() { 297 sc := -1 298 if result.Response.Response != nil { 299 sc = result.Response.Response.StatusCode 300 } 301 tracing.EndSpan(ctx, sc, err) 302 }() 303 } 304 req, err := client.GetPreparer(ctx, resourceGroupName, networkWatcherName) 305 if err != nil { 306 err = autorest.NewErrorWithError(err, "network.WatchersClient", "Get", nil, "Failure preparing request") 307 return 308 } 309 310 resp, err := client.GetSender(req) 311 if err != nil { 312 result.Response = autorest.Response{Response: resp} 313 err = autorest.NewErrorWithError(err, "network.WatchersClient", "Get", resp, "Failure sending request") 314 return 315 } 316 317 result, err = client.GetResponder(resp) 318 if err != nil { 319 err = autorest.NewErrorWithError(err, "network.WatchersClient", "Get", resp, "Failure responding to request") 320 } 321 322 return 323} 324 325// GetPreparer prepares the Get request. 326func (client WatchersClient) GetPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string) (*http.Request, error) { 327 pathParameters := map[string]interface{}{ 328 "networkWatcherName": autorest.Encode("path", networkWatcherName), 329 "resourceGroupName": autorest.Encode("path", resourceGroupName), 330 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 331 } 332 333 const APIVersion = "2018-01-01" 334 queryParameters := map[string]interface{}{ 335 "api-version": APIVersion, 336 } 337 338 preparer := autorest.CreatePreparer( 339 autorest.AsGet(), 340 autorest.WithBaseURL(client.BaseURI), 341 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}", pathParameters), 342 autorest.WithQueryParameters(queryParameters)) 343 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 344} 345 346// GetSender sends the Get request. The method will close the 347// http.Response Body if it receives an error. 348func (client WatchersClient) GetSender(req *http.Request) (*http.Response, error) { 349 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 350 return autorest.SendWithSender(client, req, sd...) 351} 352 353// GetResponder handles the response to the Get request. The method always 354// closes the http.Response Body. 355func (client WatchersClient) GetResponder(resp *http.Response) (result Watcher, err error) { 356 err = autorest.Respond( 357 resp, 358 client.ByInspecting(), 359 azure.WithErrorUnlessStatusCode(http.StatusOK), 360 autorest.ByUnmarshallingJSON(&result), 361 autorest.ByClosing()) 362 result.Response = autorest.Response{Response: resp} 363 return 364} 365 366// GetAzureReachabilityReport gets the relative latency score for internet service providers from a specified location 367// to Azure regions. 368// Parameters: 369// resourceGroupName - the name of the network watcher resource group. 370// networkWatcherName - the name of the network watcher resource. 371// parameters - parameters that determine Azure reachability report configuration. 372func (client WatchersClient) GetAzureReachabilityReport(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters AzureReachabilityReportParameters) (result WatchersGetAzureReachabilityReportFuture, err error) { 373 if tracing.IsEnabled() { 374 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.GetAzureReachabilityReport") 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 if err := validation.Validate([]validation.Validation{ 384 {TargetValue: parameters, 385 Constraints: []validation.Constraint{{Target: "parameters.ProviderLocation", Name: validation.Null, Rule: true, 386 Chain: []validation.Constraint{{Target: "parameters.ProviderLocation.Country", Name: validation.Null, Rule: true, Chain: nil}}}, 387 {Target: "parameters.StartTime", Name: validation.Null, Rule: true, Chain: nil}, 388 {Target: "parameters.EndTime", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 389 return result, validation.NewError("network.WatchersClient", "GetAzureReachabilityReport", err.Error()) 390 } 391 392 req, err := client.GetAzureReachabilityReportPreparer(ctx, resourceGroupName, networkWatcherName, parameters) 393 if err != nil { 394 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetAzureReachabilityReport", nil, "Failure preparing request") 395 return 396 } 397 398 result, err = client.GetAzureReachabilityReportSender(req) 399 if err != nil { 400 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetAzureReachabilityReport", result.Response(), "Failure sending request") 401 return 402 } 403 404 return 405} 406 407// GetAzureReachabilityReportPreparer prepares the GetAzureReachabilityReport request. 408func (client WatchersClient) GetAzureReachabilityReportPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters AzureReachabilityReportParameters) (*http.Request, error) { 409 pathParameters := map[string]interface{}{ 410 "networkWatcherName": autorest.Encode("path", networkWatcherName), 411 "resourceGroupName": autorest.Encode("path", resourceGroupName), 412 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 413 } 414 415 const APIVersion = "2018-01-01" 416 queryParameters := map[string]interface{}{ 417 "api-version": APIVersion, 418 } 419 420 preparer := autorest.CreatePreparer( 421 autorest.AsContentType("application/json; charset=utf-8"), 422 autorest.AsPost(), 423 autorest.WithBaseURL(client.BaseURI), 424 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/azureReachabilityReport", pathParameters), 425 autorest.WithJSON(parameters), 426 autorest.WithQueryParameters(queryParameters)) 427 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 428} 429 430// GetAzureReachabilityReportSender sends the GetAzureReachabilityReport request. The method will close the 431// http.Response Body if it receives an error. 432func (client WatchersClient) GetAzureReachabilityReportSender(req *http.Request) (future WatchersGetAzureReachabilityReportFuture, err error) { 433 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 434 var resp *http.Response 435 resp, err = autorest.SendWithSender(client, req, sd...) 436 if err != nil { 437 return 438 } 439 future.Future, err = azure.NewFutureFromResponse(resp) 440 return 441} 442 443// GetAzureReachabilityReportResponder handles the response to the GetAzureReachabilityReport request. The method always 444// closes the http.Response Body. 445func (client WatchersClient) GetAzureReachabilityReportResponder(resp *http.Response) (result AzureReachabilityReport, err error) { 446 err = autorest.Respond( 447 resp, 448 client.ByInspecting(), 449 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 450 autorest.ByUnmarshallingJSON(&result), 451 autorest.ByClosing()) 452 result.Response = autorest.Response{Response: resp} 453 return 454} 455 456// GetFlowLogStatus queries status of flow log and traffic analytics (optional) on a specified resource. 457// Parameters: 458// resourceGroupName - the name of the network watcher resource group. 459// networkWatcherName - the name of the network watcher resource. 460// parameters - parameters that define a resource to query flow log and traffic analytics (optional) status. 461func (client WatchersClient) GetFlowLogStatus(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters FlowLogStatusParameters) (result WatchersGetFlowLogStatusFuture, err error) { 462 if tracing.IsEnabled() { 463 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.GetFlowLogStatus") 464 defer func() { 465 sc := -1 466 if result.Response() != nil { 467 sc = result.Response().StatusCode 468 } 469 tracing.EndSpan(ctx, sc, err) 470 }() 471 } 472 if err := validation.Validate([]validation.Validation{ 473 {TargetValue: parameters, 474 Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 475 return result, validation.NewError("network.WatchersClient", "GetFlowLogStatus", err.Error()) 476 } 477 478 req, err := client.GetFlowLogStatusPreparer(ctx, resourceGroupName, networkWatcherName, parameters) 479 if err != nil { 480 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetFlowLogStatus", nil, "Failure preparing request") 481 return 482 } 483 484 result, err = client.GetFlowLogStatusSender(req) 485 if err != nil { 486 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetFlowLogStatus", result.Response(), "Failure sending request") 487 return 488 } 489 490 return 491} 492 493// GetFlowLogStatusPreparer prepares the GetFlowLogStatus request. 494func (client WatchersClient) GetFlowLogStatusPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters FlowLogStatusParameters) (*http.Request, error) { 495 pathParameters := map[string]interface{}{ 496 "networkWatcherName": autorest.Encode("path", networkWatcherName), 497 "resourceGroupName": autorest.Encode("path", resourceGroupName), 498 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 499 } 500 501 const APIVersion = "2018-01-01" 502 queryParameters := map[string]interface{}{ 503 "api-version": APIVersion, 504 } 505 506 preparer := autorest.CreatePreparer( 507 autorest.AsContentType("application/json; charset=utf-8"), 508 autorest.AsPost(), 509 autorest.WithBaseURL(client.BaseURI), 510 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/queryFlowLogStatus", pathParameters), 511 autorest.WithJSON(parameters), 512 autorest.WithQueryParameters(queryParameters)) 513 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 514} 515 516// GetFlowLogStatusSender sends the GetFlowLogStatus request. The method will close the 517// http.Response Body if it receives an error. 518func (client WatchersClient) GetFlowLogStatusSender(req *http.Request) (future WatchersGetFlowLogStatusFuture, err error) { 519 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 520 var resp *http.Response 521 resp, err = autorest.SendWithSender(client, req, sd...) 522 if err != nil { 523 return 524 } 525 future.Future, err = azure.NewFutureFromResponse(resp) 526 return 527} 528 529// GetFlowLogStatusResponder handles the response to the GetFlowLogStatus request. The method always 530// closes the http.Response Body. 531func (client WatchersClient) GetFlowLogStatusResponder(resp *http.Response) (result FlowLogInformation, err error) { 532 err = autorest.Respond( 533 resp, 534 client.ByInspecting(), 535 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 536 autorest.ByUnmarshallingJSON(&result), 537 autorest.ByClosing()) 538 result.Response = autorest.Response{Response: resp} 539 return 540} 541 542// GetNextHop gets the next hop from the specified VM. 543// Parameters: 544// resourceGroupName - the name of the resource group. 545// networkWatcherName - the name of the network watcher. 546// parameters - parameters that define the source and destination endpoint. 547func (client WatchersClient) GetNextHop(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters NextHopParameters) (result WatchersGetNextHopFuture, err error) { 548 if tracing.IsEnabled() { 549 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.GetNextHop") 550 defer func() { 551 sc := -1 552 if result.Response() != nil { 553 sc = result.Response().StatusCode 554 } 555 tracing.EndSpan(ctx, sc, err) 556 }() 557 } 558 if err := validation.Validate([]validation.Validation{ 559 {TargetValue: parameters, 560 Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}, 561 {Target: "parameters.SourceIPAddress", Name: validation.Null, Rule: true, Chain: nil}, 562 {Target: "parameters.DestinationIPAddress", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 563 return result, validation.NewError("network.WatchersClient", "GetNextHop", err.Error()) 564 } 565 566 req, err := client.GetNextHopPreparer(ctx, resourceGroupName, networkWatcherName, parameters) 567 if err != nil { 568 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetNextHop", nil, "Failure preparing request") 569 return 570 } 571 572 result, err = client.GetNextHopSender(req) 573 if err != nil { 574 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetNextHop", result.Response(), "Failure sending request") 575 return 576 } 577 578 return 579} 580 581// GetNextHopPreparer prepares the GetNextHop request. 582func (client WatchersClient) GetNextHopPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters NextHopParameters) (*http.Request, error) { 583 pathParameters := map[string]interface{}{ 584 "networkWatcherName": autorest.Encode("path", networkWatcherName), 585 "resourceGroupName": autorest.Encode("path", resourceGroupName), 586 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 587 } 588 589 const APIVersion = "2018-01-01" 590 queryParameters := map[string]interface{}{ 591 "api-version": APIVersion, 592 } 593 594 preparer := autorest.CreatePreparer( 595 autorest.AsContentType("application/json; charset=utf-8"), 596 autorest.AsPost(), 597 autorest.WithBaseURL(client.BaseURI), 598 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/nextHop", pathParameters), 599 autorest.WithJSON(parameters), 600 autorest.WithQueryParameters(queryParameters)) 601 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 602} 603 604// GetNextHopSender sends the GetNextHop request. The method will close the 605// http.Response Body if it receives an error. 606func (client WatchersClient) GetNextHopSender(req *http.Request) (future WatchersGetNextHopFuture, err error) { 607 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 608 var resp *http.Response 609 resp, err = autorest.SendWithSender(client, req, sd...) 610 if err != nil { 611 return 612 } 613 future.Future, err = azure.NewFutureFromResponse(resp) 614 return 615} 616 617// GetNextHopResponder handles the response to the GetNextHop request. The method always 618// closes the http.Response Body. 619func (client WatchersClient) GetNextHopResponder(resp *http.Response) (result NextHopResult, err error) { 620 err = autorest.Respond( 621 resp, 622 client.ByInspecting(), 623 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 624 autorest.ByUnmarshallingJSON(&result), 625 autorest.ByClosing()) 626 result.Response = autorest.Response{Response: resp} 627 return 628} 629 630// GetTopology gets the current network topology by resource group. 631// Parameters: 632// resourceGroupName - the name of the resource group. 633// networkWatcherName - the name of the network watcher. 634// parameters - parameters that define the representation of topology. 635func (client WatchersClient) GetTopology(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters TopologyParameters) (result Topology, err error) { 636 if tracing.IsEnabled() { 637 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.GetTopology") 638 defer func() { 639 sc := -1 640 if result.Response.Response != nil { 641 sc = result.Response.Response.StatusCode 642 } 643 tracing.EndSpan(ctx, sc, err) 644 }() 645 } 646 req, err := client.GetTopologyPreparer(ctx, resourceGroupName, networkWatcherName, parameters) 647 if err != nil { 648 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTopology", nil, "Failure preparing request") 649 return 650 } 651 652 resp, err := client.GetTopologySender(req) 653 if err != nil { 654 result.Response = autorest.Response{Response: resp} 655 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTopology", resp, "Failure sending request") 656 return 657 } 658 659 result, err = client.GetTopologyResponder(resp) 660 if err != nil { 661 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTopology", resp, "Failure responding to request") 662 } 663 664 return 665} 666 667// GetTopologyPreparer prepares the GetTopology request. 668func (client WatchersClient) GetTopologyPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters TopologyParameters) (*http.Request, error) { 669 pathParameters := map[string]interface{}{ 670 "networkWatcherName": autorest.Encode("path", networkWatcherName), 671 "resourceGroupName": autorest.Encode("path", resourceGroupName), 672 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 673 } 674 675 const APIVersion = "2018-01-01" 676 queryParameters := map[string]interface{}{ 677 "api-version": APIVersion, 678 } 679 680 preparer := autorest.CreatePreparer( 681 autorest.AsContentType("application/json; charset=utf-8"), 682 autorest.AsPost(), 683 autorest.WithBaseURL(client.BaseURI), 684 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/topology", pathParameters), 685 autorest.WithJSON(parameters), 686 autorest.WithQueryParameters(queryParameters)) 687 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 688} 689 690// GetTopologySender sends the GetTopology request. The method will close the 691// http.Response Body if it receives an error. 692func (client WatchersClient) GetTopologySender(req *http.Request) (*http.Response, error) { 693 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 694 return autorest.SendWithSender(client, req, sd...) 695} 696 697// GetTopologyResponder handles the response to the GetTopology request. The method always 698// closes the http.Response Body. 699func (client WatchersClient) GetTopologyResponder(resp *http.Response) (result Topology, err error) { 700 err = autorest.Respond( 701 resp, 702 client.ByInspecting(), 703 azure.WithErrorUnlessStatusCode(http.StatusOK), 704 autorest.ByUnmarshallingJSON(&result), 705 autorest.ByClosing()) 706 result.Response = autorest.Response{Response: resp} 707 return 708} 709 710// GetTroubleshooting initiate troubleshooting on a specified resource 711// Parameters: 712// resourceGroupName - the name of the resource group. 713// networkWatcherName - the name of the network watcher resource. 714// parameters - parameters that define the resource to troubleshoot. 715func (client WatchersClient) GetTroubleshooting(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters TroubleshootingParameters) (result WatchersGetTroubleshootingFuture, err error) { 716 if tracing.IsEnabled() { 717 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.GetTroubleshooting") 718 defer func() { 719 sc := -1 720 if result.Response() != nil { 721 sc = result.Response().StatusCode 722 } 723 tracing.EndSpan(ctx, sc, err) 724 }() 725 } 726 if err := validation.Validate([]validation.Validation{ 727 {TargetValue: parameters, 728 Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}, 729 {Target: "parameters.TroubleshootingProperties", Name: validation.Null, Rule: true, 730 Chain: []validation.Constraint{{Target: "parameters.TroubleshootingProperties.StorageID", Name: validation.Null, Rule: true, Chain: nil}, 731 {Target: "parameters.TroubleshootingProperties.StoragePath", Name: validation.Null, Rule: true, Chain: nil}, 732 }}}}}); err != nil { 733 return result, validation.NewError("network.WatchersClient", "GetTroubleshooting", err.Error()) 734 } 735 736 req, err := client.GetTroubleshootingPreparer(ctx, resourceGroupName, networkWatcherName, parameters) 737 if err != nil { 738 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTroubleshooting", nil, "Failure preparing request") 739 return 740 } 741 742 result, err = client.GetTroubleshootingSender(req) 743 if err != nil { 744 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTroubleshooting", result.Response(), "Failure sending request") 745 return 746 } 747 748 return 749} 750 751// GetTroubleshootingPreparer prepares the GetTroubleshooting request. 752func (client WatchersClient) GetTroubleshootingPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters TroubleshootingParameters) (*http.Request, error) { 753 pathParameters := map[string]interface{}{ 754 "networkWatcherName": autorest.Encode("path", networkWatcherName), 755 "resourceGroupName": autorest.Encode("path", resourceGroupName), 756 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 757 } 758 759 const APIVersion = "2018-01-01" 760 queryParameters := map[string]interface{}{ 761 "api-version": APIVersion, 762 } 763 764 preparer := autorest.CreatePreparer( 765 autorest.AsContentType("application/json; charset=utf-8"), 766 autorest.AsPost(), 767 autorest.WithBaseURL(client.BaseURI), 768 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/troubleshoot", pathParameters), 769 autorest.WithJSON(parameters), 770 autorest.WithQueryParameters(queryParameters)) 771 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 772} 773 774// GetTroubleshootingSender sends the GetTroubleshooting request. The method will close the 775// http.Response Body if it receives an error. 776func (client WatchersClient) GetTroubleshootingSender(req *http.Request) (future WatchersGetTroubleshootingFuture, err error) { 777 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 778 var resp *http.Response 779 resp, err = autorest.SendWithSender(client, req, sd...) 780 if err != nil { 781 return 782 } 783 future.Future, err = azure.NewFutureFromResponse(resp) 784 return 785} 786 787// GetTroubleshootingResponder handles the response to the GetTroubleshooting request. The method always 788// closes the http.Response Body. 789func (client WatchersClient) GetTroubleshootingResponder(resp *http.Response) (result TroubleshootingResult, err error) { 790 err = autorest.Respond( 791 resp, 792 client.ByInspecting(), 793 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 794 autorest.ByUnmarshallingJSON(&result), 795 autorest.ByClosing()) 796 result.Response = autorest.Response{Response: resp} 797 return 798} 799 800// GetTroubleshootingResult get the last completed troubleshooting result on a specified resource 801// Parameters: 802// resourceGroupName - the name of the resource group. 803// networkWatcherName - the name of the network watcher resource. 804// parameters - parameters that define the resource to query the troubleshooting result. 805func (client WatchersClient) GetTroubleshootingResult(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters QueryTroubleshootingParameters) (result WatchersGetTroubleshootingResultFuture, err error) { 806 if tracing.IsEnabled() { 807 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.GetTroubleshootingResult") 808 defer func() { 809 sc := -1 810 if result.Response() != nil { 811 sc = result.Response().StatusCode 812 } 813 tracing.EndSpan(ctx, sc, err) 814 }() 815 } 816 if err := validation.Validate([]validation.Validation{ 817 {TargetValue: parameters, 818 Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 819 return result, validation.NewError("network.WatchersClient", "GetTroubleshootingResult", err.Error()) 820 } 821 822 req, err := client.GetTroubleshootingResultPreparer(ctx, resourceGroupName, networkWatcherName, parameters) 823 if err != nil { 824 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTroubleshootingResult", nil, "Failure preparing request") 825 return 826 } 827 828 result, err = client.GetTroubleshootingResultSender(req) 829 if err != nil { 830 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetTroubleshootingResult", result.Response(), "Failure sending request") 831 return 832 } 833 834 return 835} 836 837// GetTroubleshootingResultPreparer prepares the GetTroubleshootingResult request. 838func (client WatchersClient) GetTroubleshootingResultPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters QueryTroubleshootingParameters) (*http.Request, error) { 839 pathParameters := map[string]interface{}{ 840 "networkWatcherName": autorest.Encode("path", networkWatcherName), 841 "resourceGroupName": autorest.Encode("path", resourceGroupName), 842 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 843 } 844 845 const APIVersion = "2018-01-01" 846 queryParameters := map[string]interface{}{ 847 "api-version": APIVersion, 848 } 849 850 preparer := autorest.CreatePreparer( 851 autorest.AsContentType("application/json; charset=utf-8"), 852 autorest.AsPost(), 853 autorest.WithBaseURL(client.BaseURI), 854 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/queryTroubleshootResult", pathParameters), 855 autorest.WithJSON(parameters), 856 autorest.WithQueryParameters(queryParameters)) 857 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 858} 859 860// GetTroubleshootingResultSender sends the GetTroubleshootingResult request. The method will close the 861// http.Response Body if it receives an error. 862func (client WatchersClient) GetTroubleshootingResultSender(req *http.Request) (future WatchersGetTroubleshootingResultFuture, err error) { 863 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 864 var resp *http.Response 865 resp, err = autorest.SendWithSender(client, req, sd...) 866 if err != nil { 867 return 868 } 869 future.Future, err = azure.NewFutureFromResponse(resp) 870 return 871} 872 873// GetTroubleshootingResultResponder handles the response to the GetTroubleshootingResult request. The method always 874// closes the http.Response Body. 875func (client WatchersClient) GetTroubleshootingResultResponder(resp *http.Response) (result TroubleshootingResult, err error) { 876 err = autorest.Respond( 877 resp, 878 client.ByInspecting(), 879 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 880 autorest.ByUnmarshallingJSON(&result), 881 autorest.ByClosing()) 882 result.Response = autorest.Response{Response: resp} 883 return 884} 885 886// GetVMSecurityRules gets the configured and effective security group rules on the specified VM. 887// Parameters: 888// resourceGroupName - the name of the resource group. 889// networkWatcherName - the name of the network watcher. 890// parameters - parameters that define the VM to check security groups for. 891func (client WatchersClient) GetVMSecurityRules(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters SecurityGroupViewParameters) (result WatchersGetVMSecurityRulesFuture, err error) { 892 if tracing.IsEnabled() { 893 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.GetVMSecurityRules") 894 defer func() { 895 sc := -1 896 if result.Response() != nil { 897 sc = result.Response().StatusCode 898 } 899 tracing.EndSpan(ctx, sc, err) 900 }() 901 } 902 if err := validation.Validate([]validation.Validation{ 903 {TargetValue: parameters, 904 Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 905 return result, validation.NewError("network.WatchersClient", "GetVMSecurityRules", err.Error()) 906 } 907 908 req, err := client.GetVMSecurityRulesPreparer(ctx, resourceGroupName, networkWatcherName, parameters) 909 if err != nil { 910 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetVMSecurityRules", nil, "Failure preparing request") 911 return 912 } 913 914 result, err = client.GetVMSecurityRulesSender(req) 915 if err != nil { 916 err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetVMSecurityRules", result.Response(), "Failure sending request") 917 return 918 } 919 920 return 921} 922 923// GetVMSecurityRulesPreparer prepares the GetVMSecurityRules request. 924func (client WatchersClient) GetVMSecurityRulesPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters SecurityGroupViewParameters) (*http.Request, error) { 925 pathParameters := map[string]interface{}{ 926 "networkWatcherName": autorest.Encode("path", networkWatcherName), 927 "resourceGroupName": autorest.Encode("path", resourceGroupName), 928 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 929 } 930 931 const APIVersion = "2018-01-01" 932 queryParameters := map[string]interface{}{ 933 "api-version": APIVersion, 934 } 935 936 preparer := autorest.CreatePreparer( 937 autorest.AsContentType("application/json; charset=utf-8"), 938 autorest.AsPost(), 939 autorest.WithBaseURL(client.BaseURI), 940 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/securityGroupView", pathParameters), 941 autorest.WithJSON(parameters), 942 autorest.WithQueryParameters(queryParameters)) 943 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 944} 945 946// GetVMSecurityRulesSender sends the GetVMSecurityRules request. The method will close the 947// http.Response Body if it receives an error. 948func (client WatchersClient) GetVMSecurityRulesSender(req *http.Request) (future WatchersGetVMSecurityRulesFuture, err error) { 949 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 950 var resp *http.Response 951 resp, err = autorest.SendWithSender(client, req, sd...) 952 if err != nil { 953 return 954 } 955 future.Future, err = azure.NewFutureFromResponse(resp) 956 return 957} 958 959// GetVMSecurityRulesResponder handles the response to the GetVMSecurityRules request. The method always 960// closes the http.Response Body. 961func (client WatchersClient) GetVMSecurityRulesResponder(resp *http.Response) (result SecurityGroupViewResult, err error) { 962 err = autorest.Respond( 963 resp, 964 client.ByInspecting(), 965 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 966 autorest.ByUnmarshallingJSON(&result), 967 autorest.ByClosing()) 968 result.Response = autorest.Response{Response: resp} 969 return 970} 971 972// List gets all network watchers by resource group. 973// Parameters: 974// resourceGroupName - the name of the resource group. 975func (client WatchersClient) List(ctx context.Context, resourceGroupName string) (result WatcherListResult, err error) { 976 if tracing.IsEnabled() { 977 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.List") 978 defer func() { 979 sc := -1 980 if result.Response.Response != nil { 981 sc = result.Response.Response.StatusCode 982 } 983 tracing.EndSpan(ctx, sc, err) 984 }() 985 } 986 req, err := client.ListPreparer(ctx, resourceGroupName) 987 if err != nil { 988 err = autorest.NewErrorWithError(err, "network.WatchersClient", "List", nil, "Failure preparing request") 989 return 990 } 991 992 resp, err := client.ListSender(req) 993 if err != nil { 994 result.Response = autorest.Response{Response: resp} 995 err = autorest.NewErrorWithError(err, "network.WatchersClient", "List", resp, "Failure sending request") 996 return 997 } 998 999 result, err = client.ListResponder(resp) 1000 if err != nil { 1001 err = autorest.NewErrorWithError(err, "network.WatchersClient", "List", resp, "Failure responding to request") 1002 } 1003 1004 return 1005} 1006 1007// ListPreparer prepares the List request. 1008func (client WatchersClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 1009 pathParameters := map[string]interface{}{ 1010 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1011 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1012 } 1013 1014 const APIVersion = "2018-01-01" 1015 queryParameters := map[string]interface{}{ 1016 "api-version": APIVersion, 1017 } 1018 1019 preparer := autorest.CreatePreparer( 1020 autorest.AsGet(), 1021 autorest.WithBaseURL(client.BaseURI), 1022 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers", pathParameters), 1023 autorest.WithQueryParameters(queryParameters)) 1024 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1025} 1026 1027// ListSender sends the List request. The method will close the 1028// http.Response Body if it receives an error. 1029func (client WatchersClient) ListSender(req *http.Request) (*http.Response, error) { 1030 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 1031 return autorest.SendWithSender(client, req, sd...) 1032} 1033 1034// ListResponder handles the response to the List request. The method always 1035// closes the http.Response Body. 1036func (client WatchersClient) ListResponder(resp *http.Response) (result WatcherListResult, err error) { 1037 err = autorest.Respond( 1038 resp, 1039 client.ByInspecting(), 1040 azure.WithErrorUnlessStatusCode(http.StatusOK), 1041 autorest.ByUnmarshallingJSON(&result), 1042 autorest.ByClosing()) 1043 result.Response = autorest.Response{Response: resp} 1044 return 1045} 1046 1047// ListAll gets all network watchers by subscription. 1048func (client WatchersClient) ListAll(ctx context.Context) (result WatcherListResult, err error) { 1049 if tracing.IsEnabled() { 1050 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.ListAll") 1051 defer func() { 1052 sc := -1 1053 if result.Response.Response != nil { 1054 sc = result.Response.Response.StatusCode 1055 } 1056 tracing.EndSpan(ctx, sc, err) 1057 }() 1058 } 1059 req, err := client.ListAllPreparer(ctx) 1060 if err != nil { 1061 err = autorest.NewErrorWithError(err, "network.WatchersClient", "ListAll", nil, "Failure preparing request") 1062 return 1063 } 1064 1065 resp, err := client.ListAllSender(req) 1066 if err != nil { 1067 result.Response = autorest.Response{Response: resp} 1068 err = autorest.NewErrorWithError(err, "network.WatchersClient", "ListAll", resp, "Failure sending request") 1069 return 1070 } 1071 1072 result, err = client.ListAllResponder(resp) 1073 if err != nil { 1074 err = autorest.NewErrorWithError(err, "network.WatchersClient", "ListAll", resp, "Failure responding to request") 1075 } 1076 1077 return 1078} 1079 1080// ListAllPreparer prepares the ListAll request. 1081func (client WatchersClient) ListAllPreparer(ctx context.Context) (*http.Request, error) { 1082 pathParameters := map[string]interface{}{ 1083 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1084 } 1085 1086 const APIVersion = "2018-01-01" 1087 queryParameters := map[string]interface{}{ 1088 "api-version": APIVersion, 1089 } 1090 1091 preparer := autorest.CreatePreparer( 1092 autorest.AsGet(), 1093 autorest.WithBaseURL(client.BaseURI), 1094 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/networkWatchers", pathParameters), 1095 autorest.WithQueryParameters(queryParameters)) 1096 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1097} 1098 1099// ListAllSender sends the ListAll request. The method will close the 1100// http.Response Body if it receives an error. 1101func (client WatchersClient) ListAllSender(req *http.Request) (*http.Response, error) { 1102 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 1103 return autorest.SendWithSender(client, req, sd...) 1104} 1105 1106// ListAllResponder handles the response to the ListAll request. The method always 1107// closes the http.Response Body. 1108func (client WatchersClient) ListAllResponder(resp *http.Response) (result WatcherListResult, err error) { 1109 err = autorest.Respond( 1110 resp, 1111 client.ByInspecting(), 1112 azure.WithErrorUnlessStatusCode(http.StatusOK), 1113 autorest.ByUnmarshallingJSON(&result), 1114 autorest.ByClosing()) 1115 result.Response = autorest.Response{Response: resp} 1116 return 1117} 1118 1119// ListAvailableProviders lists all available internet service providers for a specified Azure region. 1120// Parameters: 1121// resourceGroupName - the name of the network watcher resource group. 1122// networkWatcherName - the name of the network watcher resource. 1123// parameters - parameters that scope the list of available providers. 1124func (client WatchersClient) ListAvailableProviders(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters AvailableProvidersListParameters) (result WatchersListAvailableProvidersFuture, err error) { 1125 if tracing.IsEnabled() { 1126 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.ListAvailableProviders") 1127 defer func() { 1128 sc := -1 1129 if result.Response() != nil { 1130 sc = result.Response().StatusCode 1131 } 1132 tracing.EndSpan(ctx, sc, err) 1133 }() 1134 } 1135 req, err := client.ListAvailableProvidersPreparer(ctx, resourceGroupName, networkWatcherName, parameters) 1136 if err != nil { 1137 err = autorest.NewErrorWithError(err, "network.WatchersClient", "ListAvailableProviders", nil, "Failure preparing request") 1138 return 1139 } 1140 1141 result, err = client.ListAvailableProvidersSender(req) 1142 if err != nil { 1143 err = autorest.NewErrorWithError(err, "network.WatchersClient", "ListAvailableProviders", result.Response(), "Failure sending request") 1144 return 1145 } 1146 1147 return 1148} 1149 1150// ListAvailableProvidersPreparer prepares the ListAvailableProviders request. 1151func (client WatchersClient) ListAvailableProvidersPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters AvailableProvidersListParameters) (*http.Request, error) { 1152 pathParameters := map[string]interface{}{ 1153 "networkWatcherName": autorest.Encode("path", networkWatcherName), 1154 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1155 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1156 } 1157 1158 const APIVersion = "2018-01-01" 1159 queryParameters := map[string]interface{}{ 1160 "api-version": APIVersion, 1161 } 1162 1163 preparer := autorest.CreatePreparer( 1164 autorest.AsContentType("application/json; charset=utf-8"), 1165 autorest.AsPost(), 1166 autorest.WithBaseURL(client.BaseURI), 1167 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/availableProvidersList", pathParameters), 1168 autorest.WithJSON(parameters), 1169 autorest.WithQueryParameters(queryParameters)) 1170 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1171} 1172 1173// ListAvailableProvidersSender sends the ListAvailableProviders request. The method will close the 1174// http.Response Body if it receives an error. 1175func (client WatchersClient) ListAvailableProvidersSender(req *http.Request) (future WatchersListAvailableProvidersFuture, err error) { 1176 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 1177 var resp *http.Response 1178 resp, err = autorest.SendWithSender(client, req, sd...) 1179 if err != nil { 1180 return 1181 } 1182 future.Future, err = azure.NewFutureFromResponse(resp) 1183 return 1184} 1185 1186// ListAvailableProvidersResponder handles the response to the ListAvailableProviders request. The method always 1187// closes the http.Response Body. 1188func (client WatchersClient) ListAvailableProvidersResponder(resp *http.Response) (result AvailableProvidersList, err error) { 1189 err = autorest.Respond( 1190 resp, 1191 client.ByInspecting(), 1192 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1193 autorest.ByUnmarshallingJSON(&result), 1194 autorest.ByClosing()) 1195 result.Response = autorest.Response{Response: resp} 1196 return 1197} 1198 1199// SetFlowLogConfiguration configures flow log and traffic analytics (optional) on a specified resource. 1200// Parameters: 1201// resourceGroupName - the name of the network watcher resource group. 1202// networkWatcherName - the name of the network watcher resource. 1203// parameters - parameters that define the configuration of flow log. 1204func (client WatchersClient) SetFlowLogConfiguration(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters FlowLogInformation) (result WatchersSetFlowLogConfigurationFuture, err error) { 1205 if tracing.IsEnabled() { 1206 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.SetFlowLogConfiguration") 1207 defer func() { 1208 sc := -1 1209 if result.Response() != nil { 1210 sc = result.Response().StatusCode 1211 } 1212 tracing.EndSpan(ctx, sc, err) 1213 }() 1214 } 1215 if err := validation.Validate([]validation.Validation{ 1216 {TargetValue: parameters, 1217 Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}, 1218 {Target: "parameters.FlowLogProperties", Name: validation.Null, Rule: true, 1219 Chain: []validation.Constraint{{Target: "parameters.FlowLogProperties.StorageID", Name: validation.Null, Rule: true, Chain: nil}, 1220 {Target: "parameters.FlowLogProperties.Enabled", Name: validation.Null, Rule: true, Chain: nil}, 1221 }}, 1222 {Target: "parameters.TrafficAnalyticsProperties", Name: validation.Null, Rule: false, 1223 Chain: []validation.Constraint{{Target: "parameters.TrafficAnalyticsProperties.NetworkWatcherFlowAnalyticsConfiguration", Name: validation.Null, Rule: true, 1224 Chain: []validation.Constraint{{Target: "parameters.TrafficAnalyticsProperties.NetworkWatcherFlowAnalyticsConfiguration.Enabled", Name: validation.Null, Rule: true, Chain: nil}, 1225 {Target: "parameters.TrafficAnalyticsProperties.NetworkWatcherFlowAnalyticsConfiguration.WorkspaceID", Name: validation.Null, Rule: true, Chain: nil}, 1226 {Target: "parameters.TrafficAnalyticsProperties.NetworkWatcherFlowAnalyticsConfiguration.WorkspaceRegion", Name: validation.Null, Rule: true, Chain: nil}, 1227 {Target: "parameters.TrafficAnalyticsProperties.NetworkWatcherFlowAnalyticsConfiguration.WorkspaceResourceID", Name: validation.Null, Rule: true, Chain: nil}, 1228 }}, 1229 }}}}}); err != nil { 1230 return result, validation.NewError("network.WatchersClient", "SetFlowLogConfiguration", err.Error()) 1231 } 1232 1233 req, err := client.SetFlowLogConfigurationPreparer(ctx, resourceGroupName, networkWatcherName, parameters) 1234 if err != nil { 1235 err = autorest.NewErrorWithError(err, "network.WatchersClient", "SetFlowLogConfiguration", nil, "Failure preparing request") 1236 return 1237 } 1238 1239 result, err = client.SetFlowLogConfigurationSender(req) 1240 if err != nil { 1241 err = autorest.NewErrorWithError(err, "network.WatchersClient", "SetFlowLogConfiguration", result.Response(), "Failure sending request") 1242 return 1243 } 1244 1245 return 1246} 1247 1248// SetFlowLogConfigurationPreparer prepares the SetFlowLogConfiguration request. 1249func (client WatchersClient) SetFlowLogConfigurationPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters FlowLogInformation) (*http.Request, error) { 1250 pathParameters := map[string]interface{}{ 1251 "networkWatcherName": autorest.Encode("path", networkWatcherName), 1252 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1253 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1254 } 1255 1256 const APIVersion = "2018-01-01" 1257 queryParameters := map[string]interface{}{ 1258 "api-version": APIVersion, 1259 } 1260 1261 preparer := autorest.CreatePreparer( 1262 autorest.AsContentType("application/json; charset=utf-8"), 1263 autorest.AsPost(), 1264 autorest.WithBaseURL(client.BaseURI), 1265 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/configureFlowLog", pathParameters), 1266 autorest.WithJSON(parameters), 1267 autorest.WithQueryParameters(queryParameters)) 1268 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1269} 1270 1271// SetFlowLogConfigurationSender sends the SetFlowLogConfiguration request. The method will close the 1272// http.Response Body if it receives an error. 1273func (client WatchersClient) SetFlowLogConfigurationSender(req *http.Request) (future WatchersSetFlowLogConfigurationFuture, err error) { 1274 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 1275 var resp *http.Response 1276 resp, err = autorest.SendWithSender(client, req, sd...) 1277 if err != nil { 1278 return 1279 } 1280 future.Future, err = azure.NewFutureFromResponse(resp) 1281 return 1282} 1283 1284// SetFlowLogConfigurationResponder handles the response to the SetFlowLogConfiguration request. The method always 1285// closes the http.Response Body. 1286func (client WatchersClient) SetFlowLogConfigurationResponder(resp *http.Response) (result FlowLogInformation, err error) { 1287 err = autorest.Respond( 1288 resp, 1289 client.ByInspecting(), 1290 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1291 autorest.ByUnmarshallingJSON(&result), 1292 autorest.ByClosing()) 1293 result.Response = autorest.Response{Response: resp} 1294 return 1295} 1296 1297// UpdateTags updates a network watcher tags. 1298// Parameters: 1299// resourceGroupName - the name of the resource group. 1300// networkWatcherName - the name of the network watcher. 1301// parameters - parameters supplied to update network watcher tags. 1302func (client WatchersClient) UpdateTags(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters TagsObject) (result Watcher, err error) { 1303 if tracing.IsEnabled() { 1304 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.UpdateTags") 1305 defer func() { 1306 sc := -1 1307 if result.Response.Response != nil { 1308 sc = result.Response.Response.StatusCode 1309 } 1310 tracing.EndSpan(ctx, sc, err) 1311 }() 1312 } 1313 req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, networkWatcherName, parameters) 1314 if err != nil { 1315 err = autorest.NewErrorWithError(err, "network.WatchersClient", "UpdateTags", nil, "Failure preparing request") 1316 return 1317 } 1318 1319 resp, err := client.UpdateTagsSender(req) 1320 if err != nil { 1321 result.Response = autorest.Response{Response: resp} 1322 err = autorest.NewErrorWithError(err, "network.WatchersClient", "UpdateTags", resp, "Failure sending request") 1323 return 1324 } 1325 1326 result, err = client.UpdateTagsResponder(resp) 1327 if err != nil { 1328 err = autorest.NewErrorWithError(err, "network.WatchersClient", "UpdateTags", resp, "Failure responding to request") 1329 } 1330 1331 return 1332} 1333 1334// UpdateTagsPreparer prepares the UpdateTags request. 1335func (client WatchersClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters TagsObject) (*http.Request, error) { 1336 pathParameters := map[string]interface{}{ 1337 "networkWatcherName": autorest.Encode("path", networkWatcherName), 1338 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1339 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1340 } 1341 1342 const APIVersion = "2018-01-01" 1343 queryParameters := map[string]interface{}{ 1344 "api-version": APIVersion, 1345 } 1346 1347 preparer := autorest.CreatePreparer( 1348 autorest.AsContentType("application/json; charset=utf-8"), 1349 autorest.AsPatch(), 1350 autorest.WithBaseURL(client.BaseURI), 1351 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}", pathParameters), 1352 autorest.WithJSON(parameters), 1353 autorest.WithQueryParameters(queryParameters)) 1354 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1355} 1356 1357// UpdateTagsSender sends the UpdateTags request. The method will close the 1358// http.Response Body if it receives an error. 1359func (client WatchersClient) UpdateTagsSender(req *http.Request) (*http.Response, error) { 1360 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 1361 return autorest.SendWithSender(client, req, sd...) 1362} 1363 1364// UpdateTagsResponder handles the response to the UpdateTags request. The method always 1365// closes the http.Response Body. 1366func (client WatchersClient) UpdateTagsResponder(resp *http.Response) (result Watcher, err error) { 1367 err = autorest.Respond( 1368 resp, 1369 client.ByInspecting(), 1370 azure.WithErrorUnlessStatusCode(http.StatusOK), 1371 autorest.ByUnmarshallingJSON(&result), 1372 autorest.ByClosing()) 1373 result.Response = autorest.Response{Response: resp} 1374 return 1375} 1376 1377// VerifyIPFlow verify IP flow from the specified VM to a location given the currently configured NSG rules. 1378// Parameters: 1379// resourceGroupName - the name of the resource group. 1380// networkWatcherName - the name of the network watcher. 1381// parameters - parameters that define the IP flow to be verified. 1382func (client WatchersClient) VerifyIPFlow(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters VerificationIPFlowParameters) (result WatchersVerifyIPFlowFuture, err error) { 1383 if tracing.IsEnabled() { 1384 ctx = tracing.StartSpan(ctx, fqdn+"/WatchersClient.VerifyIPFlow") 1385 defer func() { 1386 sc := -1 1387 if result.Response() != nil { 1388 sc = result.Response().StatusCode 1389 } 1390 tracing.EndSpan(ctx, sc, err) 1391 }() 1392 } 1393 if err := validation.Validate([]validation.Validation{ 1394 {TargetValue: parameters, 1395 Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil}, 1396 {Target: "parameters.LocalPort", Name: validation.Null, Rule: true, Chain: nil}, 1397 {Target: "parameters.RemotePort", Name: validation.Null, Rule: true, Chain: nil}, 1398 {Target: "parameters.LocalIPAddress", Name: validation.Null, Rule: true, Chain: nil}, 1399 {Target: "parameters.RemoteIPAddress", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 1400 return result, validation.NewError("network.WatchersClient", "VerifyIPFlow", err.Error()) 1401 } 1402 1403 req, err := client.VerifyIPFlowPreparer(ctx, resourceGroupName, networkWatcherName, parameters) 1404 if err != nil { 1405 err = autorest.NewErrorWithError(err, "network.WatchersClient", "VerifyIPFlow", nil, "Failure preparing request") 1406 return 1407 } 1408 1409 result, err = client.VerifyIPFlowSender(req) 1410 if err != nil { 1411 err = autorest.NewErrorWithError(err, "network.WatchersClient", "VerifyIPFlow", result.Response(), "Failure sending request") 1412 return 1413 } 1414 1415 return 1416} 1417 1418// VerifyIPFlowPreparer prepares the VerifyIPFlow request. 1419func (client WatchersClient) VerifyIPFlowPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters VerificationIPFlowParameters) (*http.Request, error) { 1420 pathParameters := map[string]interface{}{ 1421 "networkWatcherName": autorest.Encode("path", networkWatcherName), 1422 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1423 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1424 } 1425 1426 const APIVersion = "2018-01-01" 1427 queryParameters := map[string]interface{}{ 1428 "api-version": APIVersion, 1429 } 1430 1431 preparer := autorest.CreatePreparer( 1432 autorest.AsContentType("application/json; charset=utf-8"), 1433 autorest.AsPost(), 1434 autorest.WithBaseURL(client.BaseURI), 1435 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/ipFlowVerify", pathParameters), 1436 autorest.WithJSON(parameters), 1437 autorest.WithQueryParameters(queryParameters)) 1438 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1439} 1440 1441// VerifyIPFlowSender sends the VerifyIPFlow request. The method will close the 1442// http.Response Body if it receives an error. 1443func (client WatchersClient) VerifyIPFlowSender(req *http.Request) (future WatchersVerifyIPFlowFuture, err error) { 1444 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 1445 var resp *http.Response 1446 resp, err = autorest.SendWithSender(client, req, sd...) 1447 if err != nil { 1448 return 1449 } 1450 future.Future, err = azure.NewFutureFromResponse(resp) 1451 return 1452} 1453 1454// VerifyIPFlowResponder handles the response to the VerifyIPFlow request. The method always 1455// closes the http.Response Body. 1456func (client WatchersClient) VerifyIPFlowResponder(resp *http.Response) (result VerificationIPFlowResult, err error) { 1457 err = autorest.Respond( 1458 resp, 1459 client.ByInspecting(), 1460 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1461 autorest.ByUnmarshallingJSON(&result), 1462 autorest.ByClosing()) 1463 result.Response = autorest.Response{Response: resp} 1464 return 1465} 1466