forked from f5devcentral/go-bigip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.go
107 lines (94 loc) · 3.11 KB
/
application.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
package bigip
import (
//"encoding/json"
"fmt"
"log"
"strings"
)
// LIC contains device license for BIG-IP system.
type Iapps struct {
Iapps []Iapp `json:"items"`
}
type Iapp struct {
Name string `json:"name,omitempty"`
Partition string `json:"partition,omitempty"`
Description string `json:"description,omitempty"`
DeviceGroup string `json:"deviceGroup,omitempty"`
ExecuteAction string `json:"execute-action,omitempty"`
InheritedDevicegroup string `json:"inheritedDevicegroup,omitempty"`
InheritedTrafficGroup string `json:"inheritedTrafficGroup,omitempty"`
StrictUpdates string `json:"strictUpdates,omitempty"`
Template string `json:"template,omitempty"`
TemplateModified string `json:"templateModified,omitempty"`
TemplatePrerequisiteErrors string `json:"templatePrerequisiteErrors,omitempty"`
TrafficGroup string `json:"trafficGroup,omitempty"`
Jsonfile string `json:"apiAnonymous,omitempty"`
Tables []struct {
ColumnNames []string `json:"columnNames"`
Name string `json:"name"`
Rows []struct {
Row []string `json:"row"`
} `json:"rows"`
} `json:"tables,omitempty"`
Lists []struct {
Name string `json:"name"`
Encrypted string `json:"encrypted"`
Value []string `json:"value"`
} `json:"lists,omitempty"`
Variables []struct {
Encrypted string `json:"encrypted"`
Name string `json:"name"`
Value string `json:"value"`
} `json:"variables,omitempty"`
Metadata []struct {
Persist string `json:"persist"`
Value string `json:"value"`
} `json:"metadata,omitempty"`
}
const (
uriApp = "application"
uriService = "service"
uriSysa = "sys"
)
func (b *BigIP) CreateIapp(p *Iapp) error {
return b.post(p, uriSysa, uriApp, uriService)
}
func (b *BigIP) UpdateIapp(name string, p *Iapp) error {
values := []string{}
values = append(values, "~Common~")
values = append(values, name)
values = append(values, ".app~")
values = append(values, name)
// Join three strings into one.
result := strings.Join(values, "")
fmt.Println(result)
return b.patch(p, uriSysa, uriApp, uriService, result)
}
func (b *BigIP) Iapp(name string) (*Iapp, error) {
var iapp Iapp
log.Println(" Value of iapp before read ", &iapp)
values := []string{}
values = append(values, "~Common~")
values = append(values, name)
values = append(values, ".app~")
values = append(values, name)
// Join three strings into one.
result := strings.Join(values, "")
err, _ := b.getForEntity(&iapp, uriSysa, uriApp, uriService, result)
log.Println(" I am here in sdk with ", err)
if err != nil {
return nil, err
}
log.Println(" Value of iapp after reading ", &iapp)
return &iapp, nil
}
func (b *BigIP) DeleteIapp(name string) error {
values := []string{}
values = append(values, "~Common~")
values = append(values, name)
values = append(values, ".app~")
values = append(values, name)
// Join three strings into one.
result := strings.Join(values, "")
return b.delete(uriSys, uriApp, uriService, result)
}