// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT.

package armnetwork_test

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v10"
	"log"
)

// Generated from example definition: 2025-07-01/NetworkManagerRoutingRulePut.json
func ExampleRoutingRulesClient_CreateOrUpdate_createAnRoutingRule() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armnetwork.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewRoutingRulesClient().CreateOrUpdate(ctx, "rg1", "testNetworkManager", "myTestRoutingConfig", "testRuleCollection", "SampleRoutingRule", armnetwork.RoutingRule{
		Properties: &armnetwork.RoutingRulePropertiesFormat{
			Description: to.Ptr("This is Sample Routing Rule"),
			Destination: &armnetwork.RoutingRuleRouteDestination{
				Type:               to.Ptr(armnetwork.RoutingRuleDestinationTypeAddressPrefix),
				DestinationAddress: to.Ptr("10.0.0.0/16"),
			},
			NextHop: &armnetwork.RoutingRuleNextHop{
				NextHopType: to.Ptr(armnetwork.RoutingRuleNextHopTypeVirtualNetworkGateway),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res = armnetwork.RoutingRulesClientCreateOrUpdateResponse{
	// 	RoutingRule: armnetwork.RoutingRule{
	// 		Name: to.Ptr("SampleRoutingRule"),
	// 		Type: to.Ptr("Microsoft.Network/networkManagers/routingConfigurations/ruleCollections/rules"),
	// 		ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/routingConfigurations/myTestRoutingConfig/ruleCollections/testRuleCollection/rules/SampleRoutingRule"),
	// 		Properties: &armnetwork.RoutingRulePropertiesFormat{
	// 			Description: to.Ptr("This is Sample Routing Rule"),
	// 			Destination: &armnetwork.RoutingRuleRouteDestination{
	// 				Type: to.Ptr(armnetwork.RoutingRuleDestinationTypeAddressPrefix),
	// 				DestinationAddress: to.Ptr("10.0.0.0/16"),
	// 			},
	// 			NextHop: &armnetwork.RoutingRuleNextHop{
	// 				NextHopAddress: to.Ptr(""),
	// 				NextHopType: to.Ptr(armnetwork.RoutingRuleNextHopTypeVirtualNetworkGateway),
	// 			},
	// 			ProvisioningState: to.Ptr(armnetwork.ProvisioningStateSucceeded),
	// 			ResourceGUID: to.Ptr("00000000-0000-0000-0000-000000000000"),
	// 		},
	// 		SystemData: &armnetwork.SystemData{
	// 			CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-11T18:52:27Z"); return t}()),
	// 			CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef5"),
	// 			CreatedByType: to.Ptr(armnetwork.CreatedByTypeUser),
	// 			LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-11T18:52:27Z"); return t}()),
	// 			LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef5"),
	// 			LastModifiedByType: to.Ptr(armnetwork.CreatedByTypeUser),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2025-07-01/NetworkManagerRoutingRulePutEcmp.json
func ExampleRoutingRulesClient_CreateOrUpdate_createAnEcmpRoutingRule() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armnetwork.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewRoutingRulesClient().CreateOrUpdate(ctx, "rg1", "testNetworkManager", "myTestRoutingConfig", "testRuleCollection", "SampleEcmpRoutingRule", armnetwork.RoutingRule{
		Properties: &armnetwork.RoutingRulePropertiesFormat{
			Description: to.Ptr("This is a sample ECMP routing rule with multiple next hop IP addresses"),
			Destination: &armnetwork.RoutingRuleRouteDestination{
				Type:               to.Ptr(armnetwork.RoutingRuleDestinationTypeAddressPrefix),
				DestinationAddress: to.Ptr("10.0.0.0/16"),
			},
			NextHop: &armnetwork.RoutingRuleNextHop{
				NextHopType:    to.Ptr(armnetwork.RoutingRuleNextHopTypeVirtualAppliance),
				NextHopAddress: to.Ptr("10.1.0.4,10.1.0.5,10.1.0.6"),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res = armnetwork.RoutingRulesClientCreateOrUpdateResponse{
	// 	RoutingRule: armnetwork.RoutingRule{
	// 		Name: to.Ptr("SampleEcmpRoutingRule"),
	// 		Type: to.Ptr("Microsoft.Network/networkManagers/routingConfigurations/ruleCollections/rules"),
	// 		ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/routingConfigurations/myTestRoutingConfig/ruleCollections/testRuleCollection/rules/SampleEcmpRoutingRule"),
	// 		Properties: &armnetwork.RoutingRulePropertiesFormat{
	// 			Description: to.Ptr("This is a sample ECMP routing rule with multiple next hop IP addresses"),
	// 			Destination: &armnetwork.RoutingRuleRouteDestination{
	// 				Type: to.Ptr(armnetwork.RoutingRuleDestinationTypeAddressPrefix),
	// 				DestinationAddress: to.Ptr("10.0.0.0/16"),
	// 			},
	// 			NextHop: &armnetwork.RoutingRuleNextHop{
	// 				NextHopType: to.Ptr(armnetwork.RoutingRuleNextHopTypeVirtualAppliance),
	// 				NextHopAddress: to.Ptr("10.1.0.4,10.1.0.5,10.1.0.6"),
	// 			},
	// 			ProvisioningState: to.Ptr(armnetwork.ProvisioningStateSucceeded),
	// 			ResourceGUID: to.Ptr("00000000-0000-0000-0000-000000000000"),
	// 		},
	// 		SystemData: &armnetwork.SystemData{
	// 			CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-11T18:52:27Z"); return t}()),
	// 			CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef5"),
	// 			CreatedByType: to.Ptr(armnetwork.CreatedByTypeUser),
	// 			LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-11T18:52:27Z"); return t}()),
	// 			LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef5"),
	// 			LastModifiedByType: to.Ptr(armnetwork.CreatedByTypeUser),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2025-07-01/NetworkManagerRoutingRuleDelete.json
func ExampleRoutingRulesClient_BeginDelete() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armnetwork.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewRoutingRulesClient().BeginDelete(ctx, "rg1", "testNetworkManager", "myTestRoutingConfig", "testRuleCollection", "sampleRule", &armnetwork.RoutingRulesClientBeginDeleteOptions{
		Force: to.Ptr(false)})
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to poll the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res = armnetwork.RoutingRulesClientDeleteResponse{
	// }
}

// Generated from example definition: 2025-07-01/NetworkManagerRoutingRuleGet.json
func ExampleRoutingRulesClient_Get() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armnetwork.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewRoutingRulesClient().Get(ctx, "rg1", "testNetworkManager", "myTestSecurityConfig", "testRuleCollection", "SampleRoutingRule", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res = armnetwork.RoutingRulesClientGetResponse{
	// 	RoutingRule: armnetwork.RoutingRule{
	// 		Name: to.Ptr("SampleRoutingRule"),
	// 		Type: to.Ptr("Microsoft.Network/networkManagers/routingConfigurations/ruleCollections/rules"),
	// 		ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/routingConfigurations/myTestSecurityConfig/ruleCollections/testRuleCollection/rules/SampleRoutingRule"),
	// 		Properties: &armnetwork.RoutingRulePropertiesFormat{
	// 			Description: to.Ptr("This is a routing rule"),
	// 			Destination: &armnetwork.RoutingRuleRouteDestination{
	// 				Type: to.Ptr(armnetwork.RoutingRuleDestinationTypeAddressPrefix),
	// 				DestinationAddress: to.Ptr("10.0.0.0/16"),
	// 			},
	// 			NextHop: &armnetwork.RoutingRuleNextHop{
	// 				NextHopAddress: to.Ptr(""),
	// 				NextHopType: to.Ptr(armnetwork.RoutingRuleNextHopTypeVirtualNetworkGateway),
	// 			},
	// 			ProvisioningState: to.Ptr(armnetwork.ProvisioningStateSucceeded),
	// 			ResourceGUID: to.Ptr("00000000-0000-0000-0000-000000000000"),
	// 		},
	// 		SystemData: &armnetwork.SystemData{
	// 			CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-11T18:52:27Z"); return t}()),
	// 			CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef5"),
	// 			CreatedByType: to.Ptr(armnetwork.CreatedByTypeUser),
	// 			LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-11T18:52:27Z"); return t}()),
	// 			LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef5"),
	// 			LastModifiedByType: to.Ptr(armnetwork.CreatedByTypeUser),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2025-07-01/NetworkManagerRoutingRuleList.json
func ExampleRoutingRulesClient_NewListPager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armnetwork.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewRoutingRulesClient().NewListPager("rg1", "testNetworkManager", "myTestRoutingConfig", "testRuleCollection", nil)
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range page.Value {
			// You could use page here. We use blank identifier for just demo purposes.
			_ = v
		}
		// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
		// page = armnetwork.RoutingRulesClientListResponse{
		// 	RoutingRuleListResult: armnetwork.RoutingRuleListResult{
		// 		NextLink: to.Ptr("https://management.azure.com/subscriptions/22222222-2222-2222-2222-222222222222/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkManagers/routingConfigurations/myTestRoutingConfig/ruleCollections/testRuleCollection/rules?api-version=2025-07-01&$skipToken=10"),
		// 		Value: []*armnetwork.RoutingRule{
		// 			{
		// 				Name: to.Ptr("SampleRoutingRule"),
		// 				Type: to.Ptr("Microsoft.Network/networkManagers/routingConfigurations/ruleCollections/rules"),
		// 				ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkmanagers/testNetworkManager/routingConfigurations/myTestRoutingConfig/ruleCollections/testRuleCollection/rules/SampleAdminRule"),
		// 				Properties: &armnetwork.RoutingRulePropertiesFormat{
		// 					Description: to.Ptr("This is Sample Admin Rule"),
		// 					Destination: &armnetwork.RoutingRuleRouteDestination{
		// 						Type: to.Ptr(armnetwork.RoutingRuleDestinationTypeAddressPrefix),
		// 						DestinationAddress: to.Ptr("10.0.0.0/16"),
		// 					},
		// 					NextHop: &armnetwork.RoutingRuleNextHop{
		// 						NextHopAddress: to.Ptr(""),
		// 						NextHopType: to.Ptr(armnetwork.RoutingRuleNextHopTypeVirtualNetworkGateway),
		// 					},
		// 					ProvisioningState: to.Ptr(armnetwork.ProvisioningStateSucceeded),
		// 					ResourceGUID: to.Ptr("00000000-0000-0000-0000-000000000000"),
		// 				},
		// 				SystemData: &armnetwork.SystemData{
		// 					CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-11T18:52:27Z"); return t}()),
		// 					CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef5"),
		// 					CreatedByType: to.Ptr(armnetwork.CreatedByTypeUser),
		// 					LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-11T18:52:27Z"); return t}()),
		// 					LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef5"),
		// 					LastModifiedByType: to.Ptr(armnetwork.CreatedByTypeUser),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}
