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

     1  /*
     2  Package services allows management and retrieval of VPN services in the
     3  OpenStack Networking Service.
     4  
     5  Example to List Services
     6  
     7  	listOpts := services.ListOpts{
     8  		TenantID: "966b3c7d36a24facaf20b7e458bf2192",
     9  	}
    10  
    11  	allPages, err := services.List(networkClient, listOpts).AllPages()
    12  	if err != nil {
    13  		panic(err)
    14  	}
    15  
    16  	allPolicies, err := services.ExtractServices(allPages)
    17  	if err != nil {
    18  		panic(err)
    19  	}
    20  
    21  	for _, service := range allServices {
    22  		fmt.Printf("%+v\n", service)
    23  	}
    24  
    25  Example to Create a Service
    26  
    27  	createOpts := services.CreateOpts{
    28  		Name:        "vpnservice1",
    29  		Description: "A service",
    30  		RouterID:	 "2512e759-e8d7-4eea-a0af-4a85927a2e59",
    31  		AdminStateUp: golangsdk.Enabled,
    32  	}
    33  
    34  	service, err := services.Create(networkClient, createOpts).Extract()
    35  	if err != nil {
    36  		panic(err)
    37  	}
    38  
    39  Example to Update a Service
    40  
    41  	serviceID := "38aee955-6283-4279-b091-8b9c828000ec"
    42  
    43  	updateOpts := services.UpdateOpts{
    44  		Description: "New Description",
    45  	}
    46  
    47  	service, err := services.Update(networkClient, serviceID, updateOpts).Extract()
    48  	if err != nil {
    49  		panic(err)
    50  	}
    51  
    52  Example to Delete a Service
    53  
    54  	serviceID := "38aee955-6283-4279-b091-8b9c828000ec"
    55  	err := services.Delete(networkClient, serviceID).ExtractErr()
    56  	if err != nil {
    57  		panic(err)
    58  	}
    59  
    60  Example to Show the details of a specific Service by ID
    61  
    62  	service, err := services.Get(client, "f2b08c1e-aa81-4668-8ae1-1401bcb0576c").Extract()
    63  	if err != nil {
    64  		panic(err)
    65  	}
    66  
    67  */
    68  package services