vpc_router.go raw
1 // Copyright 2022-2025 The sacloud/iaas-api-go Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package naked
16
17 import (
18 "encoding/json"
19 "time"
20
21 "github.com/sacloud/iaas-api-go/types"
22 )
23
24 // VPCRouter VPCルータ
25 type VPCRouter struct {
26 ID types.ID `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
27 Class string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
28 Name string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
29 Description string `yaml:"description"`
30 Plan *AppliancePlan `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
31 Settings *VPCRouterSettings `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
32 SettingsHash string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
33 Remark *ApplianceRemark `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
34 Availability types.EAvailability `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
35 Instance *Instance `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
36 ServiceClass string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
37 CreatedAt *time.Time `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
38 Icon *Icon `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
39 Switch *Switch `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
40 Interfaces Interfaces `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
41 Tags types.Tags `yaml:"tags"`
42 }
43
44 // VPCRouterSettingsUpdate VPCルータ
45 type VPCRouterSettingsUpdate struct {
46 Settings *VPCRouterSettings `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
47 SettingsHash string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
48 }
49
50 // VPCRouterSettings VPCルータ 設定
51 type VPCRouterSettings struct {
52 Router *VPCRouterSetting `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
53 }
54
55 // VPCRouterSetting VPCルータ 設定
56 type VPCRouterSetting struct {
57 InternetConnection *VPCRouterInternetConnection `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
58 Interfaces VPCRouterInterfaces `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
59 VRID int `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
60 StaticNAT *VPCRouterStaticNAT `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
61 PortForwarding *VPCRouterPortForwarding `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
62 Firewall *VPCRouterFirewall `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
63 DHCPServer *VPCRouterDHCPServer `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
64 DHCPStaticMapping *VPCRouterDHCPStaticMappings `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
65 DNSForwarding *VPCRouterDNSForwarding `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
66 PPTPServer *VPCRouterPPTPServer `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
67 L2TPIPsecServer *VPCRouterL2TPIPsecServer `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
68 WireGuard *VPCRouterWireGuard `json:"WireGuardServer,omitempty" yaml:",omitempty" structs:",omitempty"`
69 RemoteAccessUsers *VPCRouterRemoteAccessUsers `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
70 SiteToSiteIPsecVPN *VPCRouterSiteToSiteIPsecVPN `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
71 StaticRoutes *VPCRouterStaticRoutes `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
72 SyslogHost string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
73 ScheduledMaintenance *VPCRouterScheduledMaintenance `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
74 MonitoringSuite *MonitoringSuiteString `json:",omitempty" yaml:"monitoring_suite_log,omitempty" structs:",omitempty"`
75 }
76
77 // VPCRouterInternetConnection インターフェース
78 type VPCRouterInternetConnection struct {
79 Enabled types.StringFlag `yaml:"enabled"`
80 }
81
82 // VPCRouterInterface インターフェース
83 type VPCRouterInterface struct {
84 IPAddress []string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
85 VirtualIPAddress string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
86 IPAliases []string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
87 NetworkMaskLen int `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
88 // Index 仮想フィールド、VPCルータなどでInterfaces(実体は[]*Interface)を扱う場合にUnmarshalJSONの中で設定される
89 //
90 // Findした際のAPIからの応答にも同名のフィールドが含まれるが無関係。
91 Index int `json:"-"`
92 }
93
94 // VPCRouterInterfaces Interface配列
95 //
96 // 配列中にnullが返ってくる(VPCルータなど)への対応のためのtype
97 type VPCRouterInterfaces []*VPCRouterInterface
98
99 // UnmarshalJSON 配列中にnullが返ってくる(VPCルータなど)への対応
100 func (i *VPCRouterInterfaces) UnmarshalJSON(b []byte) error {
101 type alias VPCRouterInterfaces
102 var a alias
103 if err := json.Unmarshal(b, &a); err != nil {
104 return err
105 }
106
107 var dest []*VPCRouterInterface
108 for i, v := range a {
109 if v != nil {
110 if v.Index == 0 {
111 v.Index = i
112 }
113 dest = append(dest, v)
114 }
115 }
116
117 *i = VPCRouterInterfaces(dest)
118 return nil
119 }
120
121 // MarshalJSON 配列中にnullが入る場合(VPCルータなど)への対応
122 func (i *VPCRouterInterfaces) MarshalJSON() ([]byte, error) {
123 max := 0
124 for _, iface := range *i {
125 if max < iface.Index {
126 max = iface.Index
127 }
128 }
129
130 var dest = make([]*VPCRouterInterface, max+1)
131 for _, iface := range *i {
132 dest[iface.Index] = iface
133 }
134
135 return json.Marshal(dest)
136 }
137
138 // MarshalJSON JSON
139 func (i *VPCRouterInterface) MarshalJSON() ([]byte, error) {
140 type alias struct {
141 IPAddress []string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
142 VirtualIPAddress string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
143 IPAliases []string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
144 NetworkMaskLen int `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
145 }
146
147 tmp := alias{
148 IPAddress: i.IPAddress,
149 VirtualIPAddress: i.VirtualIPAddress,
150 IPAliases: i.IPAliases,
151 NetworkMaskLen: i.NetworkMaskLen,
152 }
153 return json.Marshal(tmp)
154 }
155
156 // VPCRouterStaticNAT スタティックNAT
157 type VPCRouterStaticNAT struct {
158 Config []*VPCRouterStaticNATConfig `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
159 Enabled types.StringFlag `yaml:"enabled"`
160 }
161
162 // MarshalJSON Configが一つ以上ある場合にEnabledをtrueに設定する
163 func (f *VPCRouterStaticNAT) MarshalJSON() ([]byte, error) {
164 if f == nil || f.Config == nil {
165 return nil, nil
166 }
167 if len(f.Config) > 0 {
168 f.Enabled = types.StringTrue
169 }
170 type alias VPCRouterStaticNAT
171 a := alias(*f)
172 return json.Marshal(&a)
173 }
174
175 // VPCRouterStaticNATConfig スタティックNAT
176 type VPCRouterStaticNATConfig struct {
177 GlobalAddress string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
178 PrivateAddress string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
179 Description string `yaml:"description"`
180 }
181
182 // VPCRouterPortForwarding ポートフォワーディング設定
183 type VPCRouterPortForwarding struct {
184 Config []*VPCRouterPortForwardingConfig `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
185 Enabled types.StringFlag `yaml:"enabled"`
186 }
187
188 // MarshalJSON Configが一つ以上ある場合にEnabledをtrueに設定する
189 func (f *VPCRouterPortForwarding) MarshalJSON() ([]byte, error) {
190 if f == nil || f.Config == nil {
191 return nil, nil
192 }
193 if len(f.Config) > 0 {
194 f.Enabled = types.StringTrue
195 }
196 type alias VPCRouterPortForwarding
197 a := alias(*f)
198 return json.Marshal(&a)
199 }
200
201 // VPCRouterPortForwardingConfig ポートフォワーディング設定
202 type VPCRouterPortForwardingConfig struct {
203 Protocol types.EVPCRouterPortForwardingProtocol `json:",omitempty"` // プロトコル(tcp/udp)
204 GlobalPort types.StringNumber `json:",omitempty"` // グローバル側ポート
205 PrivateAddress string `json:",omitempty"` // プライベートIPアドレス
206 PrivatePort types.StringNumber `json:",omitempty"` // プライベート側ポート
207 Description string `json:",omitempty"` // 説明
208 }
209
210 // VPCRouterFirewall ファイアウォール
211 type VPCRouterFirewall struct {
212 Config VPCRouterFirewallConfigs `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
213 Enabled types.StringFlag `yaml:"enabled"`
214 }
215
216 // MarshalJSON 常にEnabledをtrueに設定する
217 func (f *VPCRouterFirewall) MarshalJSON() ([]byte, error) {
218 if f == nil {
219 return nil, nil
220 }
221 f.Enabled = types.StringTrue
222 type alias VPCRouterFirewall
223 a := alias(*f)
224 return json.Marshal(&a)
225 }
226
227 // VPCRouterFirewallConfigs VPCルータのファイアウォール設定
228 //
229 // 配列のインデックスで対象インターフェースを表す
230 type VPCRouterFirewallConfigs [8]*VPCRouterFirewallConfig
231
232 // UnmarshalJSON 配列中にnullが返ってくる(VPCルータなど)への対応
233 func (i *VPCRouterFirewallConfigs) UnmarshalJSON(b []byte) error {
234 type alias VPCRouterFirewallConfigs
235 var a alias
236 if err := json.Unmarshal(b, &a); err != nil {
237 return err
238 }
239
240 var dest [8]*VPCRouterFirewallConfig
241 for i, v := range a {
242 if v != nil {
243 if v.Index == 0 {
244 v.Index = i
245 }
246 dest[v.Index] = v
247 }
248 }
249
250 *i = VPCRouterFirewallConfigs(dest)
251 return nil
252 }
253
254 // MarshalJSON 配列中にnullが入る場合(VPCルータなど)への対応
255 func (i *VPCRouterFirewallConfigs) MarshalJSON() ([]byte, error) {
256 var dest [8]*VPCRouterFirewallConfig
257 for _, iface := range *i {
258 if iface != nil {
259 if iface.Receive == nil {
260 iface.Receive = make([]*VPCRouterFirewallRule, 0)
261 }
262 if iface.Send == nil {
263 iface.Send = make([]*VPCRouterFirewallRule, 0)
264 }
265 dest[iface.Index] = iface
266 }
267 }
268
269 for i, v := range dest {
270 if v == nil {
271 dest[i] = &VPCRouterFirewallConfig{
272 Receive: make([]*VPCRouterFirewallRule, 0),
273 Send: make([]*VPCRouterFirewallRule, 0),
274 Index: i,
275 }
276 }
277 }
278
279 return json.Marshal(dest)
280 }
281
282 // VPCRouterFirewallConfig ファイアウォール
283 type VPCRouterFirewallConfig struct {
284 Receive []*VPCRouterFirewallRule `yaml:"receive"`
285 Send []*VPCRouterFirewallRule `yaml:"send"`
286
287 // Index 仮想フィールド UnmarshalJSONの中で設定される
288 Index int `json:"-"`
289 }
290
291 // VPCRouterFirewallRule ファイアウォール ルール
292 type VPCRouterFirewallRule struct {
293 Protocol types.Protocol `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
294 SourceNetwork types.VPCFirewallNetwork `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
295 SourcePort types.VPCFirewallPort `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
296 DestinationNetwork types.VPCFirewallNetwork `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
297 DestinationPort types.VPCFirewallPort `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
298 Action types.Action `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
299 Logging types.StringFlag `yaml:"enabled"`
300 Description string `yaml:"description"`
301 }
302
303 // VPCRouterDHCPServer DHCPサーバ
304 type VPCRouterDHCPServer struct {
305 Config []*VPCRouterDHCPServerConfig `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
306 Enabled types.StringFlag `yaml:"enabled"`
307 }
308
309 // MarshalJSON Configが一つ以上ある場合にEnabledをtrueに設定する
310 func (f *VPCRouterDHCPServer) MarshalJSON() ([]byte, error) {
311 if f == nil {
312 return nil, nil
313 }
314 if len(f.Config) > 0 {
315 f.Enabled = types.StringTrue
316 }
317 type alias VPCRouterDHCPServer
318 a := alias(*f)
319 return json.Marshal(&a)
320 }
321
322 // VPCRouterDHCPServerConfig DHCPサーバ
323 type VPCRouterDHCPServerConfig struct {
324 Interface string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
325 RangeStop string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
326 RangeStart string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
327 DNSServers []string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
328 }
329
330 // VPCRouterDHCPStaticMappings DHCPスタティックマッピング
331 type VPCRouterDHCPStaticMappings struct {
332 Config []*VPCRouterDHCPStaticMappingConfig `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
333 Enabled types.StringFlag `yaml:"enabled"`
334 }
335
336 // MarshalJSON Configが一つ以上ある場合にEnabledをtrueに設定する
337 func (f *VPCRouterDHCPStaticMappings) MarshalJSON() ([]byte, error) {
338 if f == nil {
339 return nil, nil
340 }
341 if len(f.Config) > 0 {
342 f.Enabled = types.StringTrue
343 }
344 type alias VPCRouterDHCPStaticMappings
345 a := alias(*f)
346 return json.Marshal(&a)
347 }
348
349 // VPCRouterDHCPStaticMappingConfig DHCPスタティックマッピング
350 type VPCRouterDHCPStaticMappingConfig struct {
351 MACAddress string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
352 IPAddress string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
353 }
354
355 // VPCRouterDNSForwarding DNSフォワーディング
356 type VPCRouterDNSForwarding struct {
357 Interface string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
358 DNSServers []string
359 Enabled types.StringFlag `yaml:"enabled"`
360 }
361
362 // MarshalJSON Configが一つ以上ある場合にEnabledをtrueに設定する
363 func (f *VPCRouterDNSForwarding) MarshalJSON() ([]byte, error) {
364 if f == nil {
365 return nil, nil
366 }
367 if f.Interface != "" || len(f.DNSServers) > 0 {
368 f.Enabled = types.StringTrue
369 }
370 type alias VPCRouterDNSForwarding
371 a := alias(*f)
372 return json.Marshal(&a)
373 }
374
375 // VPCRouterPPTPServer PPTP
376 type VPCRouterPPTPServer struct {
377 Config *VPCRouterPPTPServerConfig `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
378 Enabled types.StringFlag `yaml:"enabled"`
379 }
380
381 // VPCRouterPPTPServerConfig PPTP
382 type VPCRouterPPTPServerConfig struct {
383 RangeStart string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
384 RangeStop string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
385 }
386
387 // VPCRouterL2TPIPsecServer L2TP
388 type VPCRouterL2TPIPsecServer struct {
389 Config *VPCRouterL2TPIPsecServerConfig `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
390 Enabled types.StringFlag `yaml:"enabled"`
391 }
392
393 // VPCRouterL2TPIPsecServerConfig L2TP
394 type VPCRouterL2TPIPsecServerConfig struct {
395 RangeStart string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
396 RangeStop string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
397 PreSharedSecret string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
398 }
399
400 // VPCRouterWireGuard WireGuardサーバ
401 type VPCRouterWireGuard struct {
402 Config *VPCRouterWireGuardConfig `yaml:"config"`
403 Enabled types.StringFlag `yaml:"enabled"`
404 }
405
406 // MarshalJSON Configが一つ以上ある場合にEnabledをtrueに設定する
407 func (f *VPCRouterWireGuard) MarshalJSON() ([]byte, error) {
408 if f == nil {
409 return nil, nil
410 }
411 if f.Config == nil {
412 f.Config = &VPCRouterWireGuardConfig{}
413 }
414 if f.Config.IPAddress != "" {
415 f.Enabled = types.StringTrue
416 }
417 type alias VPCRouterWireGuard
418 a := alias(*f)
419 return json.Marshal(&a)
420 }
421
422 // VPCRouterWireGuardConfig WireGuardサーバコンフィグ
423 type VPCRouterWireGuardConfig struct {
424 IPAddress string `yaml:"ip_address"` // xxx.xxx.xxx.xxx/nn
425 Peers []*VPCRouterWireGuardPeer `yaml:"peers"`
426 }
427
428 // MarshalJSON Peersがnullを許容しないため代わりに[]を設定する
429 func (f *VPCRouterWireGuardConfig) MarshalJSON() ([]byte, error) {
430 if f == nil {
431 return nil, nil
432 }
433 if f.Peers == nil {
434 f.Peers = []*VPCRouterWireGuardPeer{}
435 }
436 type alias VPCRouterWireGuardConfig
437 a := alias(*f)
438 return json.Marshal(&a)
439 }
440
441 // VPCRouterWireGuardPeer ピアの設定
442 type VPCRouterWireGuardPeer struct {
443 Name string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
444 IPAddress string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
445 PublicKey string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
446 }
447
448 // VPCRouterRemoteAccessUserConfig リモートアクセスユーザー
449 type VPCRouterRemoteAccessUserConfig struct {
450 UserName string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
451 Password string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
452 }
453
454 // VPCRouterRemoteAccessUsers リモートアクセスユーザー
455 type VPCRouterRemoteAccessUsers struct {
456 Config []*VPCRouterRemoteAccessUserConfig `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
457 Enabled types.StringFlag `yaml:"enabled"`
458 }
459
460 // MarshalJSON Configが一つ以上ある場合にEnabledをtrueに設定する
461 func (f *VPCRouterRemoteAccessUsers) MarshalJSON() ([]byte, error) {
462 if f == nil {
463 return nil, nil
464 }
465 if len(f.Config) > 0 {
466 f.Enabled = types.StringTrue
467 }
468 type alias VPCRouterRemoteAccessUsers
469 a := alias(*f)
470 return json.Marshal(&a)
471 }
472
473 // VPCRouterSiteToSiteIPsecVPN サイト間VPN
474 type VPCRouterSiteToSiteIPsecVPN struct {
475 Config []*VPCRouterSiteToSiteIPsecVPNConfig `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
476 IKE *VPCRouterSiteToSiteIPsecVPNIKE `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
477 ESP *VPCRouterSiteToSiteIPsecVPNESP `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
478 EncryptionAlgo string `json:",omitempty" yaml:",omitempty" structs:",omitempty"` // aes128 or aes256
479 HashAlgo string `json:",omitempty" yaml:",omitempty" structs:",omitempty"` // sha1 or sha256
480 DHGroup string `json:",omitempty" yaml:",omitempty" structs:",omitempty"` // modp1024 or modp2048 or modp3072 or modp4096
481 Enabled types.StringFlag `yaml:"enabled"`
482 }
483
484 // MarshalJSON Configが一つ以上ある場合にEnabledをtrueに設定する
485 func (f *VPCRouterSiteToSiteIPsecVPN) MarshalJSON() ([]byte, error) {
486 if f == nil {
487 return nil, nil
488 }
489 if len(f.Config) > 0 {
490 f.Enabled = types.StringTrue
491 }
492 type alias VPCRouterSiteToSiteIPsecVPN
493 a := alias(*f)
494 return json.Marshal(&a)
495 }
496
497 // VPCRouterSiteToSiteIPsecVPNConfig サイト間VPN
498 type VPCRouterSiteToSiteIPsecVPNConfig struct {
499 Peer string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
500 PreSharedSecret string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
501 RemoteID string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
502 Routes []string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
503 LocalPrefix []string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
504 }
505
506 // VPCRouterSiteToSiteIPsecVPNIKE サイト間VPNのIKE設定値
507 type VPCRouterSiteToSiteIPsecVPNIKE struct {
508 Lifetime int // ISAKMP SAの寿命
509 DPD VPCRouterSiteToSiteIPsecVPNIKEDPD
510 }
511
512 // VPCRouterSiteToSiteIPsecVPNIKEDPD サイト間VPNのIKE設定値 - DPD
513 type VPCRouterSiteToSiteIPsecVPNIKEDPD struct {
514 Interval int // IKEキープアライブ(DPD) インターバル
515 Timeout int // IKEキープアライブ(DPD) タイムアウト
516 }
517
518 // VPCRouterSiteToSiteIPsecVPNESP サイト間VPNのESP設定値
519 type VPCRouterSiteToSiteIPsecVPNESP struct {
520 Lifetime int // IPsec SAの寿命
521 }
522
523 // VPCRouterStaticRoutes スタティックルート
524 type VPCRouterStaticRoutes struct {
525 Config []*VPCRouterStaticRouteConfig `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
526 Enabled types.StringFlag `yaml:"enabled"`
527 }
528
529 // MarshalJSON Configが一つ以上ある場合にEnabledをtrueに設定する
530 func (f *VPCRouterStaticRoutes) MarshalJSON() ([]byte, error) {
531 if f == nil {
532 return nil, nil
533 }
534 if len(f.Config) > 0 {
535 f.Enabled = types.StringTrue
536 }
537 type alias VPCRouterStaticRoutes
538 a := alias(*f)
539 return json.Marshal(&a)
540 }
541
542 // VPCRouterStaticRouteConfig スタティックルート
543 type VPCRouterStaticRouteConfig struct {
544 Prefix string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
545 NextHop string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
546 }
547
548 // VPCRouterScheduledMaintenance
549 type VPCRouterScheduledMaintenance struct {
550 DayOfWeek int // 0が日曜日
551 Hour int // 0-23時
552 }
553
554 // VPCRouterStatus ステータス
555 type VPCRouterStatus struct {
556 FirewallReceiveLogs []string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
557 FirewallSendLogs []string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
558 VPNLogs []string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
559 SessionCount int `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
560 PercentageOfMemoryFree []types.StringNumber `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
561 DHCPServerLeases []struct {
562 IPAddress string
563 MACAddress string
564 } `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
565 L2TPIPsecServerSessions []struct {
566 User string
567 IPAddress string
568 TimeSec int
569 } `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
570 PPTPServerSessions []struct {
571 User string
572 IPAddress string
573 TimeSec int
574 } `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
575 WireGuard *struct {
576 PublicKey string `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
577 } `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
578 SiteToSiteIPsecVPNPeers []struct {
579 Status string
580 Peer string
581 } `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
582 SessionAnalysis *struct {
583 SourceAndDestination []*VPCRouterStatisticsValue `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
584 DestinationAddress []*VPCRouterStatisticsValue `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
585 DestinationPort []*VPCRouterStatisticsValue `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
586 SourceAddress []*VPCRouterStatisticsValue `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
587 } `json:",omitempty" yaml:",omitempty" structs:",omitempty"`
588 }
589
590 type VPCRouterLog struct {
591 Log string
592 }
593
594 type VPCRouterPingResult struct {
595 Result []string
596 }
597
598 // VPCRouterStatisticsValue VPCルータのセッション統計情報
599 type VPCRouterStatisticsValue struct {
600 Name string `json:"name,omitempty" yaml:"name,omitempty" structs:",omitempty"`
601 Count int `json:"count,omitempty" yaml:"count,omitempty" structs:",omitempty"`
602 }
603