github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/protocol/keybase1/bot.go (about) 1 // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler) 2 // Input file: avdl/keybase1/bot.avdl 3 4 package keybase1 5 6 import ( 7 "github.com/keybase/go-framed-msgpack-rpc/rpc" 8 context "golang.org/x/net/context" 9 "time" 10 ) 11 12 type BotToken string 13 14 func (o BotToken) DeepCopy() BotToken { 15 return o 16 } 17 18 type BotTokenInfo struct { 19 Token BotToken `codec:"token" json:"bot_token"` 20 Ctime Time `codec:"ctime" json:"ctime"` 21 } 22 23 func (o BotTokenInfo) DeepCopy() BotTokenInfo { 24 return BotTokenInfo{ 25 Token: o.Token.DeepCopy(), 26 Ctime: o.Ctime.DeepCopy(), 27 } 28 } 29 30 type BotTokenListArg struct { 31 } 32 33 type BotTokenCreateArg struct { 34 } 35 36 type BotTokenDeleteArg struct { 37 Token BotToken `codec:"token" json:"token"` 38 } 39 40 type BotInterface interface { 41 BotTokenList(context.Context) ([]BotTokenInfo, error) 42 BotTokenCreate(context.Context) (BotToken, error) 43 BotTokenDelete(context.Context, BotToken) error 44 } 45 46 func BotProtocol(i BotInterface) rpc.Protocol { 47 return rpc.Protocol{ 48 Name: "keybase.1.bot", 49 Methods: map[string]rpc.ServeHandlerDescription{ 50 "botTokenList": { 51 MakeArg: func() interface{} { 52 var ret [1]BotTokenListArg 53 return &ret 54 }, 55 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 56 ret, err = i.BotTokenList(ctx) 57 return 58 }, 59 }, 60 "botTokenCreate": { 61 MakeArg: func() interface{} { 62 var ret [1]BotTokenCreateArg 63 return &ret 64 }, 65 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 66 ret, err = i.BotTokenCreate(ctx) 67 return 68 }, 69 }, 70 "botTokenDelete": { 71 MakeArg: func() interface{} { 72 var ret [1]BotTokenDeleteArg 73 return &ret 74 }, 75 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 76 typedArgs, ok := args.(*[1]BotTokenDeleteArg) 77 if !ok { 78 err = rpc.NewTypeError((*[1]BotTokenDeleteArg)(nil), args) 79 return 80 } 81 err = i.BotTokenDelete(ctx, typedArgs[0].Token) 82 return 83 }, 84 }, 85 }, 86 } 87 } 88 89 type BotClient struct { 90 Cli rpc.GenericClient 91 } 92 93 func (c BotClient) BotTokenList(ctx context.Context) (res []BotTokenInfo, err error) { 94 err = c.Cli.Call(ctx, "keybase.1.bot.botTokenList", []interface{}{BotTokenListArg{}}, &res, 0*time.Millisecond) 95 return 96 } 97 98 func (c BotClient) BotTokenCreate(ctx context.Context) (res BotToken, err error) { 99 err = c.Cli.Call(ctx, "keybase.1.bot.botTokenCreate", []interface{}{BotTokenCreateArg{}}, &res, 0*time.Millisecond) 100 return 101 } 102 103 func (c BotClient) BotTokenDelete(ctx context.Context, token BotToken) (err error) { 104 __arg := BotTokenDeleteArg{Token: token} 105 err = c.Cli.Call(ctx, "keybase.1.bot.botTokenDelete", []interface{}{__arg}, nil, 0*time.Millisecond) 106 return 107 }