github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/networking/v2/extensions/fwaas/routerinsertion/doc.go (about)

     1  /*
     2  Package routerinsertion implements the fwaasrouterinsertion Firewall extension.
     3  It is used to manage the router information of a firewall.
     4  
     5  Example to List Firewalls with Router Information
     6  
     7  	type FirewallsWithRouters struct {
     8  		firewalls.Firewall
     9  		routerinsertion.FirewallExt
    10  	}
    11  
    12  	var allFirewalls []FirewallsWithRouters
    13  
    14  	allPages, err := firewalls.List(networkClient, nil).AllPages()
    15  	if err != nil {
    16  		panic(err)
    17  	}
    18  
    19  	err = firewalls.ExtractFirewallsInto(allPages, &allFirewalls)
    20  	if err != nil {
    21  		panic(err)
    22  	}
    23  
    24  	for _, fw := range allFirewalls {
    25  		fmt.Printf("%+v\n", fw)
    26  	}
    27  
    28  Example to Create a Firewall with a Router
    29  
    30  	firewallCreateOpts := firewalls.CreateOpts{
    31  		Name:     "firewall_1",
    32  		PolicyID: "19ab8c87-4a32-4e6a-a74e-b77fffb89a0c",
    33  	}
    34  
    35  	createOpts := routerinsertion.CreateOptsExt{
    36  		CreateOptsBuilder: firewallCreateOpts,
    37  		RouterIDs: []string{
    38  			"8a3a0d6a-34b5-4a92-b65d-6375a4c1e9e8",
    39  		},
    40  	}
    41  
    42  	firewall, err := firewalls.Create(networkClient, createOpts).Extract()
    43  	if err != nil {
    44  		panic(err)
    45  	}
    46  
    47  Example to Update a Firewall with a Router
    48  
    49  	firewallID := "a6917946-38ab-4ffd-a55a-26c0980ce5ee"
    50  
    51  	firewallUpdateOpts := firewalls.UpdateOpts{
    52  		Description: "updated firewall",
    53  		PolicyID:    "19ab8c87-4a32-4e6a-a74e-b77fffb89a0c",
    54  	}
    55  
    56  	updateOpts := routerinsertion.UpdateOptsExt{
    57  		UpdateOptsBuilder: firewallUpdateOpts,
    58  		RouterIDs: []string{
    59  			"8a3a0d6a-34b5-4a92-b65d-6375a4c1e9e8",
    60  		},
    61  	}
    62  
    63  	firewall, err := firewalls.Update(networkClient, firewallID, updateOpts).Extract()
    64  	if err != nil {
    65  		panic(err)
    66  	}
    67  */
    68  package routerinsertion