forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.go
99 lines (88 loc) · 2.89 KB
/
update.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Auto-generated by avdl-compiler v1.3.1 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/update.avdl
package keybase1
import (
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
)
// Options for updating.
type UpdateOptions struct {
Version string `codec:"version" json:"version"`
Platform string `codec:"platform" json:"platform"`
DestinationPath string `codec:"destinationPath" json:"destinationPath"`
Source string `codec:"source" json:"source"`
URL string `codec:"URL" json:"URL"`
Channel string `codec:"channel" json:"channel"`
Force bool `codec:"force" json:"force"`
DefaultInstructions string `codec:"defaultInstructions" json:"defaultInstructions"`
SignaturePath string `codec:"signaturePath" json:"signaturePath"`
}
type UpdateResult struct {
Update *Update `codec:"update,omitempty" json:"update,omitempty"`
}
type UpdateArg struct {
Options UpdateOptions `codec:"options" json:"options"`
}
type UpdateCheckArg struct {
Force bool `codec:"force" json:"force"`
}
type UpdateInterface interface {
// Perform the update with options.
Update(context.Context, UpdateOptions) (UpdateResult, error)
// Perform an update check.
UpdateCheck(context.Context, bool) error
}
func UpdateProtocol(i UpdateInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.update",
Methods: map[string]rpc.ServeHandlerDescription{
"update": {
MakeArg: func() interface{} {
ret := make([]UpdateArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]UpdateArg)
if !ok {
err = rpc.NewTypeError((*[]UpdateArg)(nil), args)
return
}
ret, err = i.Update(ctx, (*typedArgs)[0].Options)
return
},
MethodType: rpc.MethodCall,
},
"updateCheck": {
MakeArg: func() interface{} {
ret := make([]UpdateCheckArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]UpdateCheckArg)
if !ok {
err = rpc.NewTypeError((*[]UpdateCheckArg)(nil), args)
return
}
err = i.UpdateCheck(ctx, (*typedArgs)[0].Force)
return
},
MethodType: rpc.MethodCall,
},
},
}
}
type UpdateClient struct {
Cli rpc.GenericClient
}
// Perform the update with options.
func (c UpdateClient) Update(ctx context.Context, options UpdateOptions) (res UpdateResult, err error) {
__arg := UpdateArg{Options: options}
err = c.Cli.Call(ctx, "keybase.1.update.update", []interface{}{__arg}, &res)
return
}
// Perform an update check.
func (c UpdateClient) UpdateCheck(ctx context.Context, force bool) (err error) {
__arg := UpdateCheckArg{Force: force}
err = c.Cli.Call(ctx, "keybase.1.update.updateCheck", []interface{}{__arg}, nil)
return
}