@@ -31,6 +31,12 @@ func dataSourceTencentRedisZoneConfig() *schema.Resource {
3131 Optional : true ,
3232 Description : "Name of a region. If this value is not set, the current region getting from provider's configuration will be used." ,
3333 },
34+ "type_id" : {
35+ Type : schema .TypeInt ,
36+ Optional : true ,
37+ ValidateFunc : validateIntegerMin (2 ),
38+ Description : "Instance type id." ,
39+ },
3440 "result_output_file" : {
3541 Type : schema .TypeString ,
3642 Optional : true ,
@@ -48,9 +54,15 @@ func dataSourceTencentRedisZoneConfig() *schema.Resource {
4854 Computed : true ,
4955 Description : "ID of available zone." ,
5056 },
57+ "type_id" : {
58+ Type : schema .TypeInt ,
59+ Computed : true ,
60+ Description : "Instance type. Which redis type supports in this zone." ,
61+ },
5162 "type" : {
5263 Type : schema .TypeString ,
5364 Computed : true ,
65+ Deprecated : "It has been deprecated from version 1.33.1. Please use 'type_id' instead." ,
5466 Description : "Instance type. Available values: master_slave_redis, master_slave_ckv, cluster_ckv, cluster_redis and standalone_redis." ,
5567 },
5668 "version" : {
@@ -64,6 +76,18 @@ func dataSourceTencentRedisZoneConfig() *schema.Resource {
6476 Computed : true ,
6577 Description : "The memory volume of an available instance(in MB)." ,
6678 },
79+ "redis_shard_nums" : {
80+ Type : schema .TypeList ,
81+ Computed : true ,
82+ Elem : & schema.Schema {Type : schema .TypeInt },
83+ Description : "The support numbers of instance shard." ,
84+ },
85+ "redis_replicas_nums" : {
86+ Type : schema .TypeList ,
87+ Computed : true ,
88+ Elem : & schema.Schema {Type : schema .TypeInt },
89+ Description : "The support numbers of instance copies." ,
90+ },
6791 },
6892 },
6993 },
@@ -86,6 +110,8 @@ func dataSourceTencentRedisZoneConfigRead(d *schema.ResourceData, meta interface
86110 log .Printf ("[INFO]%s region is not set,so we use [%s] from env\n " , logId , region )
87111 }
88112
113+ typeId := int64 (d .Get ("type_id" ).(int ))
114+
89115 sellConfigures , err := service .DescribeRedisZoneConfig (ctx )
90116 if err != nil {
91117 return fmt .Errorf ("api[DescribeRedisZoneConfig]fail, return %s" , err .Error ())
@@ -110,18 +136,19 @@ func dataSourceTencentRedisZoneConfigRead(d *schema.ResourceData, meta interface
110136 if * products .PayMode != "0" {
111137 continue
112138 }
113- //this products sale out.
114- if * products .Saleout {
115- continue
116- }
117- //not support this type now .
118- if REDIS_NAMES [* products .Type ] == "" {
139+
140+ if typeId != 0 && typeId != * products .Type {
119141 continue
120142 }
121143
122144 zoneConfigures := map [string ]interface {}{}
123145 zoneConfigures ["zone" ] = zoneName
124146 zoneConfigures ["version" ] = * products .Version
147+ zoneConfigures ["type_id" ] = products .Type
148+ //this products sale out.
149+ if * products .Saleout {
150+ continue
151+ }
125152
126153 memSizes := make ([]int64 , 0 , len (products .TotalSize ))
127154
@@ -136,6 +163,27 @@ func dataSourceTencentRedisZoneConfigRead(d *schema.ResourceData, meta interface
136163 zoneConfigures ["mem_sizes" ] = memSizes
137164 zoneConfigures ["type" ] = REDIS_NAMES [* products .Type ]
138165
166+ var redisShardNums []int64
167+ var redisReplicasNums []int64
168+
169+ for _ , v := range products .ShardNum {
170+ int64Value , err := strconv .ParseInt (* v , 10 , 64 )
171+ if err != nil {
172+ return fmt .Errorf ("api[DescribeRedisZoneConfig]return error `redis_shard_nums`,%s" , err .Error ())
173+ }
174+ redisShardNums = append (redisShardNums , int64Value )
175+ }
176+ zoneConfigures ["redis_shard_nums" ] = redisShardNums
177+
178+ for _ , v := range products .ReplicaNum {
179+ int64Value , err := strconv .ParseInt (* v , 10 , 64 )
180+ if err != nil {
181+ return fmt .Errorf ("api[DescribeRedisZoneConfig]return error `redis_replicas_nums`,%s" , err .Error ())
182+ }
183+ redisReplicasNums = append (redisReplicasNums , int64Value )
184+ }
185+ zoneConfigures ["redis_replicas_nums" ] = redisReplicasNums
186+
139187 allZonesConfigs = append (allZonesConfigs , zoneConfigures )
140188 }
141189 }
@@ -144,7 +192,12 @@ func dataSourceTencentRedisZoneConfigRead(d *schema.ResourceData, meta interface
144192 log .Printf ("[CRITAL]%s provider set redis zoneConfigs fail, reason:%s\n " , logId , err .Error ())
145193 return err
146194 }
147- d .SetId ("redis_zoneconfig" + region )
195+
196+ id := "redis_zoneconfig" + region
197+ if typeId != 0 {
198+ id += fmt .Sprintf ("%d" , typeId )
199+ }
200+ d .SetId (id )
148201
149202 if output , ok := d .GetOk ("result_output_file" ); ok && output .(string ) != "" {
150203
0 commit comments