github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/protocol/keybase1/ctl.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/ctl.avdl
     3  
     4  package keybase1
     5  
     6  import (
     7  	"fmt"
     8  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
     9  	context "golang.org/x/net/context"
    10  	"time"
    11  )
    12  
    13  type ExitCode int
    14  
    15  const (
    16  	ExitCode_OK      ExitCode = 0
    17  	ExitCode_NOTOK   ExitCode = 2
    18  	ExitCode_RESTART ExitCode = 4
    19  )
    20  
    21  func (o ExitCode) DeepCopy() ExitCode { return o }
    22  
    23  var ExitCodeMap = map[string]ExitCode{
    24  	"OK":      0,
    25  	"NOTOK":   2,
    26  	"RESTART": 4,
    27  }
    28  
    29  var ExitCodeRevMap = map[ExitCode]string{
    30  	0: "OK",
    31  	2: "NOTOK",
    32  	4: "RESTART",
    33  }
    34  
    35  func (e ExitCode) String() string {
    36  	if v, ok := ExitCodeRevMap[e]; ok {
    37  		return v
    38  	}
    39  	return fmt.Sprintf("%v", int(e))
    40  }
    41  
    42  type DbType int
    43  
    44  const (
    45  	DbType_MAIN                     DbType = 0
    46  	DbType_CHAT                     DbType = 1
    47  	DbType_FS_BLOCK_CACHE           DbType = 2
    48  	DbType_FS_BLOCK_CACHE_META      DbType = 3
    49  	DbType_FS_SYNC_BLOCK_CACHE      DbType = 4
    50  	DbType_FS_SYNC_BLOCK_CACHE_META DbType = 5
    51  )
    52  
    53  func (o DbType) DeepCopy() DbType { return o }
    54  
    55  var DbTypeMap = map[string]DbType{
    56  	"MAIN":                     0,
    57  	"CHAT":                     1,
    58  	"FS_BLOCK_CACHE":           2,
    59  	"FS_BLOCK_CACHE_META":      3,
    60  	"FS_SYNC_BLOCK_CACHE":      4,
    61  	"FS_SYNC_BLOCK_CACHE_META": 5,
    62  }
    63  
    64  var DbTypeRevMap = map[DbType]string{
    65  	0: "MAIN",
    66  	1: "CHAT",
    67  	2: "FS_BLOCK_CACHE",
    68  	3: "FS_BLOCK_CACHE_META",
    69  	4: "FS_SYNC_BLOCK_CACHE",
    70  	5: "FS_SYNC_BLOCK_CACHE_META",
    71  }
    72  
    73  func (e DbType) String() string {
    74  	if v, ok := DbTypeRevMap[e]; ok {
    75  		return v
    76  	}
    77  	return fmt.Sprintf("%v", int(e))
    78  }
    79  
    80  type DbKey struct {
    81  	DbType  DbType `codec:"dbType" json:"dbType"`
    82  	ObjType int    `codec:"objType" json:"objType"`
    83  	Key     string `codec:"key" json:"key"`
    84  }
    85  
    86  func (o DbKey) DeepCopy() DbKey {
    87  	return DbKey{
    88  		DbType:  o.DbType.DeepCopy(),
    89  		ObjType: o.ObjType,
    90  		Key:     o.Key,
    91  	}
    92  }
    93  
    94  type DbValue []byte
    95  
    96  func (o DbValue) DeepCopy() DbValue {
    97  	return (func(x []byte) []byte {
    98  		if x == nil {
    99  			return nil
   100  		}
   101  		return append([]byte{}, x...)
   102  	})(o)
   103  }
   104  
   105  type OnLoginStartupStatus int
   106  
   107  const (
   108  	OnLoginStartupStatus_UNKNOWN  OnLoginStartupStatus = 0
   109  	OnLoginStartupStatus_DISABLED OnLoginStartupStatus = 1
   110  	OnLoginStartupStatus_ENABLED  OnLoginStartupStatus = 2
   111  )
   112  
   113  func (o OnLoginStartupStatus) DeepCopy() OnLoginStartupStatus { return o }
   114  
   115  var OnLoginStartupStatusMap = map[string]OnLoginStartupStatus{
   116  	"UNKNOWN":  0,
   117  	"DISABLED": 1,
   118  	"ENABLED":  2,
   119  }
   120  
   121  var OnLoginStartupStatusRevMap = map[OnLoginStartupStatus]string{
   122  	0: "UNKNOWN",
   123  	1: "DISABLED",
   124  	2: "ENABLED",
   125  }
   126  
   127  func (e OnLoginStartupStatus) String() string {
   128  	if v, ok := OnLoginStartupStatusRevMap[e]; ok {
   129  		return v
   130  	}
   131  	return fmt.Sprintf("%v", int(e))
   132  }
   133  
   134  type StopArg struct {
   135  	SessionID int      `codec:"sessionID" json:"sessionID"`
   136  	ExitCode  ExitCode `codec:"exitCode" json:"exitCode"`
   137  }
   138  
   139  type StopServiceArg struct {
   140  	SessionID int      `codec:"sessionID" json:"sessionID"`
   141  	ExitCode  ExitCode `codec:"exitCode" json:"exitCode"`
   142  }
   143  
   144  type LogRotateArg struct {
   145  	SessionID int `codec:"sessionID" json:"sessionID"`
   146  }
   147  
   148  type ReloadArg struct {
   149  	SessionID int `codec:"sessionID" json:"sessionID"`
   150  }
   151  
   152  type DbNukeArg struct {
   153  	SessionID int `codec:"sessionID" json:"sessionID"`
   154  }
   155  
   156  type DbCleanArg struct {
   157  	SessionID int    `codec:"sessionID" json:"sessionID"`
   158  	Force     bool   `codec:"force" json:"force"`
   159  	DbType    DbType `codec:"dbType" json:"dbType"`
   160  }
   161  
   162  type AppExitArg struct {
   163  	SessionID int `codec:"sessionID" json:"sessionID"`
   164  }
   165  
   166  type DbDeleteArg struct {
   167  	SessionID int   `codec:"sessionID" json:"sessionID"`
   168  	Key       DbKey `codec:"key" json:"key"`
   169  }
   170  
   171  type DbPutArg struct {
   172  	SessionID int     `codec:"sessionID" json:"sessionID"`
   173  	Key       DbKey   `codec:"key" json:"key"`
   174  	Value     DbValue `codec:"value" json:"value"`
   175  }
   176  
   177  type DbGetArg struct {
   178  	SessionID int   `codec:"sessionID" json:"sessionID"`
   179  	Key       DbKey `codec:"key" json:"key"`
   180  }
   181  
   182  type DbKeysWithPrefixesArg struct {
   183  	SessionID int   `codec:"sessionID" json:"sessionID"`
   184  	Prefix    DbKey `codec:"prefix" json:"prefix"`
   185  }
   186  
   187  type SetOnLoginStartupArg struct {
   188  	Enabled bool `codec:"enabled" json:"enabled"`
   189  }
   190  
   191  type GetOnLoginStartupArg struct {
   192  }
   193  
   194  type CtlInterface interface {
   195  	Stop(context.Context, StopArg) error
   196  	StopService(context.Context, StopServiceArg) error
   197  	LogRotate(context.Context, int) error
   198  	Reload(context.Context, int) error
   199  	DbNuke(context.Context, int) error
   200  	DbClean(context.Context, DbCleanArg) error
   201  	AppExit(context.Context, int) error
   202  	DbDelete(context.Context, DbDeleteArg) error
   203  	DbPut(context.Context, DbPutArg) error
   204  	DbGet(context.Context, DbGetArg) (*DbValue, error)
   205  	DbKeysWithPrefixes(context.Context, DbKeysWithPrefixesArg) ([]DbKey, error)
   206  	SetOnLoginStartup(context.Context, bool) error
   207  	GetOnLoginStartup(context.Context) (OnLoginStartupStatus, error)
   208  }
   209  
   210  func CtlProtocol(i CtlInterface) rpc.Protocol {
   211  	return rpc.Protocol{
   212  		Name: "keybase.1.ctl",
   213  		Methods: map[string]rpc.ServeHandlerDescription{
   214  			"stop": {
   215  				MakeArg: func() interface{} {
   216  					var ret [1]StopArg
   217  					return &ret
   218  				},
   219  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   220  					typedArgs, ok := args.(*[1]StopArg)
   221  					if !ok {
   222  						err = rpc.NewTypeError((*[1]StopArg)(nil), args)
   223  						return
   224  					}
   225  					err = i.Stop(ctx, typedArgs[0])
   226  					return
   227  				},
   228  			},
   229  			"stopService": {
   230  				MakeArg: func() interface{} {
   231  					var ret [1]StopServiceArg
   232  					return &ret
   233  				},
   234  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   235  					typedArgs, ok := args.(*[1]StopServiceArg)
   236  					if !ok {
   237  						err = rpc.NewTypeError((*[1]StopServiceArg)(nil), args)
   238  						return
   239  					}
   240  					err = i.StopService(ctx, typedArgs[0])
   241  					return
   242  				},
   243  			},
   244  			"logRotate": {
   245  				MakeArg: func() interface{} {
   246  					var ret [1]LogRotateArg
   247  					return &ret
   248  				},
   249  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   250  					typedArgs, ok := args.(*[1]LogRotateArg)
   251  					if !ok {
   252  						err = rpc.NewTypeError((*[1]LogRotateArg)(nil), args)
   253  						return
   254  					}
   255  					err = i.LogRotate(ctx, typedArgs[0].SessionID)
   256  					return
   257  				},
   258  			},
   259  			"reload": {
   260  				MakeArg: func() interface{} {
   261  					var ret [1]ReloadArg
   262  					return &ret
   263  				},
   264  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   265  					typedArgs, ok := args.(*[1]ReloadArg)
   266  					if !ok {
   267  						err = rpc.NewTypeError((*[1]ReloadArg)(nil), args)
   268  						return
   269  					}
   270  					err = i.Reload(ctx, typedArgs[0].SessionID)
   271  					return
   272  				},
   273  			},
   274  			"dbNuke": {
   275  				MakeArg: func() interface{} {
   276  					var ret [1]DbNukeArg
   277  					return &ret
   278  				},
   279  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   280  					typedArgs, ok := args.(*[1]DbNukeArg)
   281  					if !ok {
   282  						err = rpc.NewTypeError((*[1]DbNukeArg)(nil), args)
   283  						return
   284  					}
   285  					err = i.DbNuke(ctx, typedArgs[0].SessionID)
   286  					return
   287  				},
   288  			},
   289  			"dbClean": {
   290  				MakeArg: func() interface{} {
   291  					var ret [1]DbCleanArg
   292  					return &ret
   293  				},
   294  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   295  					typedArgs, ok := args.(*[1]DbCleanArg)
   296  					if !ok {
   297  						err = rpc.NewTypeError((*[1]DbCleanArg)(nil), args)
   298  						return
   299  					}
   300  					err = i.DbClean(ctx, typedArgs[0])
   301  					return
   302  				},
   303  			},
   304  			"appExit": {
   305  				MakeArg: func() interface{} {
   306  					var ret [1]AppExitArg
   307  					return &ret
   308  				},
   309  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   310  					typedArgs, ok := args.(*[1]AppExitArg)
   311  					if !ok {
   312  						err = rpc.NewTypeError((*[1]AppExitArg)(nil), args)
   313  						return
   314  					}
   315  					err = i.AppExit(ctx, typedArgs[0].SessionID)
   316  					return
   317  				},
   318  			},
   319  			"dbDelete": {
   320  				MakeArg: func() interface{} {
   321  					var ret [1]DbDeleteArg
   322  					return &ret
   323  				},
   324  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   325  					typedArgs, ok := args.(*[1]DbDeleteArg)
   326  					if !ok {
   327  						err = rpc.NewTypeError((*[1]DbDeleteArg)(nil), args)
   328  						return
   329  					}
   330  					err = i.DbDelete(ctx, typedArgs[0])
   331  					return
   332  				},
   333  			},
   334  			"dbPut": {
   335  				MakeArg: func() interface{} {
   336  					var ret [1]DbPutArg
   337  					return &ret
   338  				},
   339  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   340  					typedArgs, ok := args.(*[1]DbPutArg)
   341  					if !ok {
   342  						err = rpc.NewTypeError((*[1]DbPutArg)(nil), args)
   343  						return
   344  					}
   345  					err = i.DbPut(ctx, typedArgs[0])
   346  					return
   347  				},
   348  			},
   349  			"dbGet": {
   350  				MakeArg: func() interface{} {
   351  					var ret [1]DbGetArg
   352  					return &ret
   353  				},
   354  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   355  					typedArgs, ok := args.(*[1]DbGetArg)
   356  					if !ok {
   357  						err = rpc.NewTypeError((*[1]DbGetArg)(nil), args)
   358  						return
   359  					}
   360  					ret, err = i.DbGet(ctx, typedArgs[0])
   361  					return
   362  				},
   363  			},
   364  			"dbKeysWithPrefixes": {
   365  				MakeArg: func() interface{} {
   366  					var ret [1]DbKeysWithPrefixesArg
   367  					return &ret
   368  				},
   369  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   370  					typedArgs, ok := args.(*[1]DbKeysWithPrefixesArg)
   371  					if !ok {
   372  						err = rpc.NewTypeError((*[1]DbKeysWithPrefixesArg)(nil), args)
   373  						return
   374  					}
   375  					ret, err = i.DbKeysWithPrefixes(ctx, typedArgs[0])
   376  					return
   377  				},
   378  			},
   379  			"setOnLoginStartup": {
   380  				MakeArg: func() interface{} {
   381  					var ret [1]SetOnLoginStartupArg
   382  					return &ret
   383  				},
   384  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   385  					typedArgs, ok := args.(*[1]SetOnLoginStartupArg)
   386  					if !ok {
   387  						err = rpc.NewTypeError((*[1]SetOnLoginStartupArg)(nil), args)
   388  						return
   389  					}
   390  					err = i.SetOnLoginStartup(ctx, typedArgs[0].Enabled)
   391  					return
   392  				},
   393  			},
   394  			"getOnLoginStartup": {
   395  				MakeArg: func() interface{} {
   396  					var ret [1]GetOnLoginStartupArg
   397  					return &ret
   398  				},
   399  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   400  					ret, err = i.GetOnLoginStartup(ctx)
   401  					return
   402  				},
   403  			},
   404  		},
   405  	}
   406  }
   407  
   408  type CtlClient struct {
   409  	Cli rpc.GenericClient
   410  }
   411  
   412  func (c CtlClient) Stop(ctx context.Context, __arg StopArg) (err error) {
   413  	err = c.Cli.Call(ctx, "keybase.1.ctl.stop", []interface{}{__arg}, nil, 0*time.Millisecond)
   414  	return
   415  }
   416  
   417  func (c CtlClient) StopService(ctx context.Context, __arg StopServiceArg) (err error) {
   418  	err = c.Cli.Call(ctx, "keybase.1.ctl.stopService", []interface{}{__arg}, nil, 0*time.Millisecond)
   419  	return
   420  }
   421  
   422  func (c CtlClient) LogRotate(ctx context.Context, sessionID int) (err error) {
   423  	__arg := LogRotateArg{SessionID: sessionID}
   424  	err = c.Cli.Call(ctx, "keybase.1.ctl.logRotate", []interface{}{__arg}, nil, 0*time.Millisecond)
   425  	return
   426  }
   427  
   428  func (c CtlClient) Reload(ctx context.Context, sessionID int) (err error) {
   429  	__arg := ReloadArg{SessionID: sessionID}
   430  	err = c.Cli.Call(ctx, "keybase.1.ctl.reload", []interface{}{__arg}, nil, 0*time.Millisecond)
   431  	return
   432  }
   433  
   434  func (c CtlClient) DbNuke(ctx context.Context, sessionID int) (err error) {
   435  	__arg := DbNukeArg{SessionID: sessionID}
   436  	err = c.Cli.Call(ctx, "keybase.1.ctl.dbNuke", []interface{}{__arg}, nil, 0*time.Millisecond)
   437  	return
   438  }
   439  
   440  func (c CtlClient) DbClean(ctx context.Context, __arg DbCleanArg) (err error) {
   441  	err = c.Cli.Call(ctx, "keybase.1.ctl.dbClean", []interface{}{__arg}, nil, 0*time.Millisecond)
   442  	return
   443  }
   444  
   445  func (c CtlClient) AppExit(ctx context.Context, sessionID int) (err error) {
   446  	__arg := AppExitArg{SessionID: sessionID}
   447  	err = c.Cli.Call(ctx, "keybase.1.ctl.appExit", []interface{}{__arg}, nil, 0*time.Millisecond)
   448  	return
   449  }
   450  
   451  func (c CtlClient) DbDelete(ctx context.Context, __arg DbDeleteArg) (err error) {
   452  	err = c.Cli.Call(ctx, "keybase.1.ctl.dbDelete", []interface{}{__arg}, nil, 0*time.Millisecond)
   453  	return
   454  }
   455  
   456  func (c CtlClient) DbPut(ctx context.Context, __arg DbPutArg) (err error) {
   457  	err = c.Cli.Call(ctx, "keybase.1.ctl.dbPut", []interface{}{__arg}, nil, 0*time.Millisecond)
   458  	return
   459  }
   460  
   461  func (c CtlClient) DbGet(ctx context.Context, __arg DbGetArg) (res *DbValue, err error) {
   462  	err = c.Cli.Call(ctx, "keybase.1.ctl.dbGet", []interface{}{__arg}, &res, 0*time.Millisecond)
   463  	return
   464  }
   465  
   466  func (c CtlClient) DbKeysWithPrefixes(ctx context.Context, __arg DbKeysWithPrefixesArg) (res []DbKey, err error) {
   467  	err = c.Cli.Call(ctx, "keybase.1.ctl.dbKeysWithPrefixes", []interface{}{__arg}, &res, 0*time.Millisecond)
   468  	return
   469  }
   470  
   471  func (c CtlClient) SetOnLoginStartup(ctx context.Context, enabled bool) (err error) {
   472  	__arg := SetOnLoginStartupArg{Enabled: enabled}
   473  	err = c.Cli.Call(ctx, "keybase.1.ctl.setOnLoginStartup", []interface{}{__arg}, nil, 0*time.Millisecond)
   474  	return
   475  }
   476  
   477  func (c CtlClient) GetOnLoginStartup(ctx context.Context) (res OnLoginStartupStatus, err error) {
   478  	err = c.Cli.Call(ctx, "keybase.1.ctl.getOnLoginStartup", []interface{}{GetOnLoginStartupArg{}}, &res, 0*time.Millisecond)
   479  	return
   480  }