github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/protocol/keybase1/kbfs_git.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/kbfs_git.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 GcOptions struct { 13 MaxLooseRefs int `codec:"maxLooseRefs" json:"maxLooseRefs"` 14 PruneMinLooseObjects int `codec:"pruneMinLooseObjects" json:"pruneMinLooseObjects"` 15 PruneExpireTime Time `codec:"pruneExpireTime" json:"pruneExpireTime"` 16 MaxObjectPacks int `codec:"maxObjectPacks" json:"maxObjectPacks"` 17 } 18 19 func (o GcOptions) DeepCopy() GcOptions { 20 return GcOptions{ 21 MaxLooseRefs: o.MaxLooseRefs, 22 PruneMinLooseObjects: o.PruneMinLooseObjects, 23 PruneExpireTime: o.PruneExpireTime.DeepCopy(), 24 MaxObjectPacks: o.MaxObjectPacks, 25 } 26 } 27 28 type CreateRepoArg struct { 29 Folder FolderHandle `codec:"folder" json:"folder"` 30 Name GitRepoName `codec:"name" json:"name"` 31 } 32 33 type DeleteRepoArg struct { 34 Folder FolderHandle `codec:"folder" json:"folder"` 35 Name GitRepoName `codec:"name" json:"name"` 36 } 37 38 type GcArg struct { 39 Folder FolderHandle `codec:"folder" json:"folder"` 40 Name GitRepoName `codec:"name" json:"name"` 41 Options GcOptions `codec:"options" json:"options"` 42 } 43 44 type KBFSGitInterface interface { 45 // * createRepo creates a bare empty repo on KBFS under the given name in the given TLF. 46 // * It returns the ID of the repo created. 47 CreateRepo(context.Context, CreateRepoArg) (RepoID, error) 48 // * deleteRepo deletes repo on KBFS under the given name in the given TLF. 49 DeleteRepo(context.Context, DeleteRepoArg) error 50 // * gc runs garbage collection on the given repo, using the given options to 51 // * see whether anything needs to be done. 52 Gc(context.Context, GcArg) error 53 } 54 55 func KBFSGitProtocol(i KBFSGitInterface) rpc.Protocol { 56 return rpc.Protocol{ 57 Name: "keybase.1.KBFSGit", 58 Methods: map[string]rpc.ServeHandlerDescription{ 59 "createRepo": { 60 MakeArg: func() interface{} { 61 var ret [1]CreateRepoArg 62 return &ret 63 }, 64 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 65 typedArgs, ok := args.(*[1]CreateRepoArg) 66 if !ok { 67 err = rpc.NewTypeError((*[1]CreateRepoArg)(nil), args) 68 return 69 } 70 ret, err = i.CreateRepo(ctx, typedArgs[0]) 71 return 72 }, 73 }, 74 "deleteRepo": { 75 MakeArg: func() interface{} { 76 var ret [1]DeleteRepoArg 77 return &ret 78 }, 79 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 80 typedArgs, ok := args.(*[1]DeleteRepoArg) 81 if !ok { 82 err = rpc.NewTypeError((*[1]DeleteRepoArg)(nil), args) 83 return 84 } 85 err = i.DeleteRepo(ctx, typedArgs[0]) 86 return 87 }, 88 }, 89 "gc": { 90 MakeArg: func() interface{} { 91 var ret [1]GcArg 92 return &ret 93 }, 94 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 95 typedArgs, ok := args.(*[1]GcArg) 96 if !ok { 97 err = rpc.NewTypeError((*[1]GcArg)(nil), args) 98 return 99 } 100 err = i.Gc(ctx, typedArgs[0]) 101 return 102 }, 103 }, 104 }, 105 } 106 } 107 108 type KBFSGitClient struct { 109 Cli rpc.GenericClient 110 } 111 112 // * createRepo creates a bare empty repo on KBFS under the given name in the given TLF. 113 // * It returns the ID of the repo created. 114 func (c KBFSGitClient) CreateRepo(ctx context.Context, __arg CreateRepoArg) (res RepoID, err error) { 115 err = c.Cli.Call(ctx, "keybase.1.KBFSGit.createRepo", []interface{}{__arg}, &res, 0*time.Millisecond) 116 return 117 } 118 119 // * deleteRepo deletes repo on KBFS under the given name in the given TLF. 120 func (c KBFSGitClient) DeleteRepo(ctx context.Context, __arg DeleteRepoArg) (err error) { 121 err = c.Cli.Call(ctx, "keybase.1.KBFSGit.deleteRepo", []interface{}{__arg}, nil, 0*time.Millisecond) 122 return 123 } 124 125 // * gc runs garbage collection on the given repo, using the given options to 126 // * see whether anything needs to be done. 127 func (c KBFSGitClient) Gc(ctx context.Context, __arg GcArg) (err error) { 128 err = c.Cli.Call(ctx, "keybase.1.KBFSGit.gc", []interface{}{__arg}, nil, 0*time.Millisecond) 129 return 130 }