@@ -15,7 +15,33 @@ type InstanceConfigInterface struct {
1515 VPCID * int `json:"vpc_id"`
1616 SubnetID * int `json:"subnet_id"`
1717 IPv4 * VPCIPv4 `json:"ipv4"`
18- IPRanges []string `json:"ip_ranges"`
18+
19+ // NOTE: IPv6 interfaces may not currently be available to all users.
20+ IPv6 * InstanceConfigInterfaceIPv6 `json:"ipv6"`
21+
22+ IPRanges []string `json:"ip_ranges"`
23+ }
24+
25+ // InstanceConfigInterfaceIPv6 represents the IPv6 configuration of a Linode interface.
26+ // NOTE: IPv6 interfaces may not currently be available to all users.
27+ type InstanceConfigInterfaceIPv6 struct {
28+ SLAAC []InstanceConfigInterfaceIPv6SLAAC `json:"slaac"`
29+ Ranges []InstanceConfigInterfaceIPv6Range `json:"ranges"`
30+ IsPublic bool `json:"is_public"`
31+ }
32+
33+ // InstanceConfigInterfaceIPv6SLAAC represents a single IPv6 SLAAC under
34+ // a Linode interface.
35+ // NOTE: IPv6 interfaces may not currently be available to all users.
36+ type InstanceConfigInterfaceIPv6SLAAC struct {
37+ Range string `json:"range"`
38+ Address string `json:"address"`
39+ }
40+
41+ // InstanceConfigInterfaceIPv6Range represents a single IPv6 range under a Linode interface.
42+ // NOTE: IPv6 interfaces may not currently be available to all users.
43+ type InstanceConfigInterfaceIPv6Range struct {
44+ Range string `json:"range"`
1945}
2046
2147type VPCIPv4 struct {
@@ -30,15 +56,69 @@ type InstanceConfigInterfaceCreateOptions struct {
3056 Primary bool `json:"primary,omitempty"`
3157 SubnetID * int `json:"subnet_id,omitempty"`
3258 IPv4 * VPCIPv4 `json:"ipv4,omitempty"`
33- IPRanges []string `json:"ip_ranges,omitempty"`
59+
60+ // NOTE: IPv6 interfaces may not currently be available to all users.
61+ IPv6 * InstanceConfigInterfaceCreateOptionsIPv6 `json:"ipv6,omitempty"`
62+
63+ IPRanges []string `json:"ip_ranges,omitempty"`
64+ }
65+
66+ // InstanceConfigInterfaceCreateOptionsIPv6 represents the IPv6 configuration of a Linode interface
67+ // specified during creation.
68+ // NOTE: IPv6 interfaces may not currently be available to all users.
69+ type InstanceConfigInterfaceCreateOptionsIPv6 struct {
70+ SLAAC []InstanceConfigInterfaceCreateOptionsIPv6SLAAC `json:"slaac,omitempty"`
71+ Ranges []InstanceConfigInterfaceCreateOptionsIPv6Range `json:"ranges,omitempty"`
72+ IsPublic * bool `json:"is_public,omitempty"`
73+ }
74+
75+ // InstanceConfigInterfaceCreateOptionsIPv6SLAAC represents a single IPv6 SLAAC of a Linode interface
76+ // specified during creation.
77+ // NOTE: IPv6 interfaces may not currently be available to all users.
78+ type InstanceConfigInterfaceCreateOptionsIPv6SLAAC struct {
79+ Range string `json:"range"`
80+ }
81+
82+ // InstanceConfigInterfaceCreateOptionsIPv6Range represents a single IPv6 ranges of a Linode interface
83+ // specified during creation.
84+ // NOTE: IPv6 interfaces may not currently be available to all users.
85+ type InstanceConfigInterfaceCreateOptionsIPv6Range struct {
86+ Range * string `json:"range,omitempty"`
3487}
3588
3689type InstanceConfigInterfaceUpdateOptions struct {
37- Primary bool `json:"primary,omitempty"`
38- IPv4 * VPCIPv4 `json:"ipv4,omitempty"`
90+ Primary bool `json:"primary,omitempty"`
91+ IPv4 * VPCIPv4 `json:"ipv4,omitempty"`
92+
93+ // NOTE: IPv6 interfaces may not currently be available to all users.
94+ IPv6 * InstanceConfigInterfaceUpdateOptionsIPv6 `json:"ipv6,omitempty"`
95+
3996 IPRanges * []string `json:"ip_ranges,omitempty"`
4097}
4198
99+ // InstanceConfigInterfaceUpdateOptionsIPv6 represents the IPv6 configuration of a Linode interface
100+ // specified during updates.
101+ // NOTE: IPv6 interfaces may not currently be available to all users.
102+ type InstanceConfigInterfaceUpdateOptionsIPv6 struct {
103+ SLAAC * []InstanceConfigInterfaceUpdateOptionsIPv6SLAAC `json:"slaac,omitempty"`
104+ Ranges * []InstanceConfigInterfaceUpdateOptionsIPv6Range `json:"ranges,omitempty"`
105+ IsPublic * bool `json:"is_public,omitempty"`
106+ }
107+
108+ // InstanceConfigInterfaceUpdateOptionsIPv6SLAAC represents a single IPv6 SLAAC of a Linode interface
109+ // specified during updates.
110+ // NOTE: IPv6 interfaces may not currently be available to all users.
111+ type InstanceConfigInterfaceUpdateOptionsIPv6SLAAC struct {
112+ Range * string `json:"range,omitempty"`
113+ }
114+
115+ // InstanceConfigInterfaceUpdateOptionsIPv6Range represents a single IPv6 ranges of a Linode interface
116+ // specified during updates.
117+ // NOTE: IPv6 interfaces may not currently be available to all users.
118+ type InstanceConfigInterfaceUpdateOptionsIPv6Range struct {
119+ Range * string `json:"range,omitempty"`
120+ }
121+
42122type InstanceConfigInterfacesReorderOptions struct {
43123 IDs []int `json:"ids"`
44124}
@@ -66,13 +146,37 @@ func (i InstanceConfigInterface) GetCreateOptions() InstanceConfigInterfaceCreat
66146 opts .IPRanges = i .IPRanges
67147 }
68148
69- if i .Purpose == InterfacePurposeVPC && i . IPv4 != nil {
149+ if i .IPv4 != nil {
70150 opts .IPv4 = & VPCIPv4 {
71151 VPC : i .IPv4 .VPC ,
72152 NAT1To1 : i .IPv4 .NAT1To1 ,
73153 }
74154 }
75155
156+ if i .IPv6 != nil {
157+ ipv6 := * i .IPv6
158+
159+ opts .IPv6 = & InstanceConfigInterfaceCreateOptionsIPv6 {
160+ SLAAC : mapSlice (
161+ ipv6 .SLAAC ,
162+ func (i InstanceConfigInterfaceIPv6SLAAC ) InstanceConfigInterfaceCreateOptionsIPv6SLAAC {
163+ return InstanceConfigInterfaceCreateOptionsIPv6SLAAC {
164+ Range : i .Range ,
165+ }
166+ },
167+ ),
168+ Ranges : mapSlice (
169+ ipv6 .Ranges ,
170+ func (i InstanceConfigInterfaceIPv6Range ) InstanceConfigInterfaceCreateOptionsIPv6Range {
171+ return InstanceConfigInterfaceCreateOptionsIPv6Range {
172+ Range : copyValue (& i .Range ),
173+ }
174+ },
175+ ),
176+ IsPublic : copyValue (& ipv6 .IsPublic ),
177+ }
178+ }
179+
76180 opts .IPAMAddress = i .IPAMAddress
77181
78182 return opts
@@ -83,10 +187,40 @@ func (i InstanceConfigInterface) GetUpdateOptions() InstanceConfigInterfaceUpdat
83187 Primary : i .Primary ,
84188 }
85189
86- if i .Purpose == InterfacePurposeVPC && i .IPv4 != nil {
87- opts .IPv4 = & VPCIPv4 {
88- VPC : i .IPv4 .VPC ,
89- NAT1To1 : i .IPv4 .NAT1To1 ,
190+ if i .Purpose == InterfacePurposeVPC {
191+ if i .IPv4 != nil {
192+ opts .IPv4 = & VPCIPv4 {
193+ VPC : i .IPv4 .VPC ,
194+ NAT1To1 : i .IPv4 .NAT1To1 ,
195+ }
196+ }
197+
198+ if i .IPv6 != nil {
199+ ipv6 := * i .IPv6
200+
201+ newSLAAC := mapSlice (
202+ ipv6 .SLAAC ,
203+ func (i InstanceConfigInterfaceIPv6SLAAC ) InstanceConfigInterfaceUpdateOptionsIPv6SLAAC {
204+ return InstanceConfigInterfaceUpdateOptionsIPv6SLAAC {
205+ Range : copyValue (& i .Range ),
206+ }
207+ },
208+ )
209+
210+ newRanges := mapSlice (
211+ ipv6 .Ranges ,
212+ func (i InstanceConfigInterfaceIPv6Range ) InstanceConfigInterfaceUpdateOptionsIPv6Range {
213+ return InstanceConfigInterfaceUpdateOptionsIPv6Range {
214+ Range : copyValue (& i .Range ),
215+ }
216+ },
217+ )
218+
219+ opts .IPv6 = & InstanceConfigInterfaceUpdateOptionsIPv6 {
220+ SLAAC : & newSLAAC ,
221+ Ranges : & newRanges ,
222+ IsPublic : copyValue (& ipv6 .IsPublic ),
223+ }
90224 }
91225 }
92226
0 commit comments