diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..508d569 --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module github.com/f5devcentral/go-bigip + +go 1.20 + +require github.com/stretchr/testify v1.2.1 + +require ( + github.com/davecgh/go-spew v1.1.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..314bd6a --- /dev/null +++ b/go.sum @@ -0,0 +1,6 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.2.1 h1:52QO5WkIUcHGIR7EnGagH88x1bUzqGXTC5/1bDTUQ7U= +github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/ltm.go b/ltm.go index b0e626d..4e57c32 100644 --- a/ltm.go +++ b/ltm.go @@ -1886,12 +1886,21 @@ type HttpCompressionProfile struct { VaryHeader string `json:"varyHeader,omitempty"` } +type CipherRule struct { + Name string `json:"name,omitempty"` + Partition string `json:"partition,omitempty"` + Cipher string `json:"cipher,omitempty"` + DHGroups string `json:"dhGroups,omitempty"` + SignatureAlgorithms string `json:"signatureAlgorithms,omitempty"` +} + const ( uriLtm = "ltm" uriNode = "node" uriPool = "pool" uriPoolMember = "members" uriProfile = "profile" + uriCipher = "cipher" uriServerSSL = "server-ssl" uriClientSSL = "client-ssl" uriVirtual = "virtual" @@ -1928,6 +1937,7 @@ const ( uriSSL = "ssl" uriUniversal = "universal" uriCreateDraft = "?options=create-draft" + uriRule = "rule" ) var cidr = map[string]string{ @@ -3918,3 +3928,82 @@ func (b *BigIP) DeleteHttpCompressionProfile(name string) error { func (b *BigIP) ModifyHttpCompressionProfile(name string, config *HttpCompressionProfile) error { return b.put(config, uriLtm, uriProfile, uriHttpcompress, name) } + +type CipherRuleReq struct { + Name string `json:"name,omitempty"` + Partition string `json:"partition,omitempty"` + FullPath string `json:"fullPath,omitempty"` + Cipher string `json:"cipher,omitempty"` + Description string `json:"description,omitempty"` + DhGroups string `json:"dhGroups,omitempty"` + SignatureAlgorithms string `json:"signatureAlgorithms,omitempty"` +} + +func (b *BigIP) AddLtmCipherRule(config *CipherRuleReq) error { + return b.post(config, uriLtm, uriCipher, "rule") +} + +func (b *BigIP) ModifyLtmCipherRule(name string, config *CipherRuleReq) error { + return b.put(config, uriLtm, uriCipher, "rule", name) +} + +func (b *BigIP) DeleteLtmCipherRule(name string) error { + return b.delete(uriLtm, uriCipher, "rule", name) +} + +func (b *BigIP) GetLtmCipherRule(name string) (*CipherRuleReq, error) { + var cipherRule CipherRuleReq + err, ok := b.getForEntity(&cipherRule, uriLtm, uriCipher, "rule", name) + if err != nil { + return nil, err + } + + if !ok { + return nil, nil + } + return &cipherRule, nil +} + +// +//type PolicyRule struct { +//Name string `json:"name,omitempty"` +//Partition string `json:"partition,omitempty"` +//NameReference struct { +//Link string `json:"link,omitempty"` +//} `json:"nameReference,omitempty"` +//} + +type CipherGroupReq struct { + Name string `json:"name,omitempty"` + Partition string `json:"partition,omitempty"` + FullPath string `json:"fullPath,omitempty"` + Ordering string `json:"ordering,omitempty"` + Allow []interface{} `json:"allow,omitempty"` + Require []interface{} `json:"require,omitempty"` +} + +func (b *BigIP) AddLtmCipherGroup(config *CipherGroupReq) error { + return b.post(config, uriLtm, uriCipher, "group") +} + +func (b *BigIP) ModifyLtmCipherGroup(name string, config *CipherGroupReq) error { + return b.put(config, uriLtm, uriCipher, "group", name) +} + +func (b *BigIP) DeleteLtmCipherGroup(name string) error { + return b.delete(uriLtm, uriCipher, "group", name) +} + +func (b *BigIP) GetLtmCipherGroup(name string) (*CipherGroupReq, error) { + var cipherGroup CipherGroupReq + err, ok := b.getForEntity(&cipherGroup, uriLtm, uriCipher, "group", name) + if err != nil { + return nil, err + } + + if !ok { + return nil, nil + } + + return &cipherGroup, nil +} \ No newline at end of file diff --git a/sys.go b/sys.go index 668b086..b9bfc76 100644 --- a/sys.go +++ b/sys.go @@ -15,6 +15,7 @@ import ( "fmt" "log" "os" + "strconv" //"strings" "time" @@ -809,20 +810,17 @@ func (b *BigIP) StartTransaction() (*Transaction, error) { return transaction, nil } -func (b *BigIP) EndTransaction(tId int64) error { +func (b *BigIP) CommitTransaction(tId int64) error { + b.Transaction = "" commitTransaction := map[string]interface{}{ - "state": "VALIDATING", - "validateOnly": false, - } - payload, err := json.Marshal(commitTransaction) - if err != nil { - return fmt.Errorf("unable create commit transaction payload: %s", err) + "state": "VALIDATING", } - err = b.patch(payload, uriMgmt, uriTm, uriTransaction, string(tId)) + log.Printf("[INFO] Commiting Transaction with TransactionID: %v", tId) + + err := b.patch(commitTransaction, uriMgmt, uriTm, uriTransaction, strconv.Itoa(int(tId))) if err != nil { return fmt.Errorf("%s", err) } - b.Transaction = "" return nil } diff --git a/vendor/modules.txt b/vendor/modules.txt new file mode 100644 index 0000000..295b503 --- /dev/null +++ b/vendor/modules.txt @@ -0,0 +1,11 @@ +# github.com/davecgh/go-spew v1.1.0 +## explicit +github.com/davecgh/go-spew/spew +# github.com/pmezard/go-difflib v1.0.0 +## explicit +github.com/pmezard/go-difflib/difflib +# github.com/stretchr/testify v1.2.1 +## explicit +github.com/stretchr/testify/assert +github.com/stretchr/testify/require +github.com/stretchr/testify/suite