forked from infobloxopen/infoblox-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
objects.go
1072 lines (918 loc) · 28 KB
/
objects.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package ibclient
import (
"bytes"
"encoding/json"
"fmt"
"reflect"
)
const MACADDR_ZERO = "00:00:00:00:00:00"
type Bool bool
type EA map[string]interface{}
type EASearch map[string]interface{}
type EADefListValue string
type IBBase struct {
objectType string
returnFields []string
eaSearch EASearch
}
type IBObject interface {
ObjectType() string
ReturnFields() []string
EaSearch() EASearch
//SetReturnFields([]string)
}
func (obj *IBBase) ObjectType() string {
return obj.objectType
}
func (obj *IBBase) ReturnFields() []string {
return obj.returnFields
}
func (obj *IBBase) EaSearch() EASearch {
return obj.eaSearch
}
type NetworkView struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Name string `json:"name,omitempty"`
Comment string `json:"comment"`
Ea EA `json:"extattrs"`
}
func NewEmptyNetworkView() *NetworkView {
res := &NetworkView{}
res.objectType = "networkview"
res.returnFields = []string{"extattrs", "name", "comment"}
return res
}
func NewNetworkView(name string, comment string, eas EA, ref string) *NetworkView {
res := NewEmptyNetworkView()
res.Name = name
res.Comment = comment
res.Ea = eas
res.Ref = ref
return res
}
// UpgradeStatus object representation
type UpgradeStatus struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Type string `json:"type"`
SubElementStatus []SubElementsStatus `json:"subelements_status,omitempty"`
UpgradeGroup string `json:"upgrade_group,omitempty"`
}
func NewUpgradeStatus(upgradeStatus UpgradeStatus) *UpgradeStatus {
result := upgradeStatus
returnFields := []string{"subelements_status", "type"}
result.objectType = "upgradestatus"
result.returnFields = returnFields
return &result
}
// SubElementsStatus object representation
type SubElementsStatus struct {
Ref string `json:"_ref,omitempty"`
CurrentVersion string `json:"current_version"`
ElementStatus string `json:"element_status"`
Ipv4Address string `json:"ipv4_address"`
Ipv6Address string `json:"ipv6_address"`
StatusValue string `json:"status_value"`
StepsTotal int `json:"steps_total"`
StepsCompleted int `json:"steps_completed"`
NodeType string `json:"type"`
Member string `json:"member"`
}
type Network struct {
IBBase
Ref string `json:"_ref,omitempty"`
NetviewName string `json:"network_view,omitempty"`
Cidr string `json:"network,omitempty"`
Ea EA `json:"extattrs"`
Comment string `json:"comment"`
}
func NewNetwork(netview string, cidr string, isIPv6 bool, comment string, ea EA) *Network {
var res Network
res.NetviewName = netview
res.Cidr = cidr
res.Ea = ea
res.Comment = comment
if isIPv6 {
res.objectType = "ipv6network"
} else {
res.objectType = "network"
}
res.returnFields = []string{"extattrs", "network", "network_view", "comment"}
return &res
}
type ServiceStatus struct {
Desciption string `json:"description,omitempty"`
Service string `json:"service,omitempty"`
Status string `json:"status,omitempty"`
}
type LanHaPortSetting struct {
HAIpAddress string `json:"ha_ip_address,omitempty"`
HaPortSetting PhysicalPortSetting `json:"ha_port_setting,omitempty"`
LanPortSetting PhysicalPortSetting `json:"lan_port_setting,omitempty"`
MgmtIpv6addr string `json:"mgmt_ipv6addr,omitempty"`
MgmtLan string `json:"mgmt_lan,omitempty"`
}
type PhysicalPortSetting struct {
AutoPortSettingEnabled bool `json:"auto_port_setting_enabled"`
Duplex string `json:"duplex,omitempty"`
Speed string `json:"speed,omitempty"`
}
type NetworkSetting struct {
Address string `json:"address"`
Dscp uint `json:"dscp"`
Gateway string `json:"gateway"`
Primary bool `json:"primary"`
SubnetMask string `json:"subnet_mask"`
UseDscp bool `json:"use_dscp,omiempty"`
VlanId uint `json:"vlan_id,omitempty"`
}
type Ipv6Setting struct {
AutoRouterConfigEnabled bool `json:"auto_router_config_enabled"`
CidrPrefix uint `json:"cidr_prefix,omitempty"`
Dscp uint `json:"dscp,omitempty"`
Enabled bool `json:"enabled,omitempty"`
Gateway string `json:"gateway"`
Primary string `json:"primary,omitempty"`
VirtualIp string `json:"virtual_ip"`
VlanId uint `json:"vlan_id,emitempty"`
UseDscp bool `json:"use_dscp,omitempty"`
}
type NodeInfo struct {
HaStatus string `json:"ha_status,omitempty"`
HwId string `json:"hwid,omitempty"`
HwModel string `json:"hwmodel,omitempty"`
HwPlatform string `json:"hwplatform,omitempty"`
HwType string `json:"hwtype,omitempty"`
Lan2PhysicalSetting PhysicalPortSetting `json:"lan2_physical_setting,omitempty"`
LanHaPortSetting LanHaPortSetting `json:"lan_ha_Port_Setting,omitempty"`
MgmtNetworkSetting NetworkSetting `json:"mgmt_network_setting,omitempty"`
MgmtPhysicalSetting PhysicalPortSetting `json:"mgmt_physical_setting,omitempty"`
PaidNios bool `json:"paid_nios,omitempty"`
PhysicalOid string `json:"physical_oid,omitempty"`
ServiceStatus []ServiceStatus `json:"service_status,omitempty"`
V6MgmtNetworkSetting Ipv6Setting `json:"v6_mgmt_network_setting,omitempty"`
}
// Member represents NIOS member
type Member struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
HostName string `json:"host_name,omitempty"`
ConfigAddrType string `json:"config_addr_type,omitempty"`
PLATFORM string `json:"platform,omitempty"`
ServiceTypeConfiguration string `json:"service_type_configuration,omitempty"`
Nodeinfo []NodeInfo `json:"node_info,omitempty"`
TimeZone string `json:"time_zone,omitempty"`
}
func NewMember(member Member) *Member {
res := member
res.objectType = "member"
returnFields := []string{"host_name", "node_info", "time_zone"}
res.returnFields = returnFields
return &res
}
// License represents license wapi object
type License struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
ExpirationStatus string `json:"expiration_status,omitempty"`
ExpiryDate int `json:"expiry_date,omitempty"`
HwID string `json:"hwid,omitempty"`
Key string `json:"key,omitempty"`
Kind string `json:"kind,omitempty"`
Limit string `json:"limit,omitempty"`
LimitContext string `json:"limit_context,omitempty"`
Licensetype string `json:"type,omitempty"`
}
func NewGridLicense(license License) *License {
result := license
result.objectType = "license:gridwide"
returnFields := []string{"expiration_status",
"expiry_date",
"key",
"limit",
"limit_context",
"type"}
result.returnFields = returnFields
return &result
}
func NewLicense(license License) *License {
result := license
returnFields := []string{"expiration_status",
"expiry_date",
"hwid",
"key",
"kind",
"limit",
"limit_context",
"type"}
result.objectType = "member:license"
result.returnFields = returnFields
return &result
}
// CapacityReport represents capacityreport object
type CapacityReport struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Name string `json:"name,omitempty"`
HardwareType string `json:"hardware_type,omitempty"`
MaxCapacity int `json:"max_capacity,omitempty"`
ObjectCount []map[string]interface{} `json:"object_counts,omitempty"`
PercentUsed int `json:"percent_used,omitempty"`
Role string `json:"role,omitempty"`
TotalObjects int `json:"total_objects,omitempty"`
}
func NewCapcityReport(capReport CapacityReport) *CapacityReport {
res := capReport
returnFields := []string{"name", "hardware_type", "max_capacity", "object_counts", "percent_used", "role", "total_objects"}
res.objectType = "capacityreport"
res.returnFields = returnFields
return &res
}
type NTPserver struct {
Address string `json:"address,omitempty"`
Burst bool `json:"burst,omitempty"`
EnableAuthentication bool `json:"enable_authentication,omitempty"`
IBurst bool `json:"iburst,omitempty"`
NTPKeyNumber uint `json:"ntp_key_number,omitempty"`
Preffered bool `json:"preffered,omitempty"`
}
type NTPSetting struct {
EnableNTP bool `json:"enable_ntp,omitempty"`
NTPAcl map[string]interface{} `json:"ntp_acl,omitempty"`
NTPKeys []string `json:"ntp_keys,omitempty"`
NTPKod bool `json:"ntp_kod,omitempty"`
NTPServers []NTPserver `json:"ntp_servers,omitempty"`
}
type Grid struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Name string `json:"name,omitempty"`
NTPSetting *NTPSetting `json:"ntp_setting,omitempty"`
}
func NewGrid(grid Grid) *Grid {
result := grid
result.objectType = "grid"
returnFields := []string{"name", "ntp_setting"}
result.returnFields = returnFields
return &result
}
type NetworkContainer struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
NetviewName string `json:"network_view,omitempty"`
Cidr string `json:"network,omitempty"`
Comment string `json:"comment"`
Ea EA `json:"extattrs"`
}
func NewNetworkContainer(netview, cidr string, isIPv6 bool, comment string, ea EA) *NetworkContainer {
nc := NetworkContainer{
NetviewName: netview,
Cidr: cidr,
Ea: ea,
Comment: comment,
}
if isIPv6 {
nc.objectType = "ipv6networkcontainer"
} else {
nc.objectType = "networkcontainer"
}
nc.returnFields = []string{"extattrs", "network", "network_view", "comment"}
return &nc
}
type NetworkContainerNextAvailable struct {
IBBase `json:"-"`
Network *NetworkContainerNextAvailableInfo `json:"network"`
Comment string `json:"comment"`
Ea EA `json:"extattrs"`
}
type NetworkContainerNextAvailableInfo struct {
Function string `json:"_object_function"`
ResultField string `json:"_result_field"`
Object string `json:"_object"`
ObjectParams map[string]string `json:"_object_parameters"`
Params map[string]uint `json:"_parameters"`
NetviewName string `json:"network_view,omitempty"`
}
func NewNetworkContainerNextAvailableInfo(netview, cidr string, prefixLen uint, isIPv6 bool) *NetworkContainerNextAvailableInfo {
containerInfo := NetworkContainerNextAvailableInfo{
Function: "next_available_network",
ResultField: "networks",
ObjectParams: map[string]string{"network": cidr},
Params: map[string]uint{"cidr": prefixLen},
NetviewName: netview,
}
if isIPv6 {
containerInfo.Object = "ipv6networkcontainer"
} else {
containerInfo.Object = "networkcontainer"
}
return &containerInfo
}
func NewNetworkContainerNextAvailable(ncav *NetworkContainerNextAvailableInfo, isIPv6 bool, comment string, ea EA) *NetworkContainerNextAvailable {
nc := &NetworkContainerNextAvailable{
Network: ncav,
Ea: ea,
Comment: comment,
}
if isIPv6 {
nc.objectType = "ipv6networkcontainer"
} else {
nc.objectType = "networkcontainer"
}
nc.returnFields = []string{"extattrs", "network", "network_view", "comment"}
return nc
}
type FixedAddress struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
NetviewName string `json:"network_view,omitempty"`
Cidr string `json:"network,omitempty"`
Comment string `json:"comment"`
IPv4Address string `json:"ipv4addr,omitempty"`
IPv6Address string `json:"ipv6addr,omitempty"`
Duid string `json:"duid,omitempty"`
Mac string `json:"mac,omitempty"`
Name string `json:"name,omitempty"`
MatchClient string `json:"match_client,omitempty"`
Ea EA `json:"extattrs"`
}
/*This is a general struct to add query params used in makeRequest*/
type QueryParams struct {
forceProxy bool
searchFields map[string]string
}
func NewQueryParams(forceProxy bool, searchFields map[string]string) *QueryParams {
qp := QueryParams{forceProxy: forceProxy}
if searchFields != nil {
qp.searchFields = searchFields
} else {
qp.searchFields = make(map[string]string)
}
return &qp
}
func NewEmptyFixedAddress(isIPv6 bool) *FixedAddress {
res := &FixedAddress{}
res.Ea = make(EA)
if isIPv6 {
res.objectType = "ipv6fixedaddress"
res.returnFields = []string{"extattrs", "ipv6addr", "duid", "name", "network", "network_view", "comment"}
} else {
res.objectType = "fixedaddress"
res.returnFields = []string{"extattrs", "ipv4addr", "mac", "name", "network", "network_view", "comment"}
}
return res
}
func NewFixedAddress(
netView string,
name string,
ipAddr string,
cidr string,
macOrDuid string,
clients string,
eas EA,
ref string,
isIPv6 bool,
comment string) *FixedAddress {
res := NewEmptyFixedAddress(isIPv6)
res.NetviewName = netView
res.Name = name
res.Cidr = cidr
res.MatchClient = clients
res.Ea = eas
res.Ref = ref
res.Comment = comment
if isIPv6 {
res.IPv6Address = ipAddr
res.Duid = macOrDuid
} else {
res.IPv4Address = ipAddr
res.Mac = macOrDuid
}
return res
}
type EADefinition struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Comment string `json:"comment"`
Flags string `json:"flags,omitempty"`
ListValues []EADefListValue `json:"list_values,omitempty"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
AllowedObjectTypes []string `json:"allowed_object_types,omitempty"`
}
func NewEADefinition(eadef EADefinition) *EADefinition {
res := eadef
res.objectType = "extensibleattributedef"
res.returnFields = []string{"allowed_object_types", "comment", "flags", "list_values", "name", "type"}
return &res
}
type UserProfile struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Name string `json:"name,omitempty"`
}
func NewUserProfile(userprofile UserProfile) *UserProfile {
res := userprofile
res.objectType = "userprofile"
res.returnFields = []string{"name"}
return &res
}
type DNSView struct {
IBBase `json:"-"`
Ref string `json:"_ref"`
Name string `json:"name"`
NetworkView string `json:"network_view"`
Comment string `json:"comment"`
Ea EA `json:"extattrs"`
}
func NewEmptyDNSView() *DNSView {
res := &DNSView{}
res.objectType = "view"
res.returnFields = []string{"extattrs", "name", "network_view", "comment"}
return res
}
type RecordA struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Ipv4Addr string `json:"ipv4addr,omitempty"`
Name string `json:"name,omitempty"`
View string `json:"view,omitempty"`
Zone string `json:"zone,omitempty"`
UseTtl bool `json:"use_ttl"`
Ttl uint32 `json:"ttl"`
Comment string `json:"comment"`
Ea EA `json:"extattrs"`
}
func NewEmptyRecordA() *RecordA {
res := &RecordA{}
res.objectType = "record:a"
res.returnFields = []string{
"extattrs", "ipv4addr", "name", "view", "zone", "comment", "ttl", "use_ttl"}
return res
}
func NewRecordA(
view string,
zone string,
name string,
ipAddr string,
ttl uint32,
useTTL bool,
comment string,
eas EA,
ref string) *RecordA {
res := NewEmptyRecordA()
res.View = view
res.Zone = zone
res.Name = name
res.Ipv4Addr = ipAddr
res.Ttl = ttl
res.UseTtl = useTTL
res.Comment = comment
res.Ea = eas
res.Ref = ref
return res
}
type RecordAAAA struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Ipv6Addr string `json:"ipv6addr,omitempty"`
Name string `json:"name,omitempty"`
View string `json:"view,omitempty"`
Zone string `json:"zone,omitempty"`
UseTtl bool `json:"use_ttl"`
Ttl uint32 `json:"ttl"`
Comment string `json:"comment"`
Ea EA `json:"extattrs"`
}
func NewEmptyRecordAAAA() *RecordAAAA {
res := &RecordAAAA{}
res.objectType = "record:aaaa"
res.returnFields = []string{"extattrs", "ipv6addr", "name", "view", "zone", "use_ttl", "ttl", "comment"}
return res
}
func NewRecordAAAA(
view string,
name string,
ipAddr string,
useTtl bool,
ttl uint32,
comment string,
eas EA,
ref string) *RecordAAAA {
res := NewEmptyRecordAAAA()
res.View = view
res.Name = name
res.Ipv6Addr = ipAddr
res.UseTtl = useTtl
res.Ttl = ttl
res.Comment = comment
res.Ea = eas
res.Ref = ref
return res
}
type RecordPTR struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Ipv4Addr string `json:"ipv4addr,omitempty"`
Ipv6Addr string `json:"ipv6addr,omitempty"`
Name string `json:"name,omitempty"`
PtrdName string `json:"ptrdname,omitempty"`
View string `json:"view,omitempty"`
Zone string `json:"zone,omitempty"`
Ea EA `json:"extattrs"`
UseTtl bool `json:"use_ttl"`
Ttl uint32 `json:"ttl"`
Comment string `json:"comment"`
}
func NewEmptyRecordPTR() *RecordPTR {
res := RecordPTR{}
res.objectType = "record:ptr"
res.returnFields = []string{"extattrs", "ipv4addr", "ipv6addr", "name", "ptrdname", "view", "zone", "comment", "use_ttl", "ttl"}
return &res
}
func NewRecordPTR(dnsView string, ptrdname string, useTtl bool, ttl uint32, comment string, ea EA) *RecordPTR {
res := NewEmptyRecordPTR()
res.View = dnsView
res.PtrdName = ptrdname
res.UseTtl = useTtl
res.Ttl = ttl
res.Comment = comment
res.Ea = ea
return res
}
type RecordCNAME struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Canonical string `json:"canonical,omitempty"`
Name string `json:"name,omitempty"`
View string `json:"view,omitempty"`
Zone string `json:"zone,omitempty"`
Ea EA `json:"extattrs"`
Comment string `json:"comment"`
UseTtl bool `json:"use_ttl"`
Ttl uint32 `json:"ttl"`
}
func NewEmptyRecordCNAME() *RecordCNAME {
res := &RecordCNAME{}
res.objectType = "record:cname"
res.returnFields = []string{"extattrs", "canonical", "name", "view", "zone", "comment", "ttl", "use_ttl"}
return res
}
func NewRecordCNAME(dnsView string,
canonical string,
recordName string,
useTtl bool,
ttl uint32,
comment string,
ea EA,
ref string) *RecordCNAME {
res := NewEmptyRecordCNAME()
res.View = dnsView
res.Canonical = canonical
res.Name = recordName
res.UseTtl = useTtl
res.Ttl = ttl
res.Comment = comment
res.Ea = ea
res.Ref = ref
return res
}
type HostRecordIpv4Addr struct {
IBBase `json:"-"`
Ipv4Addr string `json:"ipv4addr,omitempty"`
Ref string `json:"_ref,omitempty"`
Mac string `json:"mac"`
View string `json:"view,omitempty"`
Cidr string `json:"network,omitempty"`
EnableDhcp bool `json:"configure_for_dhcp"`
}
func NewEmptyHostRecordIpv4Addr() *HostRecordIpv4Addr {
res := &HostRecordIpv4Addr{}
res.objectType = "record:host_ipv4addr"
return res
}
func NewHostRecordIpv4Addr(
ipAddr string,
macAddr string,
enableDhcp bool,
ref string) *HostRecordIpv4Addr {
res := NewEmptyHostRecordIpv4Addr()
res.Ipv4Addr = ipAddr
res.Mac = macAddr
res.Ref = ref
res.EnableDhcp = enableDhcp
return res
}
type HostRecordIpv6Addr struct {
IBBase `json:"-"`
Ipv6Addr string `json:"ipv6addr,omitempty"`
Ref string `json:"_ref,omitempty"`
Duid string `json:"duid"`
View string `json:"view,omitempty"`
Cidr string `json:"network,omitempty"`
EnableDhcp bool `json:"configure_for_dhcp"`
}
func NewEmptyHostRecordIpv6Addr() *HostRecordIpv6Addr {
res := &HostRecordIpv6Addr{}
res.objectType = "record:host_ipv6addr"
return res
}
func NewHostRecordIpv6Addr(
ipAddr string,
duid string,
enableDhcp bool,
ref string) *HostRecordIpv6Addr {
res := NewEmptyHostRecordIpv6Addr()
res.Ipv6Addr = ipAddr
res.Duid = duid
res.Ref = ref
res.EnableDhcp = enableDhcp
return res
}
type HostRecord struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Ipv4Addr string `json:"ipv4addr,omitempty"`
Ipv4Addrs []HostRecordIpv4Addr `json:"ipv4addrs"`
Ipv6Addr string `json:"ipv6addr,omitempty"`
Ipv6Addrs []HostRecordIpv6Addr `json:"ipv6addrs"`
Name string `json:"name,omitempty"`
View string `json:"view,omitempty"`
Zone string `json:"zone,omitempty"`
EnableDns bool `json:"configure_for_dns"`
NetworkView string `json:"network_view,omitempty"`
Comment string `json:"comment"`
Ea EA `json:"extattrs"`
UseTtl bool `json:"use_ttl"`
Ttl uint32 `json:"ttl"`
Aliases []string `json:"aliases,omitempty"`
}
func NewEmptyHostRecord() *HostRecord {
res := &HostRecord{}
res.objectType = "record:host"
res.returnFields = []string{"extattrs", "ipv4addrs", "ipv6addrs", "name", "view", "zone", "comment", "network_view", "aliases", "use_ttl", "ttl", "configure_for_dns"}
return res
}
func NewHostRecord(
netView string,
name string,
ipv4Addr string,
ipv6Addr string,
ipv4AddrList []HostRecordIpv4Addr,
ipv6AddrList []HostRecordIpv6Addr,
eas EA,
enableDNS bool,
dnsView string,
zone string,
ref string,
useTtl bool,
ttl uint32,
comment string,
aliases []string) *HostRecord {
res := NewEmptyHostRecord()
res.NetworkView = netView
res.Name = name
res.Ea = eas
res.View = dnsView
res.Zone = zone
res.Ref = ref
res.Comment = comment
res.Ipv4Addr = ipv4Addr
res.Ipv6Addr = ipv6Addr
res.Ipv4Addrs = ipv4AddrList
res.Ipv6Addrs = ipv6AddrList
res.UseTtl = useTtl
res.Ttl = ttl
res.Aliases = aliases
res.EnableDns = enableDNS
return res
}
type RecordMX struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
View string `json:"view,omitempty"`
Fqdn string `json:"name,omitempty"`
MX string `json:"mail_exchanger,omitempty"`
Preference uint32 `json:"preference"`
Zone string `json:"zone,omitempty"`
Ttl uint32 `json:"ttl"`
UseTtl bool `json:"use_ttl"`
Comment string `json:"comment"`
Ea EA `json:"extattrs"`
}
var mxRecordReturnFieldsList = []string{"mail_exchanger", "view", "name", "preference", "ttl", "use_ttl", "comment", "extattrs", "zone"}
func NewEmptyRecordMX() *RecordMX {
res := &RecordMX{}
res.objectType = "record:mx"
res.returnFields = mxRecordReturnFieldsList
return res
}
func NewRecordMX(rm RecordMX) *RecordMX {
res := rm
res.objectType = "record:mx"
res.returnFields = mxRecordReturnFieldsList
return &res
}
type RecordSRV struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
View string `json:"view,omitempty"`
Name string `json:"name,omitempty"`
Priority uint32 `json:"priority"`
Weight uint32 `json:"weight"`
Port uint32 `json:"port"`
Target string `json:"target,omitempty"`
Zone string `json:"zone,omitempty"`
Ttl uint32 `json:"ttl"`
UseTtl bool `json:"use_ttl"`
Comment string `json:"comment"`
Ea EA `json:"extattrs"`
}
var srvRecordReturnFieldsList = []string{"name", "view", "priority", "weight", "port", "target", "ttl", "use_ttl", "comment", "extattrs", "zone"}
func NewEmptyRecordSRV() *RecordSRV {
res := RecordSRV{}
res.objectType = "record:srv"
res.returnFields = srvRecordReturnFieldsList
return &res
}
func NewRecordSRV(rv RecordSRV) *RecordSRV {
res := rv
res.objectType = "record:srv"
res.returnFields = srvRecordReturnFieldsList
return &res
}
type RecordTXT struct {
IBBase `json:"-"`
View string `json:"view,omitempty"`
Zone string `json:"zone,omitempty"`
Ref string `json:"_ref,omitempty"`
Name string `json:"name,omitempty"`
Text string `json:"text,omitempty"`
Ttl uint32 `json:"ttl"`
UseTtl bool `json:"use_ttl"`
Comment string `json:"comment"`
Ea EA `json:"extattrs"`
}
func NewEmptyRecordTXT() *RecordTXT {
res := RecordTXT{}
res.objectType = "record:txt"
res.returnFields = []string{"view", "zone", "name", "text", "ttl", "use_ttl", "comment", "extattrs"}
return &res
}
func NewRecordTXT(
dnsview string,
zone string,
recordname string,
text string,
ttl uint32,
useTtl bool,
comment string,
eas EA) *RecordTXT {
res := NewEmptyRecordTXT()
res.View = dnsview
res.Zone = zone
res.Name = recordname
res.Text = text
res.Ttl = ttl
res.UseTtl = useTtl
res.Comment = comment
res.Ea = eas
return res
}
type ZoneAuth struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Fqdn string `json:"fqdn,omitempty"`
View string `json:"view,omitempty"`
Ea EA `json:"extattrs"`
}
func NewZoneAuth(za ZoneAuth) *ZoneAuth {
res := za
res.objectType = "zone_auth"
res.returnFields = []string{"extattrs", "fqdn", "view"}
return &res
}
type NameServer struct {
Address string `json:"address,omitempty"`
Name string `json:"name,omitempty"`
}
type ZoneDelegated struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Fqdn string `json:"fqdn,omitempty"`
DelegateTo []NameServer `json:"delegate_to,omitempty"`
View string `json:"view,omitempty"`
Ea EA `json:"extattrs"`
}
func NewZoneDelegated(za ZoneDelegated) *ZoneDelegated {
res := za
res.objectType = "zone_delegated"
res.returnFields = []string{"extattrs", "fqdn", "view", "delegate_to"}
return &res
}
func (ea EA) Count() int {
return len(ea)
}
func (ea EA) MarshalJSON() ([]byte, error) {
m := make(map[string]interface{})
for k, v := range ea {
value := make(map[string]interface{})
value["value"] = v
m[k] = value
}
return json.Marshal(m)
}
func (eas EASearch) MarshalJSON() ([]byte, error) {
m := make(map[string]interface{})
for k, v := range eas {
m["*"+k] = v
}
return json.Marshal(m)
}
func (v EADefListValue) MarshalJSON() ([]byte, error) {
m := make(map[string]string)
m["value"] = string(v)
return json.Marshal(m)
}
func (b Bool) MarshalJSON() ([]byte, error) {
if b {
return json.Marshal("True")
}
return json.Marshal("False")
}
func (ea *EA) UnmarshalJSON(b []byte) (err error) {
var m map[string]map[string]interface{}
decoder := json.NewDecoder(bytes.NewBuffer(b))
decoder.UseNumber()
err = decoder.Decode(&m)
if err != nil {
return
}
*ea = make(EA)
for k, v := range m {
val := v["value"]
switch valType := reflect.TypeOf(val).String(); valType {
case "json.Number":