github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/cce/v3/clusters/doc.go (about) 1 /* 2 Package Clusters enables management and retrieval of Clusters 3 CCE service. 4 5 Example to List Clusters 6 7 listOpts:=clusters.ListOpts{} 8 allClusters,err:=clusters.List(client,listOpts) 9 if err != nil { 10 panic(err) 11 } 12 13 for _, cluster := range allClusters { 14 fmt.Printf("%+v\n", cluster) 15 } 16 17 Example to Create a cluster 18 19 createOpts:=clusters.CreateOpts{Kind:"Cluster", 20 ApiVersion:"v3", 21 Metadata:clusters.CreateMetaData{Name:"test-cluster"}, 22 Spec:clusters.Spec{Type: "VirtualMachine", 23 Flavor: "cce.s1.small", 24 Version:"v1.7.3-r10", 25 HostNetwork:clusters.HostNetworkSpec{VpcId:"3b9740a0-b44d-48f0-84ee-42eb166e54f7", 26 SubnetId:"3e8e5957-649f-477b-9e5b-f1f75b21c045",}, 27 ContainerNetwork:clusters.ContainerNetworkSpec{Mode:"overlay_l2"}, 28 }, 29 } 30 cluster,err := clusters.Create(client,createOpts).Extract() 31 if err != nil { 32 panic(err) 33 } 34 35 Example to Update a cluster 36 37 updateOpts := clusters.UpdateOpts{Spec:clusters.UpdateSpec{Description:"test"}} 38 39 clusterID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c" 40 41 cluster,err := clusters.Update(client,clusterID,updateOpts).Extract() 42 if err != nil { 43 panic(err) 44 } 45 46 Example to Delete a cluster 47 48 clusterID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c" 49 50 err := clusters.Delete(client,clusterID).ExtractErr() 51 if err != nil { 52 panic(err) 53 } 54 */ 55 package clusters