github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/keybase1/gregor.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/gregor.avdl 3 4 package keybase1 5 6 import ( 7 gregor1 "github.com/keybase/client/go/protocol/gregor1" 8 "github.com/keybase/go-framed-msgpack-rpc/rpc" 9 context "golang.org/x/net/context" 10 "time" 11 ) 12 13 type GetStateArg struct { 14 } 15 16 type InjectItemArg struct { 17 Cat string `codec:"cat" json:"cat"` 18 Body string `codec:"body" json:"body"` 19 Dtime gregor1.TimeOrOffset `codec:"dtime" json:"dtime"` 20 } 21 22 type DismissCategoryArg struct { 23 Category gregor1.Category `codec:"category" json:"category"` 24 } 25 26 type DismissItemArg struct { 27 Id gregor1.MsgID `codec:"id" json:"id"` 28 } 29 30 type UpdateItemArg struct { 31 MsgID gregor1.MsgID `codec:"msgID" json:"msgID"` 32 Cat string `codec:"cat" json:"cat"` 33 Body string `codec:"body" json:"body"` 34 Dtime gregor1.TimeOrOffset `codec:"dtime" json:"dtime"` 35 } 36 37 type UpdateCategoryArg struct { 38 Category string `codec:"category" json:"category"` 39 Body string `codec:"body" json:"body"` 40 Dtime gregor1.TimeOrOffset `codec:"dtime" json:"dtime"` 41 } 42 43 type GregorInterface interface { 44 GetState(context.Context) (gregor1.State, error) 45 InjectItem(context.Context, InjectItemArg) (gregor1.MsgID, error) 46 DismissCategory(context.Context, gregor1.Category) error 47 DismissItem(context.Context, gregor1.MsgID) error 48 UpdateItem(context.Context, UpdateItemArg) (gregor1.MsgID, error) 49 UpdateCategory(context.Context, UpdateCategoryArg) (gregor1.MsgID, error) 50 } 51 52 func GregorProtocol(i GregorInterface) rpc.Protocol { 53 return rpc.Protocol{ 54 Name: "keybase.1.gregor", 55 Methods: map[string]rpc.ServeHandlerDescription{ 56 "getState": { 57 MakeArg: func() interface{} { 58 var ret [1]GetStateArg 59 return &ret 60 }, 61 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 62 ret, err = i.GetState(ctx) 63 return 64 }, 65 }, 66 "injectItem": { 67 MakeArg: func() interface{} { 68 var ret [1]InjectItemArg 69 return &ret 70 }, 71 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 72 typedArgs, ok := args.(*[1]InjectItemArg) 73 if !ok { 74 err = rpc.NewTypeError((*[1]InjectItemArg)(nil), args) 75 return 76 } 77 ret, err = i.InjectItem(ctx, typedArgs[0]) 78 return 79 }, 80 }, 81 "dismissCategory": { 82 MakeArg: func() interface{} { 83 var ret [1]DismissCategoryArg 84 return &ret 85 }, 86 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 87 typedArgs, ok := args.(*[1]DismissCategoryArg) 88 if !ok { 89 err = rpc.NewTypeError((*[1]DismissCategoryArg)(nil), args) 90 return 91 } 92 err = i.DismissCategory(ctx, typedArgs[0].Category) 93 return 94 }, 95 }, 96 "dismissItem": { 97 MakeArg: func() interface{} { 98 var ret [1]DismissItemArg 99 return &ret 100 }, 101 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 102 typedArgs, ok := args.(*[1]DismissItemArg) 103 if !ok { 104 err = rpc.NewTypeError((*[1]DismissItemArg)(nil), args) 105 return 106 } 107 err = i.DismissItem(ctx, typedArgs[0].Id) 108 return 109 }, 110 }, 111 "updateItem": { 112 MakeArg: func() interface{} { 113 var ret [1]UpdateItemArg 114 return &ret 115 }, 116 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 117 typedArgs, ok := args.(*[1]UpdateItemArg) 118 if !ok { 119 err = rpc.NewTypeError((*[1]UpdateItemArg)(nil), args) 120 return 121 } 122 ret, err = i.UpdateItem(ctx, typedArgs[0]) 123 return 124 }, 125 }, 126 "updateCategory": { 127 MakeArg: func() interface{} { 128 var ret [1]UpdateCategoryArg 129 return &ret 130 }, 131 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 132 typedArgs, ok := args.(*[1]UpdateCategoryArg) 133 if !ok { 134 err = rpc.NewTypeError((*[1]UpdateCategoryArg)(nil), args) 135 return 136 } 137 ret, err = i.UpdateCategory(ctx, typedArgs[0]) 138 return 139 }, 140 }, 141 }, 142 } 143 } 144 145 type GregorClient struct { 146 Cli rpc.GenericClient 147 } 148 149 func (c GregorClient) GetState(ctx context.Context) (res gregor1.State, err error) { 150 err = c.Cli.Call(ctx, "keybase.1.gregor.getState", []interface{}{GetStateArg{}}, &res, 0*time.Millisecond) 151 return 152 } 153 154 func (c GregorClient) InjectItem(ctx context.Context, __arg InjectItemArg) (res gregor1.MsgID, err error) { 155 err = c.Cli.Call(ctx, "keybase.1.gregor.injectItem", []interface{}{__arg}, &res, 0*time.Millisecond) 156 return 157 } 158 159 func (c GregorClient) DismissCategory(ctx context.Context, category gregor1.Category) (err error) { 160 __arg := DismissCategoryArg{Category: category} 161 err = c.Cli.Call(ctx, "keybase.1.gregor.dismissCategory", []interface{}{__arg}, nil, 0*time.Millisecond) 162 return 163 } 164 165 func (c GregorClient) DismissItem(ctx context.Context, id gregor1.MsgID) (err error) { 166 __arg := DismissItemArg{Id: id} 167 err = c.Cli.Call(ctx, "keybase.1.gregor.dismissItem", []interface{}{__arg}, nil, 0*time.Millisecond) 168 return 169 } 170 171 func (c GregorClient) UpdateItem(ctx context.Context, __arg UpdateItemArg) (res gregor1.MsgID, err error) { 172 err = c.Cli.Call(ctx, "keybase.1.gregor.updateItem", []interface{}{__arg}, &res, 0*time.Millisecond) 173 return 174 } 175 176 func (c GregorClient) UpdateCategory(ctx context.Context, __arg UpdateCategoryArg) (res gregor1.MsgID, err error) { 177 err = c.Cli.Call(ctx, "keybase.1.gregor.updateCategory", []interface{}{__arg}, &res, 0*time.Millisecond) 178 return 179 }