github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/ecs/v1/servergroups/doc.go (about) 1 /* 2 Package servergroups provides the ability to manage server groups. 3 4 Example to List Server Groups 5 6 allpages, err := servergroups.List(ecsClient).AllPages() 7 if err != nil { 8 panic(err) 9 } 10 11 allServerGroups, err := servergroups.ExtractServerGroups(allPages) 12 if err != nil { 13 panic(err) 14 } 15 16 for _, sg := range allServerGroups { 17 fmt.Printf("%#v\n", sg) 18 } 19 20 Example to Create a Server Group 21 22 createOpts := servergroups.CreateOpts{ 23 Name: "my_sg", 24 Policies: []string{"anti-affinity"}, 25 } 26 27 sg, err := servergroups.Create(ecsClient, createOpts).Extract() 28 if err != nil { 29 panic(err) 30 } 31 32 Example to Delete a Server Group 33 34 sgID := "7a6f29ad-e34d-4368-951a-58a08f11cfb7" 35 err := servergroups.Delete(ecsClient, sgID).ExtractErr() 36 if err != nil { 37 panic(err) 38 } 39 */ 40 package servergroups