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

     1  /*
     2  Package vpcs enables management and retrieval of Vpcs
     3  VPC service.
     4  
     5  Example to List Vpcs
     6  
     7  	listOpts := vpcs.ListOpts{}
     8  	allVpcs, err := vpcs.List(vpcClient, listOpts)
     9  	if err != nil {
    10  		panic(err)
    11  	}
    12  
    13  	for _, vpc := range allVpcs {
    14  		fmt.Printf("%+v\n", vpc)
    15  	}
    16  
    17  Example to Create a Vpc
    18  
    19  	createOpts := vpcs.CreateOpts{
    20  		Name:         "vpc_1",
    21  		CIDR:         "192.168.0.0/24"
    22  
    23  	}
    24  
    25  	vpc, err := vpcs.Create(vpcClient, createOpts).Extract()
    26  	if err != nil {
    27  		panic(err)
    28  	}
    29  
    30  Example to Update a Vpc
    31  
    32  	vpcID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
    33  
    34  	updateOpts := vpcs.UpdateOpts{
    35  		Name:         "vpc_2",
    36  		CIDR:         "192.168.0.0/23"
    37  	}
    38  
    39  	vpc, err := vpcs.Update(vpcClient, vpcID, updateOpts).Extract()
    40  	if err != nil {
    41  		panic(err)
    42  	}
    43  
    44  Example to Delete a Vpc
    45  
    46  	vpcID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
    47  	err := vpcs.Delete(vpcClient, vpcID).ExtractErr()
    48  	if err != nil {
    49  		panic(err)
    50  	}
    51  */
    52  package vpcs