diff options
author | Shobhit Gupta <smartyshobhit@gmail.com> | 2018-10-03 13:04:37 -0700 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-10-03 16:04:37 -0400 |
commit | 8c03e584c182218c84bebc8af23c70fb0cd203d4 (patch) | |
tree | 90cad75d922dc3d9fb25c4456b342b2b4e642d3b /plugin | |
parent | 7468f35cb0c86b60f66e1c9228a60da244d3fcc4 (diff) | |
download | chat-8c03e584c182218c84bebc8af23c70fb0cd203d4.tar.gz chat-8c03e584c182218c84bebc8af23c70fb0cd203d4.tar.bz2 chat-8c03e584c182218c84bebc8af23c70fb0cd203d4.zip |
MM-11863 Add KVList method (#9467)
* Add KVList method
* Add KVList method
Add KVList method
* Add pagination support
* Change offset, limit to page, perPage
* Rename constant
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/api.go | 3 | ||||
-rw-r--r-- | plugin/client_rpc_generated.go | 30 | ||||
-rw-r--r-- | plugin/plugintest/api.go | 25 |
3 files changed, 58 insertions, 0 deletions
diff --git a/plugin/api.go b/plugin/api.go index c4230860f..b85160940 100644 --- a/plugin/api.go +++ b/plugin/api.go @@ -196,6 +196,9 @@ type API interface { // KVDelete will remove a key-value pair. Returns nil for non-existent keys. KVDelete(key string) *model.AppError + // KVList will list all keys for a plugin. + KVList(page, perPage int) ([]string, *model.AppError) + // PublishWebSocketEvent sends an event to WebSocket connections. // event is the type and will be prepended with "custom_<pluginid>_" // payload is the data sent with the event. Interface values must be primitive Go types or mattermost-server/model types diff --git a/plugin/client_rpc_generated.go b/plugin/client_rpc_generated.go index 6780eedf6..d4faaf502 100644 --- a/plugin/client_rpc_generated.go +++ b/plugin/client_rpc_generated.go @@ -2151,6 +2151,36 @@ func (s *apiRPCServer) KVDelete(args *Z_KVDeleteArgs, returns *Z_KVDeleteReturns return nil } +type Z_KVListArgs struct { + A int + B int +} + +type Z_KVListReturns struct { + A []string + B *model.AppError +} + +func (g *apiRPCClient) KVList(page, perPage int) ([]string, *model.AppError) { + _args := &Z_KVListArgs{page, perPage} + _returns := &Z_KVListReturns{} + if err := g.client.Call("Plugin.KVList", _args, _returns); err != nil { + log.Printf("RPC call to KVList API failed: %s", err.Error()) + } + return _returns.A, _returns.B +} + +func (s *apiRPCServer) KVList(args *Z_KVListArgs, returns *Z_KVListReturns) error { + if hook, ok := s.impl.(interface { + KVList(page, perPage int) ([]string, *model.AppError) + }); ok { + returns.A, returns.B = hook.KVList(args.A, args.B) + } else { + return encodableError(fmt.Errorf("API KVList called but not implemented.")) + } + return nil +} + type Z_PublishWebSocketEventArgs struct { A string B map[string]interface{} diff --git a/plugin/plugintest/api.go b/plugin/plugintest/api.go index 531a0be4f..64189ee23 100644 --- a/plugin/plugintest/api.go +++ b/plugin/plugintest/api.go @@ -996,6 +996,31 @@ func (_m *API) KVGet(key string) ([]byte, *model.AppError) { return r0, r1 } +// KVList provides a mock function with given fields: page, perPage +func (_m *API) KVList(page int, perPage int) ([]string, *model.AppError) { + ret := _m.Called(page, perPage) + + var r0 []string + if rf, ok := ret.Get(0).(func(int, int) []string); ok { + r0 = rf(page, perPage) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + var r1 *model.AppError + if rf, ok := ret.Get(1).(func(int, int) *model.AppError); ok { + r1 = rf(page, perPage) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.AppError) + } + } + + return r0, r1 +} + // KVSet provides a mock function with given fields: key, value func (_m *API) KVSet(key string, value []byte) *model.AppError { ret := _m.Called(key, value) |