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

     1  /*
     2  Package Subnets enables management and retrieval of Subnets
     3  
     4  Example to List Vpcs
     5  
     6  	listOpts := subnets.ListOpts{}
     7  	allSubnets, err := subnets.List(subnetClient, listOpts)
     8  	if err != nil {
     9  		panic(err)
    10  	}
    11  
    12  	for _, subnet := range allSubnets {
    13  		fmt.Printf("%+v\n", subnet)
    14  	}
    15  
    16  Example to Create a Vpc
    17  
    18  	createOpts := subnets.CreateOpts{
    19  		Name:          "test_subnets",
    20  		CIDR:          "192.168.0.0/16"
    21  		GatewayIP:	   "192.168.0.1"
    22  		PRIMARY_DNS:   "8.8.8.8"
    23  		SECONDARY_DNS: "8.8.4.4"
    24  		AvailabilityZone:"eu-de-02"
    25  		VPC_ID:"3b9740a0-b44d-48f0-84ee-42eb166e54f7"
    26  
    27  	}
    28  	vpc, err := subnets.Create(subnetClient, createOpts).Extract()
    29  
    30  	if err != nil {
    31  		panic(err)
    32  	}
    33  
    34  Example to Update a Vpc
    35  
    36  	subnetID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
    37  
    38  	updateOpts := subnets.UpdateOpts{
    39  		Name:          "testsubnet",
    40  	}
    41  
    42  	subnet, err := subnets.Update(subnetClient, subnetID, updateOpts).Extract()
    43  	if err != nil {
    44  		panic(err)
    45  	}
    46  
    47  Example to Delete a Vpc
    48  
    49  	subnetID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
    50  
    51  	err := subnets.Delete(subnetClient, subnetID).ExtractErr()
    52  
    53  	if err != nil {
    54  		panic(err)
    55  	}
    56  */
    57  package subnets