@@ -74,6 +74,68 @@ func resourceCloudProjectGateway() *schema.Resource {
74
74
Type : schema .TypeString ,
75
75
Computed : true ,
76
76
},
77
+ "external_information" : {
78
+ Type : schema .TypeList ,
79
+ Computed : true ,
80
+ Description : "External information of the gateway" ,
81
+ Elem : & schema.Resource {
82
+ Schema : map [string ]* schema.Schema {
83
+ "network_id" : {
84
+ Type : schema .TypeString ,
85
+ Description : "External network ID of the gateway" ,
86
+ Computed : true ,
87
+ },
88
+ "ips" : {
89
+ Type : schema .TypeList ,
90
+ Description : "List of external ips of the gateway" ,
91
+ Computed : true ,
92
+ Elem : & schema.Resource {
93
+ Schema : map [string ]* schema.Schema {
94
+ "ip" : {
95
+ Type : schema .TypeString ,
96
+ Description : "External IP of the gateway" ,
97
+ Computed : true ,
98
+ },
99
+ "subnet_id" : {
100
+ Type : schema .TypeString ,
101
+ Description : "Subnet ID of the ip" ,
102
+ Computed : true ,
103
+ },
104
+ },
105
+ },
106
+ },
107
+ },
108
+ },
109
+ },
110
+ "interfaces" : {
111
+ Type : schema .TypeList ,
112
+ Computed : true ,
113
+ Description : "Interfaces list of the gateway" ,
114
+ Elem : & schema.Resource {
115
+ Schema : map [string ]* schema.Schema {
116
+ "id" : {
117
+ Type : schema .TypeString ,
118
+ Description : "ID of the interface" ,
119
+ Computed : true ,
120
+ },
121
+ "ip" : {
122
+ Type : schema .TypeString ,
123
+ Description : "IP of the interface" ,
124
+ Computed : true ,
125
+ },
126
+ "network_id" : {
127
+ Type : schema .TypeString ,
128
+ Description : "Network ID of the interface" ,
129
+ Computed : true ,
130
+ },
131
+ "subnet_id" : {
132
+ Type : schema .TypeString ,
133
+ Description : "Subnet ID of the interface" ,
134
+ Computed : true ,
135
+ },
136
+ },
137
+ },
138
+ },
77
139
},
78
140
}
79
141
}
@@ -163,7 +225,32 @@ func resourceCloudProjectGatewayRead(d *schema.ResourceData, meta interface{}) e
163
225
d .SetId (r .Id )
164
226
d .Set ("service_name" , serviceName )
165
227
166
- // TODO : add response fields "externalInformation" and "interfaces"
228
+ externalInfos := make ([]map [string ]interface {}, 0 )
229
+ if r .ExternalInformation != nil {
230
+ externalInfo := make (map [string ]interface {})
231
+ ips := make ([]map [string ]interface {}, 0 )
232
+ for _ , externalIp := range r .ExternalInformation .Ips {
233
+ ip := make (map [string ]interface {})
234
+ ip ["ip" ] = externalIp .Ip
235
+ ip ["subnet_id" ] = externalIp .SubnetId
236
+ ips = append (ips , ip )
237
+ }
238
+ externalInfo ["ips" ] = ips
239
+ externalInfo ["network_id" ] = r .ExternalInformation .NetworkId
240
+ externalInfos = append (externalInfos , externalInfo )
241
+ }
242
+ d .Set ("external_information" , externalInfos )
243
+
244
+ interfaces := make ([]map [string ]string , 0 )
245
+ for _ , responseInterface := range r .Interfaces {
246
+ itf := make (map [string ]string )
247
+ itf ["id" ] = responseInterface .Id
248
+ itf ["ip" ] = responseInterface .Ip
249
+ itf ["subnet_id" ] = responseInterface .SubnetId
250
+ itf ["network_id" ] = responseInterface .NetworkId
251
+ interfaces = append (interfaces , itf )
252
+ }
253
+ d .Set ("interfaces" , interfaces )
167
254
168
255
log .Printf ("[DEBUG] Read Public Cloud Gateway %+v" , r )
169
256
return nil
0 commit comments