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

     1  /*
     2  package floatingips enables management and retrieval of Floating IPs from the
     3  OpenStack Networking service.
     4  
     5  Example to List Floating IPs
     6  
     7  	listOpts := floatingips.ListOpts{
     8  		FloatingNetworkID: "a6917946-38ab-4ffd-a55a-26c0980ce5ee",
     9  	}
    10  
    11  	allPages, err := floatingips.List(networkClient, listOpts).AllPages()
    12  	if err != nil {
    13  		panic(err)
    14  	}
    15  
    16  	allFIPs, err := floatingips.ExtractFloatingIPs(allPages)
    17  	if err != nil {
    18  		panic(err)
    19  	}
    20  
    21  	for _, fip := range allFIPs {
    22  		fmt.Printf("%+v\n", fip)
    23  	}
    24  
    25  Example to Create a Floating IP
    26  
    27  	createOpts := floatingips.CreateOpts{
    28  		FloatingNetworkID: "a6917946-38ab-4ffd-a55a-26c0980ce5ee",
    29  	}
    30  
    31  	fip, err := floatingips.Create(networkingClient, createOpts).Extract()
    32  	if err != nil {
    33  		panic(err)
    34  	}
    35  
    36  Example to Update a Floating IP
    37  
    38  	fipID := "2f245a7b-796b-4f26-9cf9-9e82d248fda7"
    39  	portID := "76d0a61b-b8e5-490c-9892-4cf674f2bec8"
    40  
    41  	updateOpts := floatingips.UpdateOpts{
    42  		PortID: &portID,
    43  	}
    44  
    45  	fip, err := floatingips.Update(networkingClient, fipID, updateOpts).Extract()
    46  	if err != nil {
    47  		panic(err)
    48  	}
    49  
    50  Example to Disassociate a Floating IP with a Port
    51  
    52  	fipID := "2f245a7b-796b-4f26-9cf9-9e82d248fda7"
    53  
    54  	updateOpts := floatingips.UpdateOpts{
    55  		PortID: nil,
    56  	}
    57  
    58  	fip, err := floatingips.Update(networkingClient, fipID, updateOpts).Extract()
    59  	if err != nil {
    60  		panic(err)
    61  	}
    62  
    63  Example to Delete a Floating IP
    64  
    65  	fipID := "2f245a7b-796b-4f26-9cf9-9e82d248fda7"
    66  	err := floatingips.Delete(networkClient, fipID).ExtractErr()
    67  	if err != nil {
    68  		panic(err)
    69  	}
    70  */
    71  package floatingips