diff --git a/bigip.go b/bigip.go index f98e5be..4c46236 100644 --- a/bigip.go +++ b/bigip.go @@ -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, } @@ -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{ @@ -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 @@ -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 +} diff --git a/ltm.go b/ltm.go index 822630e..c5b4e3b 100644 --- a/ltm.go +++ b/ltm.go @@ -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 @@ -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"` diff --git a/ltm_test.go b/ltm_test.go index 42ea867..0dcaf2c 100644 --- a/ltm_test.go +++ b/ltm_test.go @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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",