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

     1  /*
     2  Package networks contains functionality for working with Neutron network
     3  resources. A network is an isolated virtual layer-2 broadcast domain that is
     4  typically reserved for the tenant who created it (unless you configure the
     5  network to be shared). Tenants can create multiple networks until the
     6  thresholds per-tenant quota is reached.
     7  
     8  In the v2.0 Networking API, the network is the main entity. Ports and subnets
     9  are always associated with a network.
    10  
    11  Example to List Networks
    12  
    13  	listOpts := networks.ListOpts{
    14  		TenantID: "a99e9b4e620e4db09a2dfb6e42a01e66",
    15  	}
    16  
    17  	allPages, err := networks.List(networkClient, listOpts).AllPages()
    18  	if err != nil {
    19  		panic(err)
    20  	}
    21  
    22  	allNetworks, err := networks.ExtractNetworks(allPages)
    23  	if err != nil {
    24  		panic(err)
    25  	}
    26  
    27  	for _, network := range allNetworks {
    28  		fmt.Printf("%+v", network)
    29  	}
    30  
    31  Example to Create a Network
    32  
    33  	iTrue := true
    34  	createOpts := networks.CreateOpts{
    35  		Name:         "network_1",
    36  		AdminStateUp: &iTrue,
    37  	}
    38  
    39  	network, err := networks.Create(networkClient, createOpts).Extract()
    40  	if err != nil {
    41  		panic(err)
    42  	}
    43  
    44  Example to Update a Network
    45  
    46  	networkID := "484cda0e-106f-4f4b-bb3f-d413710bbe78"
    47  
    48  	updateOpts := networks.UpdateOpts{
    49  		Name: "new_name",
    50  	}
    51  
    52  	network, err := networks.Update(networkClient, networkID, updateOpts).Extract()
    53  	if err != nil {
    54  		panic(err)
    55  	}
    56  
    57  Example to Delete a Network
    58  
    59  	networkID := "484cda0e-106f-4f4b-bb3f-d413710bbe78"
    60  	err := networks.Delete(networkClient, networkID).ExtractErr()
    61  	if err != nil {
    62  		panic(err)
    63  	}
    64  */
    65  package networks