github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/protocol/keybase1/tlf.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/tlf.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 CryptKeysArg struct { 13 Query TLFQuery `codec:"query" json:"query"` 14 } 15 16 type PublicCanonicalTLFNameAndIDArg struct { 17 Query TLFQuery `codec:"query" json:"query"` 18 } 19 20 type CompleteAndCanonicalizePrivateTlfNameArg struct { 21 Query TLFQuery `codec:"query" json:"query"` 22 } 23 24 type TlfInterface interface { 25 // CryptKeys returns TLF crypt keys from all generations. 26 CryptKeys(context.Context, TLFQuery) (GetTLFCryptKeysRes, error) 27 // * tlfCanonicalID returns the canonical name and TLFID for tlfName. 28 // * TLFID should not be cached or stored persistently. 29 PublicCanonicalTLFNameAndID(context.Context, TLFQuery) (CanonicalTLFNameAndIDWithBreaks, error) 30 CompleteAndCanonicalizePrivateTlfName(context.Context, TLFQuery) (CanonicalTLFNameAndIDWithBreaks, error) 31 } 32 33 func TlfProtocol(i TlfInterface) rpc.Protocol { 34 return rpc.Protocol{ 35 Name: "keybase.1.tlf", 36 Methods: map[string]rpc.ServeHandlerDescription{ 37 "CryptKeys": { 38 MakeArg: func() interface{} { 39 var ret [1]CryptKeysArg 40 return &ret 41 }, 42 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 43 typedArgs, ok := args.(*[1]CryptKeysArg) 44 if !ok { 45 err = rpc.NewTypeError((*[1]CryptKeysArg)(nil), args) 46 return 47 } 48 ret, err = i.CryptKeys(ctx, typedArgs[0].Query) 49 return 50 }, 51 }, 52 "publicCanonicalTLFNameAndID": { 53 MakeArg: func() interface{} { 54 var ret [1]PublicCanonicalTLFNameAndIDArg 55 return &ret 56 }, 57 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 58 typedArgs, ok := args.(*[1]PublicCanonicalTLFNameAndIDArg) 59 if !ok { 60 err = rpc.NewTypeError((*[1]PublicCanonicalTLFNameAndIDArg)(nil), args) 61 return 62 } 63 ret, err = i.PublicCanonicalTLFNameAndID(ctx, typedArgs[0].Query) 64 return 65 }, 66 }, 67 "completeAndCanonicalizePrivateTlfName": { 68 MakeArg: func() interface{} { 69 var ret [1]CompleteAndCanonicalizePrivateTlfNameArg 70 return &ret 71 }, 72 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 73 typedArgs, ok := args.(*[1]CompleteAndCanonicalizePrivateTlfNameArg) 74 if !ok { 75 err = rpc.NewTypeError((*[1]CompleteAndCanonicalizePrivateTlfNameArg)(nil), args) 76 return 77 } 78 ret, err = i.CompleteAndCanonicalizePrivateTlfName(ctx, typedArgs[0].Query) 79 return 80 }, 81 }, 82 }, 83 } 84 } 85 86 type TlfClient struct { 87 Cli rpc.GenericClient 88 } 89 90 // CryptKeys returns TLF crypt keys from all generations. 91 func (c TlfClient) CryptKeys(ctx context.Context, query TLFQuery) (res GetTLFCryptKeysRes, err error) { 92 __arg := CryptKeysArg{Query: query} 93 err = c.Cli.Call(ctx, "keybase.1.tlf.CryptKeys", []interface{}{__arg}, &res, 0*time.Millisecond) 94 return 95 } 96 97 // * tlfCanonicalID returns the canonical name and TLFID for tlfName. 98 // * TLFID should not be cached or stored persistently. 99 func (c TlfClient) PublicCanonicalTLFNameAndID(ctx context.Context, query TLFQuery) (res CanonicalTLFNameAndIDWithBreaks, err error) { 100 __arg := PublicCanonicalTLFNameAndIDArg{Query: query} 101 err = c.Cli.Call(ctx, "keybase.1.tlf.publicCanonicalTLFNameAndID", []interface{}{__arg}, &res, 0*time.Millisecond) 102 return 103 } 104 105 func (c TlfClient) CompleteAndCanonicalizePrivateTlfName(ctx context.Context, query TLFQuery) (res CanonicalTLFNameAndIDWithBreaks, err error) { 106 __arg := CompleteAndCanonicalizePrivateTlfNameArg{Query: query} 107 err = c.Cli.Call(ctx, "keybase.1.tlf.completeAndCanonicalizePrivateTlfName", []interface{}{__arg}, &res, 0*time.Millisecond) 108 return 109 }