github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/rds/v3/flavors/ListFlavors.go (about) 1 package flavors 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 6 ) 7 8 type ListOpts struct { 9 DatabaseName string 10 // Specifies the database version. 11 VersionName string `q:"version_name"` 12 // Specifies the specification code. 13 // NOTICE 14 // Only DB instances running Microsoft SQL Server 2017 EE support the creation of read replicas. 15 // Microsoft SQL Server 2017 EE does not support the creation of single DB instances. 16 // The format of the specification code is: {spec code}{instance mode}. 17 // spec code can be obtained from Table 8-10. 18 // instance mode can be any of the following: 19 // For single DB instances, the value is null. Example spe_code: rds.mysql.s1.xlarge 20 // For primary/standby DB instances, the value is .ha. Example spe_code: rds.mysql.s1.xlarge.ha 21 // For read replicas, the value is .rr. Example spe_code: rds.mysql.s1.xlarge.rr 22 SpecCode string `q:"spec_code"` 23 } 24 25 func ListFlavors(client *golangsdk.ServiceClient, opts ListOpts) ([]Flavor, error) { 26 // GET https://{Endpoint}/v3/{project_id}/flavors/{database_name} 27 url, err := golangsdk.NewURLBuilder().WithEndpoints("flavors", opts.DatabaseName).WithQueryParams(&opts).Build() 28 if err != nil { 29 return nil, err 30 } 31 32 raw, err := client.Get(client.ServiceURL(url.String()), nil, nil) 33 if err != nil { 34 return nil, err 35 } 36 37 var res []Flavor 38 err = extract.IntoSlicePtr(raw.Body, &res, "flavors") 39 return res, err 40 } 41 42 type Flavor struct { 43 // Indicates the CPU size. For example, the value 1 indicates 1 vCPU. 44 VCPUs string `json:"vcpus"` 45 // Indicates the memory size in GB. 46 RAM int `json:"ram"` 47 // Indicates the specification ID, which is unique. 48 Id string `json:"id"` 49 // Indicates the resource specification code. Use rds.mysql.m1.xlarge.rr as an example. 50 // rds: indicates the RDS product. 51 // mysql: indicates the DB engine. 52 // m1.xlarge: indicates the high memory performance specifications. 53 // rr: indicates the read replica (.ha indicates primary/standby DB instances). 54 SpecCode string `json:"spec_code"` 55 // Indicates the database version. 56 // Example value for MySQL: ["5.6","5.7","8.0"] 57 VersionName []string `json:"version_name"` 58 // Indicates the DB instance type. Its value can be any of the following: 59 // ha: indicates primary/standby DB instances. 60 // replica: indicates read replicas. 61 // single: indicates single DB instances. 62 InstanceMode string `json:"instance_mode"` 63 // Indicates the specification status in an AZ. Its value can be any of the following: 64 // normal: indicates that the specifications in the AZ are available. 65 // unsupported: indicates that the specifications are not supported by the AZ. 66 // sellout: indicates that the specifications in the AZ are sold out. 67 AzStatus map[string]string `json:"az_status"` 68 // Indicates the description of the AZ to which the specifications belong. 69 AzDesc map[string]string `json:"az_desc"` 70 // Indicates the performance specifications. Its value can be any of the following: 71 // normal: general-enhanced 72 GroupType string `json:"group_type"` 73 }