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

     1  /*
     2  Package subnetpools provides the ability to retrieve and manage subnetpools through the Neutron API.
     3  
     4  Example of Listing Subnetpools
     5  
     6  	listOpts := subnets.ListOpts{
     7  		IPVersion: 6,
     8  	}
     9  
    10  	allPages, err := subnetpools.List(networkClient, listOpts).AllPages()
    11  	if err != nil {
    12  		panic(err)
    13  	}
    14  
    15  	allSubnetpools, err := subnetpools.ExtractSubnetPools(allPages)
    16  	if err != nil {
    17  		panic(err)
    18  	}
    19  
    20  	for _, subnetpools := range allSubnetpools {
    21  		fmt.Printf("%+v\n", subnetpools)
    22  	}
    23  
    24  Example to Get a Subnetpool
    25  
    26  	subnetPoolID = "23d5d3f7-9dfa-4f73-b72b-8b0b0063ec55"
    27  	subnetPool, err := subnetpools.Get(networkClient, subnetPoolID).Extract()
    28  	if err != nil {
    29  		panic(err)
    30  	}
    31  
    32  Example to Create a new Subnetpool
    33  
    34  	subnetPoolName := "private_pool"
    35  	subnetPoolPrefixes := []string{
    36  		"10.0.0.0/8",
    37  		"172.16.0.0/12",
    38  		"192.168.0.0/16",
    39  	}
    40  	subnetPoolOpts := subnetpools.CreateOpts{
    41  		Name: subnetPoolName,
    42  		Prefixes: subnetPoolPrefixes,
    43  	}
    44  	subnetPool, err := subnetpools.Create(networkClient, subnetPoolOpts).Extract()
    45  	if err != nil {
    46  		panic(err)
    47  	}
    48  
    49  Example to Update a Subnetpool
    50  
    51  	subnetPoolID := "099546ca-788d-41e5-a76d-17d8cd282d3e"
    52  	updateOpts := networks.UpdateOpts{
    53  		Prefixes: []string{
    54  		  "fdf7:b13d:dead:beef::/64",
    55  	  },
    56  		MaxPrefixLen: 72,
    57  	}
    58  
    59  	subnetPool, err := subnetpools.Update(networkClient, subnetPoolID, updateOpts).Extract()
    60  	if err != nil {
    61  		panic(err)
    62  	}
    63  
    64  Example to Delete a Subnetpool
    65  
    66  	subnetPoolID := "23d5d3f7-9dfa-4f73-b72b-8b0b0063ec55"
    67  	err := subnetpools.Delete(networkClient, subnetPoolID).ExtractErr()
    68  	if err != nil {
    69  		panic(err)
    70  	}
    71  */
    72  package subnetpools