Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redefine TmOptions from array to string #105

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions bigip.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ import (
"time"
)

type BashArgs struct {
Command string `json:"command,omitempty"`
UtilCmdArgs string `json:"utilCmdArgs,omitempty"`
CommandResult string `json:"commandResult,omitempty"`
}

var defaultConfigOptions = &ConfigOptions{
APICallTimeout: 60 * time.Second,
}
Expand Down Expand Up @@ -232,21 +238,32 @@ func (b *BigIP) delete(path ...string) error {
}

func (b *BigIP) post(body interface{}, path ...string) error {
return b.reqWithBody("post", body, path...)
_, err := b.reqWithBody("post", body, path...)
return err
}

func (b *BigIP) postReturn(body, e interface{}, path ...string) error {
data, err := b.reqWithBody("post", body, path...)
if err != nil {
return err
}
return json.Unmarshal(data, e)
}

func (b *BigIP) put(body interface{}, path ...string) error {
return b.reqWithBody("put", body, path...)
_, err := b.reqWithBody("put", body, path...)
return err
}

func (b *BigIP) patch(body interface{}, path ...string) error {
return b.reqWithBody("patch", body, path...)
_, err := b.reqWithBody("patch", body, path...)
return err
}

func (b *BigIP) reqWithBody(method string, body interface{}, path ...string) error {
func (b *BigIP) reqWithBody(method string, body interface{}, path ...string) ([]byte, error) {
marshalJSON, err := jsonMarshal(body)
if err != nil {
return err
return nil, err
}

req := &APIRequest{
Expand All @@ -256,8 +273,7 @@ func (b *BigIP) reqWithBody(method string, body interface{}, path ...string) err
ContentType: "application/json",
}

_, callErr := b.APICall(req)
return callErr
return b.APICall(req)
}

//Get a url and populate an entity. If the entity does not exist (404) then the
Expand Down Expand Up @@ -471,3 +487,13 @@ func (b *BigIP) Upload(r io.Reader, size int64, path ...string) (*Upload, error)
}
}
}

// Exec call tmsh exec command
func (b *BigIP) Exec(args *BashArgs) (*BashArgs, error) {
e := &BashArgs{}
err := b.postReturn(args, e, "util", "bash")
if err != nil {
return nil, err
}
return e, nil
}
82 changes: 41 additions & 41 deletions ltm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,46 @@ type ServerSSLProfiles struct {
// ServerSSLProfile contains information about each server-ssl profile. You can use all
// of these fields when modifying a server-ssl profile.
type ServerSSLProfile struct {
Name string `json:"name,omitempty"`
Partition string `json:"partition,omitempty"`
FullPath string `json:"fullPath,omitempty"`
Generation int `json:"generation,omitempty"`
AlertTimeout string `json:"alertTimeout,omitempty"`
Authenticate string `json:"authenticate,omitempty"`
AuthenticateDepth int `json:"authenticateDepth,omitempty"`
CaFile string `json:"caFile,omitempty"`
CacheSize int `json:"cacheSize,omitempty"`
CacheTimeout int `json:"cacheTimeout,omitempty"`
Cert string `json:"cert,omitempty"`
Chain string `json:"chain,omitempty"`
Ciphers string `json:"ciphers,omitempty"`
DefaultsFrom string `json:"defaultsFrom,omitempty"`
ExpireCertResponseControl string `json:"expireCertResponseControl,omitempty"`
GenericAlert string `json:"genericAlert,omitempty"`
HandshakeTimeout string `json:"handshakeTimeout,omitempty"`
Key string `json:"key,omitempty"`
ModSslMethods string `json:"modSslMethods,omitempty"`
Mode string `json:"mode,omitempty"`
TmOptions []string `json:"tmOptions,omitempty"`
Passphrase string `json:"passphrase,omitempty"`
PeerCertMode string `json:"peerCertMode,omitempty"`
ProxySsl string `json:"proxySsl,omitempty"`
RenegotiatePeriod string `json:"renegotiatePeriod,omitempty"`
RenegotiateSize string `json:"renegotiateSize,omitempty"`
Renegotiation string `json:"renegotiation,omitempty"`
RetainCertificate string `json:"retainCertificate,omitempty"`
SecureRenegotiation string `json:"secureRenegotiation,omitempty"`
ServerName string `json:"serverName,omitempty"`
SessionMirroring string `json:"sessionMirroring,omitempty"`
SessionTicket string `json:"sessionTicket,omitempty"`
SniDefault string `json:"sniDefault,omitempty"`
SniRequire string `json:"sniRequire,omitempty"`
SslForwardProxy string `json:"sslForwardProxy,omitempty"`
SslForwardProxyBypass string `json:"sslForwardProxyBypass,omitempty"`
SslSignHash string `json:"sslSignHash,omitempty"`
StrictResume string `json:"strictResume,omitempty"`
UncleanShutdown string `json:"uncleanShutdown,omitempty"`
UntrustedCertResponseControl string `json:"untrustedCertResponseControl,omitempty"`
Name string `json:"name,omitempty"`
Partition string `json:"partition,omitempty"`
FullPath string `json:"fullPath,omitempty"`
Generation int `json:"generation,omitempty"`
AlertTimeout string `json:"alertTimeout,omitempty"`
Authenticate string `json:"authenticate,omitempty"`
AuthenticateDepth int `json:"authenticateDepth,omitempty"`
CaFile string `json:"caFile,omitempty"`
CacheSize int `json:"cacheSize,omitempty"`
CacheTimeout int `json:"cacheTimeout,omitempty"`
Cert string `json:"cert,omitempty"`
Chain string `json:"chain,omitempty"`
Ciphers string `json:"ciphers,omitempty"`
DefaultsFrom string `json:"defaultsFrom,omitempty"`
ExpireCertResponseControl string `json:"expireCertResponseControl,omitempty"`
GenericAlert string `json:"genericAlert,omitempty"`
HandshakeTimeout string `json:"handshakeTimeout,omitempty"`
Key string `json:"key,omitempty"`
ModSslMethods string `json:"modSslMethods,omitempty"`
Mode string `json:"mode,omitempty"`
TmOptions string `json:"tmOptions,omitempty"`
Passphrase string `json:"passphrase,omitempty"`
PeerCertMode string `json:"peerCertMode,omitempty"`
ProxySsl string `json:"proxySsl,omitempty"`
RenegotiatePeriod string `json:"renegotiatePeriod,omitempty"`
RenegotiateSize string `json:"renegotiateSize,omitempty"`
Renegotiation string `json:"renegotiation,omitempty"`
RetainCertificate string `json:"retainCertificate,omitempty"`
SecureRenegotiation string `json:"secureRenegotiation,omitempty"`
ServerName string `json:"serverName,omitempty"`
SessionMirroring string `json:"sessionMirroring,omitempty"`
SessionTicket string `json:"sessionTicket,omitempty"`
SniDefault string `json:"sniDefault,omitempty"`
SniRequire string `json:"sniRequire,omitempty"`
SslForwardProxy string `json:"sslForwardProxy,omitempty"`
SslForwardProxyBypass string `json:"sslForwardProxyBypass,omitempty"`
SslSignHash string `json:"sslSignHash,omitempty"`
StrictResume string `json:"strictResume,omitempty"`
UncleanShutdown string `json:"uncleanShutdown,omitempty"`
UntrustedCertResponseControl string `json:"untrustedCertResponseControl,omitempty"`
}

// ClientSSLProfiles
Expand Down Expand Up @@ -104,7 +104,7 @@ type ClientSSLProfile struct {
Key string `json:"key,omitempty"`
ModSslMethods string `json:"modSslMethods,omitempty"`
Mode string `json:"mode,omitempty"`
TmOptions []string `json:"tmOptions,omitempty"`
TmOptions string `json:"tmOptions,omitempty"`
Passphrase string `json:"passphrase,omitempty"`
PeerCertMode string `json:"peerCertMode,omitempty"`
ProxyCaCert string `json:"proxyCaCert,omitempty"`
Expand Down
28 changes: 7 additions & 21 deletions ltm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1502,9 +1502,7 @@ func (s *LTMTestSuite) TestServerSSLProfiles() {
"key": "/Common/default.key",
"modSslMethods": "disabled",
"mode": "enabled",
"tmOptions": [
"dont-insert-empty-fragments"
],
"tmOptions": "{ dont-insert-empty-fragments }",
"peerCertMode": "ignore",
"proxySsl": "disabled",
"renegotiatePeriod": "indefinite",
Expand Down Expand Up @@ -1540,9 +1538,7 @@ func (s *LTMTestSuite) TestServerSSLProfiles() {
"handshakeTimeout": "10",
"modSslMethods": "disabled",
"mode": "enabled",
"tmOptions": [
"dont-insert-empty-fragments"
],
"tmOptions": "{ dont-insert-empty-fragments }",
"peerCertMode": "ignore",
"proxySsl": "disabled",
"renegotiatePeriod": "indefinite",
Expand Down Expand Up @@ -1578,9 +1574,7 @@ func (s *LTMTestSuite) TestServerSSLProfiles() {
"handshakeTimeout": "10",
"modSslMethods": "disabled",
"mode": "enabled",
"tmOptions": [
"dont-insert-empty-fragments"
],
"tmOptions": "{ dont-insert-empty-fragments }",
"peerCertMode": "ignore",
"proxySsl": "disabled",
"renegotiatePeriod": "indefinite",
Expand Down Expand Up @@ -1671,9 +1665,7 @@ func (s *LTMTestSuite) TestClientSSLProfiles() {
"key": "/Common/default.key",
"modSslMethods": "disabled",
"mode": "enabled",
"tmOptions": [
"dont-insert-empty-fragments"
],
"tmOptions": "{ dont-insert-empty-fragments }",
"peerCertMode": "ignore",
"proxySsl": "disabled",
"renegotiateMaxRecordDelay": "indefinite",
Expand Down Expand Up @@ -1724,9 +1716,7 @@ func (s *LTMTestSuite) TestClientSSLProfiles() {
"key": "/Common/default.key",
"modSslMethods": "disabled",
"mode": "enabled",
"tmOptions": [
"dont-insert-empty-fragments"
],
"tmOptions": "{ dont-insert-empty-fragments }",
"peerCertMode": "ignore",
"proxySsl": "disabled",
"renegotiateMaxRecordDelay": "indefinite",
Expand Down Expand Up @@ -1775,9 +1765,7 @@ func (s *LTMTestSuite) TestClientSSLProfiles() {
"inheritCertkeychain": "false",
"modSslMethods": "disabled",
"mode": "enabled",
"tmOptions": [
"dont-insert-empty-fragments"
],
"tmOptions": "{ dont-insert-empty-fragments }",
"peerCertMode": "ignore",
"proxySsl": "disabled",
"renegotiateMaxRecordDelay": "indefinite",
Expand Down Expand Up @@ -1826,9 +1814,7 @@ func (s *LTMTestSuite) TestClientSSLProfiles() {
"key": "/Common/default.key",
"modSslMethods": "disabled",
"mode": "enabled",
"tmOptions": [
"dont-insert-empty-fragments"
],
"tmOptions": "{ dont-insert-empty-fragments }",
"peerCertMode": "ignore",
"proxySsl": "disabled",
"renegotiateMaxRecordDelay": "indefinite",
Expand Down