11package bigip
22
3- import "encoding/json"
3+ import (
4+ "encoding/json"
5+ )
46
57// LIC contains device license for BIG-IP system.
68type LICs struct {
@@ -56,10 +58,77 @@ type Devicegroups struct {
5658}
5759
5860type Devicegroup struct {
59- AutoSync string `json:"autoSync,omitempty"`
60- Name string `json:"name,omitempty"`
61- Type string `json:"type,omitempty"`
62- FullLoadOnSync string `json:"fullLoadOnSync,omitempty"`
61+ AutoSync string
62+ Name string
63+ Partition string
64+ Description string
65+ Type string
66+ FullLoadOnSync string
67+ SaveOnAutoSync string
68+ NetworkFailover string
69+ IncrementalConfigSyncSizeMax int
70+ Deviceb []Devicerecord
71+ }
72+ type devicegroupDTO struct {
73+ AutoSync string `json:"autoSync,omitempty"`
74+ Name string `json:"name,omitempty"`
75+ Partition string `json:"partition,omitempty"`
76+ Description string `json:"description,omitempty"`
77+ Type string `json:"type,omitempty"`
78+ FullLoadOnSync string `json:"fullLoadOnSync,omitempty"`
79+ SaveOnAutoSync string `json:"saveOnAutoSync,omitempty"`
80+ NetworkFailover string `json:"networkFailover,omitempty"`
81+ IncrementalConfigSyncSizeMax int `json:"incrementalConfigSyncSizeMax,omitempty"`
82+ Deviceb struct {
83+ Items []Devicerecord `json:"items,omitempty"`
84+ } `json:"devicesReference,omitempty"`
85+ }
86+
87+ type Devicerecords struct {
88+ Items []Devicerecord `json:"items,omitempty"`
89+ }
90+
91+ type Devicerecord struct {
92+ SetSyncLeader bool `json:"setSyncLeader"`
93+ Name string `json:"name"`
94+ }
95+
96+ func (p * Devicegroup ) MarshalJSON () ([]byte , error ) {
97+ return json .Marshal (devicegroupDTO {
98+ Name : p .Name ,
99+ Partition : p .Partition ,
100+ AutoSync : p .AutoSync ,
101+ Description : p .Description ,
102+ Type : p .Type ,
103+ FullLoadOnSync : p .FullLoadOnSync ,
104+ SaveOnAutoSync : p .SaveOnAutoSync ,
105+ NetworkFailover : p .NetworkFailover ,
106+ IncrementalConfigSyncSizeMax : p .IncrementalConfigSyncSizeMax ,
107+ Deviceb : struct {
108+ Items []Devicerecord `json:"items,omitempty"`
109+ }{Items : p .Deviceb },
110+ })
111+ }
112+
113+ func (p * Devicegroup ) UnmarshalJSON (b []byte ) error {
114+ var dto devicegroupDTO
115+ err := json .Unmarshal (b , & dto )
116+ if err != nil {
117+ return err
118+ }
119+
120+ p .Name = dto .Name
121+ p .Partition = dto .Partition
122+ p .AutoSync = dto .AutoSync
123+ p .Description = dto .Description
124+ p .Type = dto .Type
125+ p .FullLoadOnSync = dto .FullLoadOnSync
126+ p .SaveOnAutoSync = dto .SaveOnAutoSync
127+ p .NetworkFailover = dto .NetworkFailover
128+ p .IncrementalConfigSyncSizeMax = dto .IncrementalConfigSyncSizeMax
129+ p .Deviceb = dto .Deviceb .Items
130+
131+ return nil
63132}
64133
65134// https://10.192.74.80/mgmt/cm/device/licensing/pool/purchased-pool/licenses
@@ -68,6 +137,8 @@ const (
68137 uriMgmt = "mgmt"
69138 uriCm = "cm"
70139 uriDiv = "device"
140+ uriDevices = "devices"
141+ uriDG = "device-group"
71142 uriLins = "licensing"
72143 uriPoo = "pool"
73144 uriPur = "purchased-pool"
@@ -158,31 +229,6 @@ func (b *BigIP) LICs() (*LIC, error) {
158229 return & members , nil
159230}
160231
161- func (b * BigIP ) CreateDevicename (command , name , target string ) error {
162- config := & Devicename {
163- Command : command ,
164- Name : name ,
165- Target : target ,
166- }
167-
168- return b .post (config , uriCm , uriDiv )
169- }
170-
171- func (b * BigIP ) ModifyDevicename (config * Devicename ) error {
172- return b .put (config , uriCm , uriDiv )
173- }
174-
175- func (b * BigIP ) Devicenames () (* Devicename , error ) {
176- var devicename Devicename
177- err , _ := b .getForEntity (& devicename , uriCm , uriDiv )
178-
179- if err != nil {
180- return nil , err
181- }
182-
183- return & devicename , nil
184- }
185-
186232func (b * BigIP ) CreateDevice (name , configsyncIp , mirrorIp , mirrorSecondaryIp string ) error {
187233 config := & Device {
188234 Name : name ,
@@ -194,13 +240,18 @@ func (b *BigIP) CreateDevice(name, configsyncIp, mirrorIp, mirrorSecondaryIp str
194240 return b .post (config , uriCm , uriDiv )
195241}
196242
243+ // API does not work, you cannot modify API issue
197244func (b * BigIP ) ModifyDevice (config * Device ) error {
198245 return b .put (config , uriCm , uriDiv )
199246}
200247
201- func (b * BigIP ) Devices () (* Device , error ) {
248+ func (b * BigIP ) DeleteDevice (name string ) error {
249+ return b .delete (uriCm , uriDiv , name )
250+ }
251+
252+ func (b * BigIP ) Devices (name string ) (* Device , error ) {
202253 var device Device
203- err , _ := b .getForEntity (& device , uriCm , uriDiv )
254+ err , _ := b .getForEntity (& device , uriCm , uriDiv , name )
204255
205256 if err != nil {
206257 return nil , err
@@ -209,25 +260,38 @@ func (b *BigIP) Devices() (*Device, error) {
209260 return & device , nil
210261}
211262
212- func (b * BigIP ) CreateDevicegroup (name , autoSync , typo , fullLoadOnSync string ) error {
213- config := & Devicegroup {
214- Name : name ,
215- AutoSync : autoSync ,
216- Type : typo ,
217- FullLoadOnSync : fullLoadOnSync ,
218- }
219-
220- return b .post (config , uriCm , uriDiv )
263+ func (b * BigIP ) CreateDevicegroup (p * Devicegroup ) error {
264+ return b .post (p , uriCm , uriDG )
221265}
222266
267+ func (b * BigIP ) UpdateDevicegroup (name string , p * Devicegroup ) error {
268+ return b .put (p , uriCm , uriDG , name )
269+ }
223270func (b * BigIP ) ModifyDevicegroup (config * Devicegroup ) error {
224- return b .put (config , uriCm , uriDiv )
271+ return b .put (config , uriCm , uriDG )
225272}
226273
227- func (b * BigIP ) Devicegroups () (* Devicegroup , error ) {
274+ func (b * BigIP ) Devicegroups (name string ) (* Devicegroup , error ) {
228275 var devicegroup Devicegroup
229- err , _ := b .getForEntity (& devicegroup , uriCm , uriDiv )
276+ err , _ := b .getForEntity (& devicegroup , uriCm , uriDG , name )
277+ if err != nil {
278+ return nil , err
279+ }
280+
281+ return & devicegroup , nil
282+ }
283+
284+ func (b * BigIP ) DeleteDevicegroup (name string ) error {
285+ return b .delete (uriCm , uriDG , name )
286+ }
230287
288+ func (b * BigIP ) DeleteDevicegroupDevices (name , rname string ) error {
289+ return b .delete (uriCm , uriDG , name , uriDevices , rname )
290+ }
291+
292+ func (b * BigIP ) DevicegroupsDevices (name , rname string ) (* Devicegroup , error ) {
293+ var devicegroup Devicegroup
294+ err , _ := b .getForEntity (& devicegroup , uriCm , uriDG , name , uriDevices , rname )
231295 if err != nil {
232296 return nil , err
233297 }
0 commit comments