@@ -37,6 +37,10 @@ func DataSourceElbIpGroups() *schema.Resource {
3737 Type : schema .TypeString ,
3838 Optional : true ,
3939 },
40+ "enterprise_project_id" : {
41+ Type : schema .TypeString ,
42+ Optional : true ,
43+ },
4044 "ip_address" : {
4145 Type : schema .TypeString ,
4246 Optional : true ,
@@ -69,6 +73,10 @@ func ipgroupsSchema() *schema.Resource {
6973 Type : schema .TypeString ,
7074 Computed : true ,
7175 },
76+ "enterprise_project_id" : {
77+ Type : schema .TypeString ,
78+ Computed : true ,
79+ },
7280 "project_id" : {
7381 Type : schema .TypeString ,
7482 Computed : true ,
@@ -127,7 +135,7 @@ func dataSourceElbIpGroupsRead(_ context.Context, d *schema.ResourceData, meta i
127135 }
128136 listIpGroupsPath := listIpGroupsClient .Endpoint + listIpGroupsHttpUrl
129137 listIpGroupsPath = strings .ReplaceAll (listIpGroupsPath , "{project_id}" , listIpGroupsClient .ProjectID )
130- listIpGroupsQueryParams := buildListIpGroupsQueryParams (d )
138+ listIpGroupsQueryParams := buildListIpGroupsQueryParams (d , cfg . GetEnterpriseProjectID ( d ) )
131139 listIpGroupsPath += listIpGroupsQueryParams
132140 listIpGroupsResp , err := pagination .ListAllItems (
133141 listIpGroupsClient ,
@@ -162,7 +170,7 @@ func dataSourceElbIpGroupsRead(_ context.Context, d *schema.ResourceData, meta i
162170 return diag .FromErr (mErr .ErrorOrNil ())
163171}
164172
165- func buildListIpGroupsQueryParams (d * schema.ResourceData ) string {
173+ func buildListIpGroupsQueryParams (d * schema.ResourceData , enterpriseProjectId string ) string {
166174 res := ""
167175 if v , ok := d .GetOk ("ipgroup_id" ); ok {
168176 res = fmt .Sprintf ("%s&id=%v" , res , v )
@@ -176,6 +184,9 @@ func buildListIpGroupsQueryParams(d *schema.ResourceData) string {
176184 if v , ok := d .GetOk ("ip_address" ); ok {
177185 res = fmt .Sprintf ("%s&ip_list=%v" , res , v )
178186 }
187+ if enterpriseProjectId != "" {
188+ res = fmt .Sprintf ("%s&enterprise_project_id=%v" , res , enterpriseProjectId )
189+ }
179190 if res != "" {
180191 res = "?" + res [1 :]
181192 }
@@ -194,14 +205,15 @@ func flattenListIpGroupsBody(resp interface{}) []interface{} {
194205 rst := make ([]interface {}, 0 , len (curArray ))
195206 for _ , v := range curArray {
196207 rst = append (rst , map [string ]interface {}{
197- "id" : utils .PathSearch ("id" , v , nil ),
198- "name" : utils .PathSearch ("name" , v , nil ),
199- "description" : utils .PathSearch ("description" , v , nil ),
200- "project_id" : utils .PathSearch ("project_id" , v , nil ),
201- "listeners" : utils .PathSearch ("listeners" , v , nil ),
202- "ip_list" : utils .PathSearch ("ip_list" , v , nil ),
203- "created_at" : utils .PathSearch ("created_at" , v , nil ),
204- "updated_at" : utils .PathSearch ("updated_at" , v , nil ),
208+ "id" : utils .PathSearch ("id" , v , nil ),
209+ "name" : utils .PathSearch ("name" , v , nil ),
210+ "description" : utils .PathSearch ("description" , v , nil ),
211+ "enterprise_project_id" : utils .PathSearch ("enterprise_project_id" , v , nil ),
212+ "project_id" : utils .PathSearch ("project_id" , v , nil ),
213+ "listeners" : utils .PathSearch ("listeners" , v , nil ),
214+ "ip_list" : utils .PathSearch ("ip_list" , v , nil ),
215+ "created_at" : utils .PathSearch ("created_at" , v , nil ),
216+ "updated_at" : utils .PathSearch ("updated_at" , v , nil ),
205217 })
206218 }
207219 return rst
0 commit comments