github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/watchers_client.go (about) 1 //go:build go1.18 2 // +build go1.18 3 4 // Copyright (c) Microsoft Corporation. All rights reserved. 5 // Licensed under the MIT License. See License.txt in the project root for license information. 6 // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. 7 // Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9 package armnetwork 10 11 import ( 12 "context" 13 "errors" 14 "github.com/Azure/azure-sdk-for-go/sdk/azcore" 15 "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" 16 "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" 17 "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" 18 "net/http" 19 "net/url" 20 "strings" 21 ) 22 23 // WatchersClient contains the methods for the NetworkWatchers group. 24 // Don't use this type directly, use NewWatchersClient() instead. 25 type WatchersClient struct { 26 internal *arm.Client 27 subscriptionID string 28 } 29 30 // NewWatchersClient creates a new instance of WatchersClient with the specified values. 31 // - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription 32 // ID forms part of the URI for every service call. 33 // - credential - used to authorize requests. Usually a credential from azidentity. 34 // - options - pass nil to accept the default values. 35 func NewWatchersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WatchersClient, error) { 36 cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) 37 if err != nil { 38 return nil, err 39 } 40 client := &WatchersClient{ 41 subscriptionID: subscriptionID, 42 internal: cl, 43 } 44 return client, nil 45 } 46 47 // BeginCheckConnectivity - Verifies the possibility of establishing a direct TCP connection from a virtual machine to a given 48 // endpoint including another VM or an arbitrary remote server. 49 // If the operation fails it returns an *azcore.ResponseError type. 50 // 51 // Generated from API version 2024-05-01 52 // - resourceGroupName - The name of the network watcher resource group. 53 // - networkWatcherName - The name of the network watcher resource. 54 // - parameters - Parameters that determine how the connectivity check will be performed. 55 // - options - WatchersClientBeginCheckConnectivityOptions contains the optional parameters for the WatchersClient.BeginCheckConnectivity 56 // method. 57 func (client *WatchersClient) BeginCheckConnectivity(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters ConnectivityParameters, options *WatchersClientBeginCheckConnectivityOptions) (*runtime.Poller[WatchersClientCheckConnectivityResponse], error) { 58 if options == nil || options.ResumeToken == "" { 59 resp, err := client.checkConnectivity(ctx, resourceGroupName, networkWatcherName, parameters, options) 60 if err != nil { 61 return nil, err 62 } 63 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WatchersClientCheckConnectivityResponse]{ 64 FinalStateVia: runtime.FinalStateViaLocation, 65 Tracer: client.internal.Tracer(), 66 }) 67 return poller, err 68 } else { 69 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WatchersClientCheckConnectivityResponse]{ 70 Tracer: client.internal.Tracer(), 71 }) 72 } 73 } 74 75 // CheckConnectivity - Verifies the possibility of establishing a direct TCP connection from a virtual machine to a given 76 // endpoint including another VM or an arbitrary remote server. 77 // If the operation fails it returns an *azcore.ResponseError type. 78 // 79 // Generated from API version 2024-05-01 80 func (client *WatchersClient) checkConnectivity(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters ConnectivityParameters, options *WatchersClientBeginCheckConnectivityOptions) (*http.Response, error) { 81 var err error 82 const operationName = "WatchersClient.BeginCheckConnectivity" 83 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 84 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 85 defer func() { endSpan(err) }() 86 req, err := client.checkConnectivityCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 87 if err != nil { 88 return nil, err 89 } 90 httpResp, err := client.internal.Pipeline().Do(req) 91 if err != nil { 92 return nil, err 93 } 94 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 95 err = runtime.NewResponseError(httpResp) 96 return nil, err 97 } 98 return httpResp, nil 99 } 100 101 // checkConnectivityCreateRequest creates the CheckConnectivity request. 102 func (client *WatchersClient) checkConnectivityCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters ConnectivityParameters, options *WatchersClientBeginCheckConnectivityOptions) (*policy.Request, error) { 103 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectivityCheck" 104 if resourceGroupName == "" { 105 return nil, errors.New("parameter resourceGroupName cannot be empty") 106 } 107 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 108 if networkWatcherName == "" { 109 return nil, errors.New("parameter networkWatcherName cannot be empty") 110 } 111 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 112 if client.subscriptionID == "" { 113 return nil, errors.New("parameter client.subscriptionID cannot be empty") 114 } 115 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 116 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 117 if err != nil { 118 return nil, err 119 } 120 reqQP := req.Raw().URL.Query() 121 reqQP.Set("api-version", "2024-05-01") 122 req.Raw().URL.RawQuery = reqQP.Encode() 123 req.Raw().Header["Accept"] = []string{"application/json"} 124 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 125 return nil, err 126 } 127 return req, nil 128 } 129 130 // CreateOrUpdate - Creates or updates a network watcher in the specified resource group. 131 // If the operation fails it returns an *azcore.ResponseError type. 132 // 133 // Generated from API version 2024-05-01 134 // - resourceGroupName - The name of the resource group. 135 // - networkWatcherName - The name of the network watcher. 136 // - parameters - Parameters that define the network watcher resource. 137 // - options - WatchersClientCreateOrUpdateOptions contains the optional parameters for the WatchersClient.CreateOrUpdate method. 138 func (client *WatchersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters Watcher, options *WatchersClientCreateOrUpdateOptions) (WatchersClientCreateOrUpdateResponse, error) { 139 var err error 140 const operationName = "WatchersClient.CreateOrUpdate" 141 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 142 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 143 defer func() { endSpan(err) }() 144 req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 145 if err != nil { 146 return WatchersClientCreateOrUpdateResponse{}, err 147 } 148 httpResp, err := client.internal.Pipeline().Do(req) 149 if err != nil { 150 return WatchersClientCreateOrUpdateResponse{}, err 151 } 152 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { 153 err = runtime.NewResponseError(httpResp) 154 return WatchersClientCreateOrUpdateResponse{}, err 155 } 156 resp, err := client.createOrUpdateHandleResponse(httpResp) 157 return resp, err 158 } 159 160 // createOrUpdateCreateRequest creates the CreateOrUpdate request. 161 func (client *WatchersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters Watcher, options *WatchersClientCreateOrUpdateOptions) (*policy.Request, error) { 162 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}" 163 if resourceGroupName == "" { 164 return nil, errors.New("parameter resourceGroupName cannot be empty") 165 } 166 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 167 if networkWatcherName == "" { 168 return nil, errors.New("parameter networkWatcherName cannot be empty") 169 } 170 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 171 if client.subscriptionID == "" { 172 return nil, errors.New("parameter client.subscriptionID cannot be empty") 173 } 174 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 175 req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 176 if err != nil { 177 return nil, err 178 } 179 reqQP := req.Raw().URL.Query() 180 reqQP.Set("api-version", "2024-05-01") 181 req.Raw().URL.RawQuery = reqQP.Encode() 182 req.Raw().Header["Accept"] = []string{"application/json"} 183 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 184 return nil, err 185 } 186 return req, nil 187 } 188 189 // createOrUpdateHandleResponse handles the CreateOrUpdate response. 190 func (client *WatchersClient) createOrUpdateHandleResponse(resp *http.Response) (WatchersClientCreateOrUpdateResponse, error) { 191 result := WatchersClientCreateOrUpdateResponse{} 192 if err := runtime.UnmarshalAsJSON(resp, &result.Watcher); err != nil { 193 return WatchersClientCreateOrUpdateResponse{}, err 194 } 195 return result, nil 196 } 197 198 // BeginDelete - Deletes the specified network watcher resource. 199 // If the operation fails it returns an *azcore.ResponseError type. 200 // 201 // Generated from API version 2024-05-01 202 // - resourceGroupName - The name of the resource group. 203 // - networkWatcherName - The name of the network watcher. 204 // - options - WatchersClientBeginDeleteOptions contains the optional parameters for the WatchersClient.BeginDelete method. 205 func (client *WatchersClient) BeginDelete(ctx context.Context, resourceGroupName string, networkWatcherName string, options *WatchersClientBeginDeleteOptions) (*runtime.Poller[WatchersClientDeleteResponse], error) { 206 if options == nil || options.ResumeToken == "" { 207 resp, err := client.deleteOperation(ctx, resourceGroupName, networkWatcherName, options) 208 if err != nil { 209 return nil, err 210 } 211 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WatchersClientDeleteResponse]{ 212 FinalStateVia: runtime.FinalStateViaLocation, 213 Tracer: client.internal.Tracer(), 214 }) 215 return poller, err 216 } else { 217 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WatchersClientDeleteResponse]{ 218 Tracer: client.internal.Tracer(), 219 }) 220 } 221 } 222 223 // Delete - Deletes the specified network watcher resource. 224 // If the operation fails it returns an *azcore.ResponseError type. 225 // 226 // Generated from API version 2024-05-01 227 func (client *WatchersClient) deleteOperation(ctx context.Context, resourceGroupName string, networkWatcherName string, options *WatchersClientBeginDeleteOptions) (*http.Response, error) { 228 var err error 229 const operationName = "WatchersClient.BeginDelete" 230 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 231 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 232 defer func() { endSpan(err) }() 233 req, err := client.deleteCreateRequest(ctx, resourceGroupName, networkWatcherName, options) 234 if err != nil { 235 return nil, err 236 } 237 httpResp, err := client.internal.Pipeline().Do(req) 238 if err != nil { 239 return nil, err 240 } 241 if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { 242 err = runtime.NewResponseError(httpResp) 243 return nil, err 244 } 245 return httpResp, nil 246 } 247 248 // deleteCreateRequest creates the Delete request. 249 func (client *WatchersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, options *WatchersClientBeginDeleteOptions) (*policy.Request, error) { 250 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}" 251 if resourceGroupName == "" { 252 return nil, errors.New("parameter resourceGroupName cannot be empty") 253 } 254 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 255 if networkWatcherName == "" { 256 return nil, errors.New("parameter networkWatcherName cannot be empty") 257 } 258 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 259 if client.subscriptionID == "" { 260 return nil, errors.New("parameter client.subscriptionID cannot be empty") 261 } 262 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 263 req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 264 if err != nil { 265 return nil, err 266 } 267 reqQP := req.Raw().URL.Query() 268 reqQP.Set("api-version", "2024-05-01") 269 req.Raw().URL.RawQuery = reqQP.Encode() 270 req.Raw().Header["Accept"] = []string{"application/json"} 271 return req, nil 272 } 273 274 // Get - Gets the specified network watcher by resource group. 275 // If the operation fails it returns an *azcore.ResponseError type. 276 // 277 // Generated from API version 2024-05-01 278 // - resourceGroupName - The name of the resource group. 279 // - networkWatcherName - The name of the network watcher. 280 // - options - WatchersClientGetOptions contains the optional parameters for the WatchersClient.Get method. 281 func (client *WatchersClient) Get(ctx context.Context, resourceGroupName string, networkWatcherName string, options *WatchersClientGetOptions) (WatchersClientGetResponse, error) { 282 var err error 283 const operationName = "WatchersClient.Get" 284 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 285 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 286 defer func() { endSpan(err) }() 287 req, err := client.getCreateRequest(ctx, resourceGroupName, networkWatcherName, options) 288 if err != nil { 289 return WatchersClientGetResponse{}, err 290 } 291 httpResp, err := client.internal.Pipeline().Do(req) 292 if err != nil { 293 return WatchersClientGetResponse{}, err 294 } 295 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 296 err = runtime.NewResponseError(httpResp) 297 return WatchersClientGetResponse{}, err 298 } 299 resp, err := client.getHandleResponse(httpResp) 300 return resp, err 301 } 302 303 // getCreateRequest creates the Get request. 304 func (client *WatchersClient) getCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, options *WatchersClientGetOptions) (*policy.Request, error) { 305 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}" 306 if resourceGroupName == "" { 307 return nil, errors.New("parameter resourceGroupName cannot be empty") 308 } 309 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 310 if networkWatcherName == "" { 311 return nil, errors.New("parameter networkWatcherName cannot be empty") 312 } 313 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 314 if client.subscriptionID == "" { 315 return nil, errors.New("parameter client.subscriptionID cannot be empty") 316 } 317 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 318 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 319 if err != nil { 320 return nil, err 321 } 322 reqQP := req.Raw().URL.Query() 323 reqQP.Set("api-version", "2024-05-01") 324 req.Raw().URL.RawQuery = reqQP.Encode() 325 req.Raw().Header["Accept"] = []string{"application/json"} 326 return req, nil 327 } 328 329 // getHandleResponse handles the Get response. 330 func (client *WatchersClient) getHandleResponse(resp *http.Response) (WatchersClientGetResponse, error) { 331 result := WatchersClientGetResponse{} 332 if err := runtime.UnmarshalAsJSON(resp, &result.Watcher); err != nil { 333 return WatchersClientGetResponse{}, err 334 } 335 return result, nil 336 } 337 338 // BeginGetAzureReachabilityReport - NOTE: This feature is currently in preview and still being tested for stability. Gets 339 // the relative latency score for internet service providers from a specified location to Azure regions. 340 // If the operation fails it returns an *azcore.ResponseError type. 341 // 342 // Generated from API version 2024-05-01 343 // - resourceGroupName - The name of the network watcher resource group. 344 // - networkWatcherName - The name of the network watcher resource. 345 // - parameters - Parameters that determine Azure reachability report configuration. 346 // - options - WatchersClientBeginGetAzureReachabilityReportOptions contains the optional parameters for the WatchersClient.BeginGetAzureReachabilityReport 347 // method. 348 func (client *WatchersClient) BeginGetAzureReachabilityReport(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters AzureReachabilityReportParameters, options *WatchersClientBeginGetAzureReachabilityReportOptions) (*runtime.Poller[WatchersClientGetAzureReachabilityReportResponse], error) { 349 if options == nil || options.ResumeToken == "" { 350 resp, err := client.getAzureReachabilityReport(ctx, resourceGroupName, networkWatcherName, parameters, options) 351 if err != nil { 352 return nil, err 353 } 354 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WatchersClientGetAzureReachabilityReportResponse]{ 355 FinalStateVia: runtime.FinalStateViaLocation, 356 Tracer: client.internal.Tracer(), 357 }) 358 return poller, err 359 } else { 360 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WatchersClientGetAzureReachabilityReportResponse]{ 361 Tracer: client.internal.Tracer(), 362 }) 363 } 364 } 365 366 // GetAzureReachabilityReport - NOTE: This feature is currently in preview and still being tested for stability. Gets the 367 // relative latency score for internet service providers from a specified location to Azure regions. 368 // If the operation fails it returns an *azcore.ResponseError type. 369 // 370 // Generated from API version 2024-05-01 371 func (client *WatchersClient) getAzureReachabilityReport(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters AzureReachabilityReportParameters, options *WatchersClientBeginGetAzureReachabilityReportOptions) (*http.Response, error) { 372 var err error 373 const operationName = "WatchersClient.BeginGetAzureReachabilityReport" 374 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 375 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 376 defer func() { endSpan(err) }() 377 req, err := client.getAzureReachabilityReportCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 378 if err != nil { 379 return nil, err 380 } 381 httpResp, err := client.internal.Pipeline().Do(req) 382 if err != nil { 383 return nil, err 384 } 385 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 386 err = runtime.NewResponseError(httpResp) 387 return nil, err 388 } 389 return httpResp, nil 390 } 391 392 // getAzureReachabilityReportCreateRequest creates the GetAzureReachabilityReport request. 393 func (client *WatchersClient) getAzureReachabilityReportCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters AzureReachabilityReportParameters, options *WatchersClientBeginGetAzureReachabilityReportOptions) (*policy.Request, error) { 394 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/azureReachabilityReport" 395 if resourceGroupName == "" { 396 return nil, errors.New("parameter resourceGroupName cannot be empty") 397 } 398 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 399 if networkWatcherName == "" { 400 return nil, errors.New("parameter networkWatcherName cannot be empty") 401 } 402 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 403 if client.subscriptionID == "" { 404 return nil, errors.New("parameter client.subscriptionID cannot be empty") 405 } 406 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 407 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 408 if err != nil { 409 return nil, err 410 } 411 reqQP := req.Raw().URL.Query() 412 reqQP.Set("api-version", "2024-05-01") 413 req.Raw().URL.RawQuery = reqQP.Encode() 414 req.Raw().Header["Accept"] = []string{"application/json"} 415 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 416 return nil, err 417 } 418 return req, nil 419 } 420 421 // BeginGetFlowLogStatus - Queries status of flow log and traffic analytics (optional) on a specified resource. 422 // If the operation fails it returns an *azcore.ResponseError type. 423 // 424 // Generated from API version 2024-05-01 425 // - resourceGroupName - The name of the network watcher resource group. 426 // - networkWatcherName - The name of the network watcher resource. 427 // - parameters - Parameters that define a resource to query flow log and traffic analytics (optional) status. 428 // - options - WatchersClientBeginGetFlowLogStatusOptions contains the optional parameters for the WatchersClient.BeginGetFlowLogStatus 429 // method. 430 func (client *WatchersClient) BeginGetFlowLogStatus(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters FlowLogStatusParameters, options *WatchersClientBeginGetFlowLogStatusOptions) (*runtime.Poller[WatchersClientGetFlowLogStatusResponse], error) { 431 if options == nil || options.ResumeToken == "" { 432 resp, err := client.getFlowLogStatus(ctx, resourceGroupName, networkWatcherName, parameters, options) 433 if err != nil { 434 return nil, err 435 } 436 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WatchersClientGetFlowLogStatusResponse]{ 437 FinalStateVia: runtime.FinalStateViaLocation, 438 Tracer: client.internal.Tracer(), 439 }) 440 return poller, err 441 } else { 442 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WatchersClientGetFlowLogStatusResponse]{ 443 Tracer: client.internal.Tracer(), 444 }) 445 } 446 } 447 448 // GetFlowLogStatus - Queries status of flow log and traffic analytics (optional) on a specified resource. 449 // If the operation fails it returns an *azcore.ResponseError type. 450 // 451 // Generated from API version 2024-05-01 452 func (client *WatchersClient) getFlowLogStatus(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters FlowLogStatusParameters, options *WatchersClientBeginGetFlowLogStatusOptions) (*http.Response, error) { 453 var err error 454 const operationName = "WatchersClient.BeginGetFlowLogStatus" 455 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 456 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 457 defer func() { endSpan(err) }() 458 req, err := client.getFlowLogStatusCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 459 if err != nil { 460 return nil, err 461 } 462 httpResp, err := client.internal.Pipeline().Do(req) 463 if err != nil { 464 return nil, err 465 } 466 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 467 err = runtime.NewResponseError(httpResp) 468 return nil, err 469 } 470 return httpResp, nil 471 } 472 473 // getFlowLogStatusCreateRequest creates the GetFlowLogStatus request. 474 func (client *WatchersClient) getFlowLogStatusCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters FlowLogStatusParameters, options *WatchersClientBeginGetFlowLogStatusOptions) (*policy.Request, error) { 475 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/queryFlowLogStatus" 476 if resourceGroupName == "" { 477 return nil, errors.New("parameter resourceGroupName cannot be empty") 478 } 479 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 480 if networkWatcherName == "" { 481 return nil, errors.New("parameter networkWatcherName cannot be empty") 482 } 483 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 484 if client.subscriptionID == "" { 485 return nil, errors.New("parameter client.subscriptionID cannot be empty") 486 } 487 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 488 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 489 if err != nil { 490 return nil, err 491 } 492 reqQP := req.Raw().URL.Query() 493 reqQP.Set("api-version", "2024-05-01") 494 req.Raw().URL.RawQuery = reqQP.Encode() 495 req.Raw().Header["Accept"] = []string{"application/json"} 496 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 497 return nil, err 498 } 499 return req, nil 500 } 501 502 // BeginGetNetworkConfigurationDiagnostic - Gets Network Configuration Diagnostic data to help customers understand and debug 503 // network behavior. It provides detailed information on what security rules were applied to a specified traffic flow and 504 // the result of evaluating these rules. Customers must provide details of a flow like source, destination, protocol, etc. 505 // The API returns whether traffic was allowed or denied, the rules evaluated for 506 // the specified flow and the evaluation results. 507 // If the operation fails it returns an *azcore.ResponseError type. 508 // 509 // Generated from API version 2024-05-01 510 // - resourceGroupName - The name of the resource group. 511 // - networkWatcherName - The name of the network watcher. 512 // - parameters - Parameters to get network configuration diagnostic. 513 // - options - WatchersClientBeginGetNetworkConfigurationDiagnosticOptions contains the optional parameters for the WatchersClient.BeginGetNetworkConfigurationDiagnostic 514 // method. 515 func (client *WatchersClient) BeginGetNetworkConfigurationDiagnostic(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters ConfigurationDiagnosticParameters, options *WatchersClientBeginGetNetworkConfigurationDiagnosticOptions) (*runtime.Poller[WatchersClientGetNetworkConfigurationDiagnosticResponse], error) { 516 if options == nil || options.ResumeToken == "" { 517 resp, err := client.getNetworkConfigurationDiagnostic(ctx, resourceGroupName, networkWatcherName, parameters, options) 518 if err != nil { 519 return nil, err 520 } 521 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WatchersClientGetNetworkConfigurationDiagnosticResponse]{ 522 FinalStateVia: runtime.FinalStateViaLocation, 523 Tracer: client.internal.Tracer(), 524 }) 525 return poller, err 526 } else { 527 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WatchersClientGetNetworkConfigurationDiagnosticResponse]{ 528 Tracer: client.internal.Tracer(), 529 }) 530 } 531 } 532 533 // GetNetworkConfigurationDiagnostic - Gets Network Configuration Diagnostic data to help customers understand and debug network 534 // behavior. It provides detailed information on what security rules were applied to a specified traffic flow and 535 // the result of evaluating these rules. Customers must provide details of a flow like source, destination, protocol, etc. 536 // The API returns whether traffic was allowed or denied, the rules evaluated for 537 // the specified flow and the evaluation results. 538 // If the operation fails it returns an *azcore.ResponseError type. 539 // 540 // Generated from API version 2024-05-01 541 func (client *WatchersClient) getNetworkConfigurationDiagnostic(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters ConfigurationDiagnosticParameters, options *WatchersClientBeginGetNetworkConfigurationDiagnosticOptions) (*http.Response, error) { 542 var err error 543 const operationName = "WatchersClient.BeginGetNetworkConfigurationDiagnostic" 544 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 545 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 546 defer func() { endSpan(err) }() 547 req, err := client.getNetworkConfigurationDiagnosticCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 548 if err != nil { 549 return nil, err 550 } 551 httpResp, err := client.internal.Pipeline().Do(req) 552 if err != nil { 553 return nil, err 554 } 555 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 556 err = runtime.NewResponseError(httpResp) 557 return nil, err 558 } 559 return httpResp, nil 560 } 561 562 // getNetworkConfigurationDiagnosticCreateRequest creates the GetNetworkConfigurationDiagnostic request. 563 func (client *WatchersClient) getNetworkConfigurationDiagnosticCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters ConfigurationDiagnosticParameters, options *WatchersClientBeginGetNetworkConfigurationDiagnosticOptions) (*policy.Request, error) { 564 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/networkConfigurationDiagnostic" 565 if resourceGroupName == "" { 566 return nil, errors.New("parameter resourceGroupName cannot be empty") 567 } 568 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 569 if networkWatcherName == "" { 570 return nil, errors.New("parameter networkWatcherName cannot be empty") 571 } 572 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 573 if client.subscriptionID == "" { 574 return nil, errors.New("parameter client.subscriptionID cannot be empty") 575 } 576 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 577 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 578 if err != nil { 579 return nil, err 580 } 581 reqQP := req.Raw().URL.Query() 582 reqQP.Set("api-version", "2024-05-01") 583 req.Raw().URL.RawQuery = reqQP.Encode() 584 req.Raw().Header["Accept"] = []string{"application/json"} 585 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 586 return nil, err 587 } 588 return req, nil 589 } 590 591 // BeginGetNextHop - Gets the next hop from the specified VM. 592 // If the operation fails it returns an *azcore.ResponseError type. 593 // 594 // Generated from API version 2024-05-01 595 // - resourceGroupName - The name of the resource group. 596 // - networkWatcherName - The name of the network watcher. 597 // - parameters - Parameters that define the source and destination endpoint. 598 // - options - WatchersClientBeginGetNextHopOptions contains the optional parameters for the WatchersClient.BeginGetNextHop 599 // method. 600 func (client *WatchersClient) BeginGetNextHop(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters NextHopParameters, options *WatchersClientBeginGetNextHopOptions) (*runtime.Poller[WatchersClientGetNextHopResponse], error) { 601 if options == nil || options.ResumeToken == "" { 602 resp, err := client.getNextHop(ctx, resourceGroupName, networkWatcherName, parameters, options) 603 if err != nil { 604 return nil, err 605 } 606 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WatchersClientGetNextHopResponse]{ 607 FinalStateVia: runtime.FinalStateViaLocation, 608 Tracer: client.internal.Tracer(), 609 }) 610 return poller, err 611 } else { 612 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WatchersClientGetNextHopResponse]{ 613 Tracer: client.internal.Tracer(), 614 }) 615 } 616 } 617 618 // GetNextHop - Gets the next hop from the specified VM. 619 // If the operation fails it returns an *azcore.ResponseError type. 620 // 621 // Generated from API version 2024-05-01 622 func (client *WatchersClient) getNextHop(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters NextHopParameters, options *WatchersClientBeginGetNextHopOptions) (*http.Response, error) { 623 var err error 624 const operationName = "WatchersClient.BeginGetNextHop" 625 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 626 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 627 defer func() { endSpan(err) }() 628 req, err := client.getNextHopCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 629 if err != nil { 630 return nil, err 631 } 632 httpResp, err := client.internal.Pipeline().Do(req) 633 if err != nil { 634 return nil, err 635 } 636 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 637 err = runtime.NewResponseError(httpResp) 638 return nil, err 639 } 640 return httpResp, nil 641 } 642 643 // getNextHopCreateRequest creates the GetNextHop request. 644 func (client *WatchersClient) getNextHopCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters NextHopParameters, options *WatchersClientBeginGetNextHopOptions) (*policy.Request, error) { 645 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/nextHop" 646 if resourceGroupName == "" { 647 return nil, errors.New("parameter resourceGroupName cannot be empty") 648 } 649 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 650 if networkWatcherName == "" { 651 return nil, errors.New("parameter networkWatcherName cannot be empty") 652 } 653 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 654 if client.subscriptionID == "" { 655 return nil, errors.New("parameter client.subscriptionID cannot be empty") 656 } 657 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 658 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 659 if err != nil { 660 return nil, err 661 } 662 reqQP := req.Raw().URL.Query() 663 reqQP.Set("api-version", "2024-05-01") 664 req.Raw().URL.RawQuery = reqQP.Encode() 665 req.Raw().Header["Accept"] = []string{"application/json"} 666 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 667 return nil, err 668 } 669 return req, nil 670 } 671 672 // GetTopology - Gets the current network topology by resource group. 673 // If the operation fails it returns an *azcore.ResponseError type. 674 // 675 // Generated from API version 2024-05-01 676 // - resourceGroupName - The name of the resource group. 677 // - networkWatcherName - The name of the network watcher. 678 // - parameters - Parameters that define the representation of topology. 679 // - options - WatchersClientGetTopologyOptions contains the optional parameters for the WatchersClient.GetTopology method. 680 func (client *WatchersClient) GetTopology(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters TopologyParameters, options *WatchersClientGetTopologyOptions) (WatchersClientGetTopologyResponse, error) { 681 var err error 682 const operationName = "WatchersClient.GetTopology" 683 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 684 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 685 defer func() { endSpan(err) }() 686 req, err := client.getTopologyCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 687 if err != nil { 688 return WatchersClientGetTopologyResponse{}, err 689 } 690 httpResp, err := client.internal.Pipeline().Do(req) 691 if err != nil { 692 return WatchersClientGetTopologyResponse{}, err 693 } 694 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 695 err = runtime.NewResponseError(httpResp) 696 return WatchersClientGetTopologyResponse{}, err 697 } 698 resp, err := client.getTopologyHandleResponse(httpResp) 699 return resp, err 700 } 701 702 // getTopologyCreateRequest creates the GetTopology request. 703 func (client *WatchersClient) getTopologyCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters TopologyParameters, options *WatchersClientGetTopologyOptions) (*policy.Request, error) { 704 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/topology" 705 if resourceGroupName == "" { 706 return nil, errors.New("parameter resourceGroupName cannot be empty") 707 } 708 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 709 if networkWatcherName == "" { 710 return nil, errors.New("parameter networkWatcherName cannot be empty") 711 } 712 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 713 if client.subscriptionID == "" { 714 return nil, errors.New("parameter client.subscriptionID cannot be empty") 715 } 716 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 717 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 718 if err != nil { 719 return nil, err 720 } 721 reqQP := req.Raw().URL.Query() 722 reqQP.Set("api-version", "2024-05-01") 723 req.Raw().URL.RawQuery = reqQP.Encode() 724 req.Raw().Header["Accept"] = []string{"application/json"} 725 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 726 return nil, err 727 } 728 return req, nil 729 } 730 731 // getTopologyHandleResponse handles the GetTopology response. 732 func (client *WatchersClient) getTopologyHandleResponse(resp *http.Response) (WatchersClientGetTopologyResponse, error) { 733 result := WatchersClientGetTopologyResponse{} 734 if err := runtime.UnmarshalAsJSON(resp, &result.Topology); err != nil { 735 return WatchersClientGetTopologyResponse{}, err 736 } 737 return result, nil 738 } 739 740 // BeginGetTroubleshooting - Initiate troubleshooting on a specified resource. 741 // If the operation fails it returns an *azcore.ResponseError type. 742 // 743 // Generated from API version 2024-05-01 744 // - resourceGroupName - The name of the resource group. 745 // - networkWatcherName - The name of the network watcher resource. 746 // - parameters - Parameters that define the resource to troubleshoot. 747 // - options - WatchersClientBeginGetTroubleshootingOptions contains the optional parameters for the WatchersClient.BeginGetTroubleshooting 748 // method. 749 func (client *WatchersClient) BeginGetTroubleshooting(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters TroubleshootingParameters, options *WatchersClientBeginGetTroubleshootingOptions) (*runtime.Poller[WatchersClientGetTroubleshootingResponse], error) { 750 if options == nil || options.ResumeToken == "" { 751 resp, err := client.getTroubleshooting(ctx, resourceGroupName, networkWatcherName, parameters, options) 752 if err != nil { 753 return nil, err 754 } 755 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WatchersClientGetTroubleshootingResponse]{ 756 FinalStateVia: runtime.FinalStateViaLocation, 757 Tracer: client.internal.Tracer(), 758 }) 759 return poller, err 760 } else { 761 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WatchersClientGetTroubleshootingResponse]{ 762 Tracer: client.internal.Tracer(), 763 }) 764 } 765 } 766 767 // GetTroubleshooting - Initiate troubleshooting on a specified resource. 768 // If the operation fails it returns an *azcore.ResponseError type. 769 // 770 // Generated from API version 2024-05-01 771 func (client *WatchersClient) getTroubleshooting(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters TroubleshootingParameters, options *WatchersClientBeginGetTroubleshootingOptions) (*http.Response, error) { 772 var err error 773 const operationName = "WatchersClient.BeginGetTroubleshooting" 774 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 775 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 776 defer func() { endSpan(err) }() 777 req, err := client.getTroubleshootingCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 778 if err != nil { 779 return nil, err 780 } 781 httpResp, err := client.internal.Pipeline().Do(req) 782 if err != nil { 783 return nil, err 784 } 785 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 786 err = runtime.NewResponseError(httpResp) 787 return nil, err 788 } 789 return httpResp, nil 790 } 791 792 // getTroubleshootingCreateRequest creates the GetTroubleshooting request. 793 func (client *WatchersClient) getTroubleshootingCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters TroubleshootingParameters, options *WatchersClientBeginGetTroubleshootingOptions) (*policy.Request, error) { 794 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/troubleshoot" 795 if resourceGroupName == "" { 796 return nil, errors.New("parameter resourceGroupName cannot be empty") 797 } 798 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 799 if networkWatcherName == "" { 800 return nil, errors.New("parameter networkWatcherName cannot be empty") 801 } 802 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 803 if client.subscriptionID == "" { 804 return nil, errors.New("parameter client.subscriptionID cannot be empty") 805 } 806 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 807 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 808 if err != nil { 809 return nil, err 810 } 811 reqQP := req.Raw().URL.Query() 812 reqQP.Set("api-version", "2024-05-01") 813 req.Raw().URL.RawQuery = reqQP.Encode() 814 req.Raw().Header["Accept"] = []string{"application/json"} 815 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 816 return nil, err 817 } 818 return req, nil 819 } 820 821 // BeginGetTroubleshootingResult - Get the last completed troubleshooting result on a specified resource. 822 // If the operation fails it returns an *azcore.ResponseError type. 823 // 824 // Generated from API version 2024-05-01 825 // - resourceGroupName - The name of the resource group. 826 // - networkWatcherName - The name of the network watcher resource. 827 // - parameters - Parameters that define the resource to query the troubleshooting result. 828 // - options - WatchersClientBeginGetTroubleshootingResultOptions contains the optional parameters for the WatchersClient.BeginGetTroubleshootingResult 829 // method. 830 func (client *WatchersClient) BeginGetTroubleshootingResult(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters QueryTroubleshootingParameters, options *WatchersClientBeginGetTroubleshootingResultOptions) (*runtime.Poller[WatchersClientGetTroubleshootingResultResponse], error) { 831 if options == nil || options.ResumeToken == "" { 832 resp, err := client.getTroubleshootingResult(ctx, resourceGroupName, networkWatcherName, parameters, options) 833 if err != nil { 834 return nil, err 835 } 836 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WatchersClientGetTroubleshootingResultResponse]{ 837 FinalStateVia: runtime.FinalStateViaLocation, 838 Tracer: client.internal.Tracer(), 839 }) 840 return poller, err 841 } else { 842 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WatchersClientGetTroubleshootingResultResponse]{ 843 Tracer: client.internal.Tracer(), 844 }) 845 } 846 } 847 848 // GetTroubleshootingResult - Get the last completed troubleshooting result on a specified resource. 849 // If the operation fails it returns an *azcore.ResponseError type. 850 // 851 // Generated from API version 2024-05-01 852 func (client *WatchersClient) getTroubleshootingResult(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters QueryTroubleshootingParameters, options *WatchersClientBeginGetTroubleshootingResultOptions) (*http.Response, error) { 853 var err error 854 const operationName = "WatchersClient.BeginGetTroubleshootingResult" 855 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 856 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 857 defer func() { endSpan(err) }() 858 req, err := client.getTroubleshootingResultCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 859 if err != nil { 860 return nil, err 861 } 862 httpResp, err := client.internal.Pipeline().Do(req) 863 if err != nil { 864 return nil, err 865 } 866 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 867 err = runtime.NewResponseError(httpResp) 868 return nil, err 869 } 870 return httpResp, nil 871 } 872 873 // getTroubleshootingResultCreateRequest creates the GetTroubleshootingResult request. 874 func (client *WatchersClient) getTroubleshootingResultCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters QueryTroubleshootingParameters, options *WatchersClientBeginGetTroubleshootingResultOptions) (*policy.Request, error) { 875 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/queryTroubleshootResult" 876 if resourceGroupName == "" { 877 return nil, errors.New("parameter resourceGroupName cannot be empty") 878 } 879 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 880 if networkWatcherName == "" { 881 return nil, errors.New("parameter networkWatcherName cannot be empty") 882 } 883 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 884 if client.subscriptionID == "" { 885 return nil, errors.New("parameter client.subscriptionID cannot be empty") 886 } 887 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 888 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 889 if err != nil { 890 return nil, err 891 } 892 reqQP := req.Raw().URL.Query() 893 reqQP.Set("api-version", "2024-05-01") 894 req.Raw().URL.RawQuery = reqQP.Encode() 895 req.Raw().Header["Accept"] = []string{"application/json"} 896 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 897 return nil, err 898 } 899 return req, nil 900 } 901 902 // BeginGetVMSecurityRules - Gets the configured and effective security group rules on the specified VM. 903 // If the operation fails it returns an *azcore.ResponseError type. 904 // 905 // Generated from API version 2024-05-01 906 // - resourceGroupName - The name of the resource group. 907 // - networkWatcherName - The name of the network watcher. 908 // - parameters - Parameters that define the VM to check security groups for. 909 // - options - WatchersClientBeginGetVMSecurityRulesOptions contains the optional parameters for the WatchersClient.BeginGetVMSecurityRules 910 // method. 911 func (client *WatchersClient) BeginGetVMSecurityRules(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters SecurityGroupViewParameters, options *WatchersClientBeginGetVMSecurityRulesOptions) (*runtime.Poller[WatchersClientGetVMSecurityRulesResponse], error) { 912 if options == nil || options.ResumeToken == "" { 913 resp, err := client.getVMSecurityRules(ctx, resourceGroupName, networkWatcherName, parameters, options) 914 if err != nil { 915 return nil, err 916 } 917 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WatchersClientGetVMSecurityRulesResponse]{ 918 FinalStateVia: runtime.FinalStateViaLocation, 919 Tracer: client.internal.Tracer(), 920 }) 921 return poller, err 922 } else { 923 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WatchersClientGetVMSecurityRulesResponse]{ 924 Tracer: client.internal.Tracer(), 925 }) 926 } 927 } 928 929 // GetVMSecurityRules - Gets the configured and effective security group rules on the specified VM. 930 // If the operation fails it returns an *azcore.ResponseError type. 931 // 932 // Generated from API version 2024-05-01 933 func (client *WatchersClient) getVMSecurityRules(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters SecurityGroupViewParameters, options *WatchersClientBeginGetVMSecurityRulesOptions) (*http.Response, error) { 934 var err error 935 const operationName = "WatchersClient.BeginGetVMSecurityRules" 936 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 937 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 938 defer func() { endSpan(err) }() 939 req, err := client.getVMSecurityRulesCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 940 if err != nil { 941 return nil, err 942 } 943 httpResp, err := client.internal.Pipeline().Do(req) 944 if err != nil { 945 return nil, err 946 } 947 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 948 err = runtime.NewResponseError(httpResp) 949 return nil, err 950 } 951 return httpResp, nil 952 } 953 954 // getVMSecurityRulesCreateRequest creates the GetVMSecurityRules request. 955 func (client *WatchersClient) getVMSecurityRulesCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters SecurityGroupViewParameters, options *WatchersClientBeginGetVMSecurityRulesOptions) (*policy.Request, error) { 956 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/securityGroupView" 957 if resourceGroupName == "" { 958 return nil, errors.New("parameter resourceGroupName cannot be empty") 959 } 960 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 961 if networkWatcherName == "" { 962 return nil, errors.New("parameter networkWatcherName cannot be empty") 963 } 964 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 965 if client.subscriptionID == "" { 966 return nil, errors.New("parameter client.subscriptionID cannot be empty") 967 } 968 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 969 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 970 if err != nil { 971 return nil, err 972 } 973 reqQP := req.Raw().URL.Query() 974 reqQP.Set("api-version", "2024-05-01") 975 req.Raw().URL.RawQuery = reqQP.Encode() 976 req.Raw().Header["Accept"] = []string{"application/json"} 977 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 978 return nil, err 979 } 980 return req, nil 981 } 982 983 // NewListPager - Gets all network watchers by resource group. 984 // 985 // Generated from API version 2024-05-01 986 // - resourceGroupName - The name of the resource group. 987 // - options - WatchersClientListOptions contains the optional parameters for the WatchersClient.NewListPager method. 988 func (client *WatchersClient) NewListPager(resourceGroupName string, options *WatchersClientListOptions) *runtime.Pager[WatchersClientListResponse] { 989 return runtime.NewPager(runtime.PagingHandler[WatchersClientListResponse]{ 990 More: func(page WatchersClientListResponse) bool { 991 return false 992 }, 993 Fetcher: func(ctx context.Context, page *WatchersClientListResponse) (WatchersClientListResponse, error) { 994 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WatchersClient.NewListPager") 995 req, err := client.listCreateRequest(ctx, resourceGroupName, options) 996 if err != nil { 997 return WatchersClientListResponse{}, err 998 } 999 resp, err := client.internal.Pipeline().Do(req) 1000 if err != nil { 1001 return WatchersClientListResponse{}, err 1002 } 1003 if !runtime.HasStatusCode(resp, http.StatusOK) { 1004 return WatchersClientListResponse{}, runtime.NewResponseError(resp) 1005 } 1006 return client.listHandleResponse(resp) 1007 }, 1008 Tracer: client.internal.Tracer(), 1009 }) 1010 } 1011 1012 // listCreateRequest creates the List request. 1013 func (client *WatchersClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *WatchersClientListOptions) (*policy.Request, error) { 1014 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers" 1015 if resourceGroupName == "" { 1016 return nil, errors.New("parameter resourceGroupName cannot be empty") 1017 } 1018 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 1019 if client.subscriptionID == "" { 1020 return nil, errors.New("parameter client.subscriptionID cannot be empty") 1021 } 1022 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 1023 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 1024 if err != nil { 1025 return nil, err 1026 } 1027 reqQP := req.Raw().URL.Query() 1028 reqQP.Set("api-version", "2024-05-01") 1029 req.Raw().URL.RawQuery = reqQP.Encode() 1030 req.Raw().Header["Accept"] = []string{"application/json"} 1031 return req, nil 1032 } 1033 1034 // listHandleResponse handles the List response. 1035 func (client *WatchersClient) listHandleResponse(resp *http.Response) (WatchersClientListResponse, error) { 1036 result := WatchersClientListResponse{} 1037 if err := runtime.UnmarshalAsJSON(resp, &result.WatcherListResult); err != nil { 1038 return WatchersClientListResponse{}, err 1039 } 1040 return result, nil 1041 } 1042 1043 // NewListAllPager - Gets all network watchers by subscription. 1044 // 1045 // Generated from API version 2024-05-01 1046 // - options - WatchersClientListAllOptions contains the optional parameters for the WatchersClient.NewListAllPager method. 1047 func (client *WatchersClient) NewListAllPager(options *WatchersClientListAllOptions) *runtime.Pager[WatchersClientListAllResponse] { 1048 return runtime.NewPager(runtime.PagingHandler[WatchersClientListAllResponse]{ 1049 More: func(page WatchersClientListAllResponse) bool { 1050 return false 1051 }, 1052 Fetcher: func(ctx context.Context, page *WatchersClientListAllResponse) (WatchersClientListAllResponse, error) { 1053 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WatchersClient.NewListAllPager") 1054 req, err := client.listAllCreateRequest(ctx, options) 1055 if err != nil { 1056 return WatchersClientListAllResponse{}, err 1057 } 1058 resp, err := client.internal.Pipeline().Do(req) 1059 if err != nil { 1060 return WatchersClientListAllResponse{}, err 1061 } 1062 if !runtime.HasStatusCode(resp, http.StatusOK) { 1063 return WatchersClientListAllResponse{}, runtime.NewResponseError(resp) 1064 } 1065 return client.listAllHandleResponse(resp) 1066 }, 1067 Tracer: client.internal.Tracer(), 1068 }) 1069 } 1070 1071 // listAllCreateRequest creates the ListAll request. 1072 func (client *WatchersClient) listAllCreateRequest(ctx context.Context, options *WatchersClientListAllOptions) (*policy.Request, error) { 1073 urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Network/networkWatchers" 1074 if client.subscriptionID == "" { 1075 return nil, errors.New("parameter client.subscriptionID cannot be empty") 1076 } 1077 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 1078 req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 1079 if err != nil { 1080 return nil, err 1081 } 1082 reqQP := req.Raw().URL.Query() 1083 reqQP.Set("api-version", "2024-05-01") 1084 req.Raw().URL.RawQuery = reqQP.Encode() 1085 req.Raw().Header["Accept"] = []string{"application/json"} 1086 return req, nil 1087 } 1088 1089 // listAllHandleResponse handles the ListAll response. 1090 func (client *WatchersClient) listAllHandleResponse(resp *http.Response) (WatchersClientListAllResponse, error) { 1091 result := WatchersClientListAllResponse{} 1092 if err := runtime.UnmarshalAsJSON(resp, &result.WatcherListResult); err != nil { 1093 return WatchersClientListAllResponse{}, err 1094 } 1095 return result, nil 1096 } 1097 1098 // BeginListAvailableProviders - NOTE: This feature is currently in preview and still being tested for stability. Lists all 1099 // available internet service providers for a specified Azure region. 1100 // If the operation fails it returns an *azcore.ResponseError type. 1101 // 1102 // Generated from API version 2024-05-01 1103 // - resourceGroupName - The name of the network watcher resource group. 1104 // - networkWatcherName - The name of the network watcher resource. 1105 // - parameters - Parameters that scope the list of available providers. 1106 // - options - WatchersClientBeginListAvailableProvidersOptions contains the optional parameters for the WatchersClient.BeginListAvailableProviders 1107 // method. 1108 func (client *WatchersClient) BeginListAvailableProviders(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters AvailableProvidersListParameters, options *WatchersClientBeginListAvailableProvidersOptions) (*runtime.Poller[WatchersClientListAvailableProvidersResponse], error) { 1109 if options == nil || options.ResumeToken == "" { 1110 resp, err := client.listAvailableProviders(ctx, resourceGroupName, networkWatcherName, parameters, options) 1111 if err != nil { 1112 return nil, err 1113 } 1114 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WatchersClientListAvailableProvidersResponse]{ 1115 FinalStateVia: runtime.FinalStateViaLocation, 1116 Tracer: client.internal.Tracer(), 1117 }) 1118 return poller, err 1119 } else { 1120 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WatchersClientListAvailableProvidersResponse]{ 1121 Tracer: client.internal.Tracer(), 1122 }) 1123 } 1124 } 1125 1126 // ListAvailableProviders - NOTE: This feature is currently in preview and still being tested for stability. Lists all available 1127 // internet service providers for a specified Azure region. 1128 // If the operation fails it returns an *azcore.ResponseError type. 1129 // 1130 // Generated from API version 2024-05-01 1131 func (client *WatchersClient) listAvailableProviders(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters AvailableProvidersListParameters, options *WatchersClientBeginListAvailableProvidersOptions) (*http.Response, error) { 1132 var err error 1133 const operationName = "WatchersClient.BeginListAvailableProviders" 1134 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 1135 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 1136 defer func() { endSpan(err) }() 1137 req, err := client.listAvailableProvidersCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 1138 if err != nil { 1139 return nil, err 1140 } 1141 httpResp, err := client.internal.Pipeline().Do(req) 1142 if err != nil { 1143 return nil, err 1144 } 1145 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 1146 err = runtime.NewResponseError(httpResp) 1147 return nil, err 1148 } 1149 return httpResp, nil 1150 } 1151 1152 // listAvailableProvidersCreateRequest creates the ListAvailableProviders request. 1153 func (client *WatchersClient) listAvailableProvidersCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters AvailableProvidersListParameters, options *WatchersClientBeginListAvailableProvidersOptions) (*policy.Request, error) { 1154 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/availableProvidersList" 1155 if resourceGroupName == "" { 1156 return nil, errors.New("parameter resourceGroupName cannot be empty") 1157 } 1158 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 1159 if networkWatcherName == "" { 1160 return nil, errors.New("parameter networkWatcherName cannot be empty") 1161 } 1162 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 1163 if client.subscriptionID == "" { 1164 return nil, errors.New("parameter client.subscriptionID cannot be empty") 1165 } 1166 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 1167 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 1168 if err != nil { 1169 return nil, err 1170 } 1171 reqQP := req.Raw().URL.Query() 1172 reqQP.Set("api-version", "2024-05-01") 1173 req.Raw().URL.RawQuery = reqQP.Encode() 1174 req.Raw().Header["Accept"] = []string{"application/json"} 1175 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 1176 return nil, err 1177 } 1178 return req, nil 1179 } 1180 1181 // BeginSetFlowLogConfiguration - Configures flow log and traffic analytics (optional) on a specified resource. 1182 // If the operation fails it returns an *azcore.ResponseError type. 1183 // 1184 // Generated from API version 2024-05-01 1185 // - resourceGroupName - The name of the network watcher resource group. 1186 // - networkWatcherName - The name of the network watcher resource. 1187 // - parameters - Parameters that define the configuration of flow log. 1188 // - options - WatchersClientBeginSetFlowLogConfigurationOptions contains the optional parameters for the WatchersClient.BeginSetFlowLogConfiguration 1189 // method. 1190 func (client *WatchersClient) BeginSetFlowLogConfiguration(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters FlowLogInformation, options *WatchersClientBeginSetFlowLogConfigurationOptions) (*runtime.Poller[WatchersClientSetFlowLogConfigurationResponse], error) { 1191 if options == nil || options.ResumeToken == "" { 1192 resp, err := client.setFlowLogConfiguration(ctx, resourceGroupName, networkWatcherName, parameters, options) 1193 if err != nil { 1194 return nil, err 1195 } 1196 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WatchersClientSetFlowLogConfigurationResponse]{ 1197 FinalStateVia: runtime.FinalStateViaLocation, 1198 Tracer: client.internal.Tracer(), 1199 }) 1200 return poller, err 1201 } else { 1202 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WatchersClientSetFlowLogConfigurationResponse]{ 1203 Tracer: client.internal.Tracer(), 1204 }) 1205 } 1206 } 1207 1208 // SetFlowLogConfiguration - Configures flow log and traffic analytics (optional) on a specified resource. 1209 // If the operation fails it returns an *azcore.ResponseError type. 1210 // 1211 // Generated from API version 2024-05-01 1212 func (client *WatchersClient) setFlowLogConfiguration(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters FlowLogInformation, options *WatchersClientBeginSetFlowLogConfigurationOptions) (*http.Response, error) { 1213 var err error 1214 const operationName = "WatchersClient.BeginSetFlowLogConfiguration" 1215 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 1216 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 1217 defer func() { endSpan(err) }() 1218 req, err := client.setFlowLogConfigurationCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 1219 if err != nil { 1220 return nil, err 1221 } 1222 httpResp, err := client.internal.Pipeline().Do(req) 1223 if err != nil { 1224 return nil, err 1225 } 1226 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 1227 err = runtime.NewResponseError(httpResp) 1228 return nil, err 1229 } 1230 return httpResp, nil 1231 } 1232 1233 // setFlowLogConfigurationCreateRequest creates the SetFlowLogConfiguration request. 1234 func (client *WatchersClient) setFlowLogConfigurationCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters FlowLogInformation, options *WatchersClientBeginSetFlowLogConfigurationOptions) (*policy.Request, error) { 1235 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/configureFlowLog" 1236 if resourceGroupName == "" { 1237 return nil, errors.New("parameter resourceGroupName cannot be empty") 1238 } 1239 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 1240 if networkWatcherName == "" { 1241 return nil, errors.New("parameter networkWatcherName cannot be empty") 1242 } 1243 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 1244 if client.subscriptionID == "" { 1245 return nil, errors.New("parameter client.subscriptionID cannot be empty") 1246 } 1247 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 1248 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 1249 if err != nil { 1250 return nil, err 1251 } 1252 reqQP := req.Raw().URL.Query() 1253 reqQP.Set("api-version", "2024-05-01") 1254 req.Raw().URL.RawQuery = reqQP.Encode() 1255 req.Raw().Header["Accept"] = []string{"application/json"} 1256 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 1257 return nil, err 1258 } 1259 return req, nil 1260 } 1261 1262 // UpdateTags - Updates a network watcher tags. 1263 // If the operation fails it returns an *azcore.ResponseError type. 1264 // 1265 // Generated from API version 2024-05-01 1266 // - resourceGroupName - The name of the resource group. 1267 // - networkWatcherName - The name of the network watcher. 1268 // - parameters - Parameters supplied to update network watcher tags. 1269 // - options - WatchersClientUpdateTagsOptions contains the optional parameters for the WatchersClient.UpdateTags method. 1270 func (client *WatchersClient) UpdateTags(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters TagsObject, options *WatchersClientUpdateTagsOptions) (WatchersClientUpdateTagsResponse, error) { 1271 var err error 1272 const operationName = "WatchersClient.UpdateTags" 1273 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 1274 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 1275 defer func() { endSpan(err) }() 1276 req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 1277 if err != nil { 1278 return WatchersClientUpdateTagsResponse{}, err 1279 } 1280 httpResp, err := client.internal.Pipeline().Do(req) 1281 if err != nil { 1282 return WatchersClientUpdateTagsResponse{}, err 1283 } 1284 if !runtime.HasStatusCode(httpResp, http.StatusOK) { 1285 err = runtime.NewResponseError(httpResp) 1286 return WatchersClientUpdateTagsResponse{}, err 1287 } 1288 resp, err := client.updateTagsHandleResponse(httpResp) 1289 return resp, err 1290 } 1291 1292 // updateTagsCreateRequest creates the UpdateTags request. 1293 func (client *WatchersClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters TagsObject, options *WatchersClientUpdateTagsOptions) (*policy.Request, error) { 1294 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}" 1295 if resourceGroupName == "" { 1296 return nil, errors.New("parameter resourceGroupName cannot be empty") 1297 } 1298 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 1299 if networkWatcherName == "" { 1300 return nil, errors.New("parameter networkWatcherName cannot be empty") 1301 } 1302 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 1303 if client.subscriptionID == "" { 1304 return nil, errors.New("parameter client.subscriptionID cannot be empty") 1305 } 1306 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 1307 req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 1308 if err != nil { 1309 return nil, err 1310 } 1311 reqQP := req.Raw().URL.Query() 1312 reqQP.Set("api-version", "2024-05-01") 1313 req.Raw().URL.RawQuery = reqQP.Encode() 1314 req.Raw().Header["Accept"] = []string{"application/json"} 1315 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 1316 return nil, err 1317 } 1318 return req, nil 1319 } 1320 1321 // updateTagsHandleResponse handles the UpdateTags response. 1322 func (client *WatchersClient) updateTagsHandleResponse(resp *http.Response) (WatchersClientUpdateTagsResponse, error) { 1323 result := WatchersClientUpdateTagsResponse{} 1324 if err := runtime.UnmarshalAsJSON(resp, &result.Watcher); err != nil { 1325 return WatchersClientUpdateTagsResponse{}, err 1326 } 1327 return result, nil 1328 } 1329 1330 // BeginVerifyIPFlow - Verify IP flow from the specified VM to a location given the currently configured NSG rules. 1331 // If the operation fails it returns an *azcore.ResponseError type. 1332 // 1333 // Generated from API version 2024-05-01 1334 // - resourceGroupName - The name of the resource group. 1335 // - networkWatcherName - The name of the network watcher. 1336 // - parameters - Parameters that define the IP flow to be verified. 1337 // - options - WatchersClientBeginVerifyIPFlowOptions contains the optional parameters for the WatchersClient.BeginVerifyIPFlow 1338 // method. 1339 func (client *WatchersClient) BeginVerifyIPFlow(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters VerificationIPFlowParameters, options *WatchersClientBeginVerifyIPFlowOptions) (*runtime.Poller[WatchersClientVerifyIPFlowResponse], error) { 1340 if options == nil || options.ResumeToken == "" { 1341 resp, err := client.verifyIPFlow(ctx, resourceGroupName, networkWatcherName, parameters, options) 1342 if err != nil { 1343 return nil, err 1344 } 1345 poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WatchersClientVerifyIPFlowResponse]{ 1346 FinalStateVia: runtime.FinalStateViaLocation, 1347 Tracer: client.internal.Tracer(), 1348 }) 1349 return poller, err 1350 } else { 1351 return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WatchersClientVerifyIPFlowResponse]{ 1352 Tracer: client.internal.Tracer(), 1353 }) 1354 } 1355 } 1356 1357 // VerifyIPFlow - Verify IP flow from the specified VM to a location given the currently configured NSG rules. 1358 // If the operation fails it returns an *azcore.ResponseError type. 1359 // 1360 // Generated from API version 2024-05-01 1361 func (client *WatchersClient) verifyIPFlow(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters VerificationIPFlowParameters, options *WatchersClientBeginVerifyIPFlowOptions) (*http.Response, error) { 1362 var err error 1363 const operationName = "WatchersClient.BeginVerifyIPFlow" 1364 ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) 1365 ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) 1366 defer func() { endSpan(err) }() 1367 req, err := client.verifyIPFlowCreateRequest(ctx, resourceGroupName, networkWatcherName, parameters, options) 1368 if err != nil { 1369 return nil, err 1370 } 1371 httpResp, err := client.internal.Pipeline().Do(req) 1372 if err != nil { 1373 return nil, err 1374 } 1375 if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { 1376 err = runtime.NewResponseError(httpResp) 1377 return nil, err 1378 } 1379 return httpResp, nil 1380 } 1381 1382 // verifyIPFlowCreateRequest creates the VerifyIPFlow request. 1383 func (client *WatchersClient) verifyIPFlowCreateRequest(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters VerificationIPFlowParameters, options *WatchersClientBeginVerifyIPFlowOptions) (*policy.Request, error) { 1384 urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/ipFlowVerify" 1385 if resourceGroupName == "" { 1386 return nil, errors.New("parameter resourceGroupName cannot be empty") 1387 } 1388 urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 1389 if networkWatcherName == "" { 1390 return nil, errors.New("parameter networkWatcherName cannot be empty") 1391 } 1392 urlPath = strings.ReplaceAll(urlPath, "{networkWatcherName}", url.PathEscape(networkWatcherName)) 1393 if client.subscriptionID == "" { 1394 return nil, errors.New("parameter client.subscriptionID cannot be empty") 1395 } 1396 urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) 1397 req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) 1398 if err != nil { 1399 return nil, err 1400 } 1401 reqQP := req.Raw().URL.Query() 1402 reqQP.Set("api-version", "2024-05-01") 1403 req.Raw().URL.RawQuery = reqQP.Encode() 1404 req.Raw().Header["Accept"] = []string{"application/json"} 1405 if err := runtime.MarshalAsJSON(req, parameters); err != nil { 1406 return nil, err 1407 } 1408 return req, nil 1409 }