github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/protocol/keybase1/kbfs.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.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 KBFSTeamSettings struct {
    13  	TlfID TLFID `codec:"tlfID" json:"tlfID"`
    14  }
    15  
    16  func (o KBFSTeamSettings) DeepCopy() KBFSTeamSettings {
    17  	return KBFSTeamSettings{
    18  		TlfID: o.TlfID.DeepCopy(),
    19  	}
    20  }
    21  
    22  type FSEventArg struct {
    23  	Event FSNotification `codec:"event" json:"event"`
    24  }
    25  
    26  type FSPathUpdateArg struct {
    27  	Path string `codec:"path" json:"path"`
    28  }
    29  
    30  type FSEditListArg struct {
    31  	Edits     FSFolderEditHistory `codec:"edits" json:"edits"`
    32  	RequestID int                 `codec:"requestID" json:"requestID"`
    33  }
    34  
    35  type FSSyncStatusArg struct {
    36  	Status    FSSyncStatus `codec:"status" json:"status"`
    37  	RequestID int          `codec:"requestID" json:"requestID"`
    38  }
    39  
    40  type FSSyncEventArg struct {
    41  	Event FSPathSyncStatus `codec:"event" json:"event"`
    42  }
    43  
    44  type FSOverallSyncEventArg struct {
    45  	Status FolderSyncStatus `codec:"status" json:"status"`
    46  }
    47  
    48  type FSOnlineStatusChangedEventArg struct {
    49  	Online bool `codec:"online" json:"online"`
    50  }
    51  
    52  type FSFavoritesChangedEventArg struct {
    53  }
    54  
    55  type FSSubscriptionNotifyPathEventArg struct {
    56  	ClientID        string                  `codec:"clientID" json:"clientID"`
    57  	SubscriptionIDs []string                `codec:"subscriptionIDs" json:"subscriptionIDs"`
    58  	Path            string                  `codec:"path" json:"path"`
    59  	Topics          []PathSubscriptionTopic `codec:"topics" json:"topics"`
    60  }
    61  
    62  type FSSubscriptionNotifyEventArg struct {
    63  	ClientID        string            `codec:"clientID" json:"clientID"`
    64  	SubscriptionIDs []string          `codec:"subscriptionIDs" json:"subscriptionIDs"`
    65  	Topic           SubscriptionTopic `codec:"topic" json:"topic"`
    66  }
    67  
    68  type CreateTLFArg struct {
    69  	TeamID TeamID `codec:"teamID" json:"teamID"`
    70  	TlfID  TLFID  `codec:"tlfID" json:"tlfID"`
    71  }
    72  
    73  type GetKBFSTeamSettingsArg struct {
    74  	TeamID TeamID              `codec:"teamID" json:"teamID"`
    75  	Oa     OfflineAvailability `codec:"oa" json:"oa"`
    76  }
    77  
    78  type UpgradeTLFArg struct {
    79  	TlfName string `codec:"tlfName" json:"tlfName"`
    80  	Public  bool   `codec:"public" json:"public"`
    81  }
    82  
    83  type EncryptFavoritesArg struct {
    84  	DataToEncrypt []byte `codec:"dataToEncrypt" json:"dataToEncrypt"`
    85  }
    86  
    87  type DecryptFavoritesArg struct {
    88  	DataToEncrypt []byte `codec:"dataToEncrypt" json:"dataToEncrypt"`
    89  }
    90  
    91  type KbfsInterface interface {
    92  	// Idea is that kbfs would call the function below whenever these actions are
    93  	// performed on a file.
    94  	//
    95  	// Note that this list/interface is very temporary and highly likely to change
    96  	// significantly.
    97  	//
    98  	// It is just a starting point to get kbfs notifications through the daemon to
    99  	// the clients.
   100  	FSEvent(context.Context, FSNotification) error
   101  	// kbfs calls this whenever the currently subscribed-to folder (via the
   102  	// SimpleFSList[Recursive call) has been updated.
   103  	FSPathUpdate(context.Context, string) error
   104  	// kbfs calls this as a response to receiving an FSEditListRequest with a
   105  	// given requestID.
   106  	FSEditList(context.Context, FSEditListArg) error
   107  	// FSSyncStatus is called by KBFS as a response to receiving an
   108  	// FSSyncStatusRequest with a given requestID.
   109  	FSSyncStatus(context.Context, FSSyncStatusArg) error
   110  	// FSSyncEvent is called by KBFS when the sync status of an individual path
   111  	// changes.
   112  	FSSyncEvent(context.Context, FSPathSyncStatus) error
   113  	// FSOverallSyncEvent is called by KBFS when the overall sync status
   114  	// changes.
   115  	FSOverallSyncEvent(context.Context, FolderSyncStatus) error
   116  	// FSOnlineStatusChangedEvent is called by KBFS when the online status changes.
   117  	FSOnlineStatusChangedEvent(context.Context, bool) error
   118  	// FSFavoritesChangedEvent is called by KBFS when the favorites list changes.
   119  	FSFavoritesChangedEvent(context.Context) error
   120  	FSSubscriptionNotifyPathEvent(context.Context, FSSubscriptionNotifyPathEventArg) error
   121  	FSSubscriptionNotifyEvent(context.Context, FSSubscriptionNotifyEventArg) error
   122  	// createTLF is called by KBFS to associate the tlfID with the given teamID,
   123  	// using the v2 Team-based system.
   124  	CreateTLF(context.Context, CreateTLFArg) error
   125  	// getKBFSTeamSettings gets the settings written for the team in the team's sigchain.
   126  	GetKBFSTeamSettings(context.Context, GetKBFSTeamSettingsArg) (KBFSTeamSettings, error)
   127  	// upgradeTLF upgrades a TLF to use implicit team keys
   128  	UpgradeTLF(context.Context, UpgradeTLFArg) error
   129  	// Encrypt cached favorites to store on disk.
   130  	EncryptFavorites(context.Context, []byte) ([]byte, error)
   131  	// Decrypt cached favorites stored on disk.
   132  	DecryptFavorites(context.Context, []byte) ([]byte, error)
   133  }
   134  
   135  func KbfsProtocol(i KbfsInterface) rpc.Protocol {
   136  	return rpc.Protocol{
   137  		Name: "keybase.1.kbfs",
   138  		Methods: map[string]rpc.ServeHandlerDescription{
   139  			"FSEvent": {
   140  				MakeArg: func() interface{} {
   141  					var ret [1]FSEventArg
   142  					return &ret
   143  				},
   144  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   145  					typedArgs, ok := args.(*[1]FSEventArg)
   146  					if !ok {
   147  						err = rpc.NewTypeError((*[1]FSEventArg)(nil), args)
   148  						return
   149  					}
   150  					err = i.FSEvent(ctx, typedArgs[0].Event)
   151  					return
   152  				},
   153  			},
   154  			"FSPathUpdate": {
   155  				MakeArg: func() interface{} {
   156  					var ret [1]FSPathUpdateArg
   157  					return &ret
   158  				},
   159  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   160  					typedArgs, ok := args.(*[1]FSPathUpdateArg)
   161  					if !ok {
   162  						err = rpc.NewTypeError((*[1]FSPathUpdateArg)(nil), args)
   163  						return
   164  					}
   165  					err = i.FSPathUpdate(ctx, typedArgs[0].Path)
   166  					return
   167  				},
   168  			},
   169  			"FSEditList": {
   170  				MakeArg: func() interface{} {
   171  					var ret [1]FSEditListArg
   172  					return &ret
   173  				},
   174  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   175  					typedArgs, ok := args.(*[1]FSEditListArg)
   176  					if !ok {
   177  						err = rpc.NewTypeError((*[1]FSEditListArg)(nil), args)
   178  						return
   179  					}
   180  					err = i.FSEditList(ctx, typedArgs[0])
   181  					return
   182  				},
   183  			},
   184  			"FSSyncStatus": {
   185  				MakeArg: func() interface{} {
   186  					var ret [1]FSSyncStatusArg
   187  					return &ret
   188  				},
   189  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   190  					typedArgs, ok := args.(*[1]FSSyncStatusArg)
   191  					if !ok {
   192  						err = rpc.NewTypeError((*[1]FSSyncStatusArg)(nil), args)
   193  						return
   194  					}
   195  					err = i.FSSyncStatus(ctx, typedArgs[0])
   196  					return
   197  				},
   198  			},
   199  			"FSSyncEvent": {
   200  				MakeArg: func() interface{} {
   201  					var ret [1]FSSyncEventArg
   202  					return &ret
   203  				},
   204  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   205  					typedArgs, ok := args.(*[1]FSSyncEventArg)
   206  					if !ok {
   207  						err = rpc.NewTypeError((*[1]FSSyncEventArg)(nil), args)
   208  						return
   209  					}
   210  					err = i.FSSyncEvent(ctx, typedArgs[0].Event)
   211  					return
   212  				},
   213  			},
   214  			"FSOverallSyncEvent": {
   215  				MakeArg: func() interface{} {
   216  					var ret [1]FSOverallSyncEventArg
   217  					return &ret
   218  				},
   219  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   220  					typedArgs, ok := args.(*[1]FSOverallSyncEventArg)
   221  					if !ok {
   222  						err = rpc.NewTypeError((*[1]FSOverallSyncEventArg)(nil), args)
   223  						return
   224  					}
   225  					err = i.FSOverallSyncEvent(ctx, typedArgs[0].Status)
   226  					return
   227  				},
   228  			},
   229  			"FSOnlineStatusChangedEvent": {
   230  				MakeArg: func() interface{} {
   231  					var ret [1]FSOnlineStatusChangedEventArg
   232  					return &ret
   233  				},
   234  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   235  					typedArgs, ok := args.(*[1]FSOnlineStatusChangedEventArg)
   236  					if !ok {
   237  						err = rpc.NewTypeError((*[1]FSOnlineStatusChangedEventArg)(nil), args)
   238  						return
   239  					}
   240  					err = i.FSOnlineStatusChangedEvent(ctx, typedArgs[0].Online)
   241  					return
   242  				},
   243  			},
   244  			"FSFavoritesChangedEvent": {
   245  				MakeArg: func() interface{} {
   246  					var ret [1]FSFavoritesChangedEventArg
   247  					return &ret
   248  				},
   249  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   250  					err = i.FSFavoritesChangedEvent(ctx)
   251  					return
   252  				},
   253  			},
   254  			"FSSubscriptionNotifyPathEvent": {
   255  				MakeArg: func() interface{} {
   256  					var ret [1]FSSubscriptionNotifyPathEventArg
   257  					return &ret
   258  				},
   259  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   260  					typedArgs, ok := args.(*[1]FSSubscriptionNotifyPathEventArg)
   261  					if !ok {
   262  						err = rpc.NewTypeError((*[1]FSSubscriptionNotifyPathEventArg)(nil), args)
   263  						return
   264  					}
   265  					err = i.FSSubscriptionNotifyPathEvent(ctx, typedArgs[0])
   266  					return
   267  				},
   268  			},
   269  			"FSSubscriptionNotifyEvent": {
   270  				MakeArg: func() interface{} {
   271  					var ret [1]FSSubscriptionNotifyEventArg
   272  					return &ret
   273  				},
   274  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   275  					typedArgs, ok := args.(*[1]FSSubscriptionNotifyEventArg)
   276  					if !ok {
   277  						err = rpc.NewTypeError((*[1]FSSubscriptionNotifyEventArg)(nil), args)
   278  						return
   279  					}
   280  					err = i.FSSubscriptionNotifyEvent(ctx, typedArgs[0])
   281  					return
   282  				},
   283  			},
   284  			"createTLF": {
   285  				MakeArg: func() interface{} {
   286  					var ret [1]CreateTLFArg
   287  					return &ret
   288  				},
   289  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   290  					typedArgs, ok := args.(*[1]CreateTLFArg)
   291  					if !ok {
   292  						err = rpc.NewTypeError((*[1]CreateTLFArg)(nil), args)
   293  						return
   294  					}
   295  					err = i.CreateTLF(ctx, typedArgs[0])
   296  					return
   297  				},
   298  			},
   299  			"getKBFSTeamSettings": {
   300  				MakeArg: func() interface{} {
   301  					var ret [1]GetKBFSTeamSettingsArg
   302  					return &ret
   303  				},
   304  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   305  					typedArgs, ok := args.(*[1]GetKBFSTeamSettingsArg)
   306  					if !ok {
   307  						err = rpc.NewTypeError((*[1]GetKBFSTeamSettingsArg)(nil), args)
   308  						return
   309  					}
   310  					ret, err = i.GetKBFSTeamSettings(ctx, typedArgs[0])
   311  					return
   312  				},
   313  			},
   314  			"upgradeTLF": {
   315  				MakeArg: func() interface{} {
   316  					var ret [1]UpgradeTLFArg
   317  					return &ret
   318  				},
   319  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   320  					typedArgs, ok := args.(*[1]UpgradeTLFArg)
   321  					if !ok {
   322  						err = rpc.NewTypeError((*[1]UpgradeTLFArg)(nil), args)
   323  						return
   324  					}
   325  					err = i.UpgradeTLF(ctx, typedArgs[0])
   326  					return
   327  				},
   328  			},
   329  			"encryptFavorites": {
   330  				MakeArg: func() interface{} {
   331  					var ret [1]EncryptFavoritesArg
   332  					return &ret
   333  				},
   334  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   335  					typedArgs, ok := args.(*[1]EncryptFavoritesArg)
   336  					if !ok {
   337  						err = rpc.NewTypeError((*[1]EncryptFavoritesArg)(nil), args)
   338  						return
   339  					}
   340  					ret, err = i.EncryptFavorites(ctx, typedArgs[0].DataToEncrypt)
   341  					return
   342  				},
   343  			},
   344  			"decryptFavorites": {
   345  				MakeArg: func() interface{} {
   346  					var ret [1]DecryptFavoritesArg
   347  					return &ret
   348  				},
   349  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   350  					typedArgs, ok := args.(*[1]DecryptFavoritesArg)
   351  					if !ok {
   352  						err = rpc.NewTypeError((*[1]DecryptFavoritesArg)(nil), args)
   353  						return
   354  					}
   355  					ret, err = i.DecryptFavorites(ctx, typedArgs[0].DataToEncrypt)
   356  					return
   357  				},
   358  			},
   359  		},
   360  	}
   361  }
   362  
   363  type KbfsClient struct {
   364  	Cli rpc.GenericClient
   365  }
   366  
   367  // Idea is that kbfs would call the function below whenever these actions are
   368  // performed on a file.
   369  //
   370  // Note that this list/interface is very temporary and highly likely to change
   371  // significantly.
   372  //
   373  // It is just a starting point to get kbfs notifications through the daemon to
   374  // the clients.
   375  func (c KbfsClient) FSEvent(ctx context.Context, event FSNotification) (err error) {
   376  	__arg := FSEventArg{Event: event}
   377  	err = c.Cli.Call(ctx, "keybase.1.kbfs.FSEvent", []interface{}{__arg}, nil, 0*time.Millisecond)
   378  	return
   379  }
   380  
   381  // kbfs calls this whenever the currently subscribed-to folder (via the
   382  // SimpleFSList[Recursive call) has been updated.
   383  func (c KbfsClient) FSPathUpdate(ctx context.Context, path string) (err error) {
   384  	__arg := FSPathUpdateArg{Path: path}
   385  	err = c.Cli.Notify(ctx, "keybase.1.kbfs.FSPathUpdate", []interface{}{__arg}, 0*time.Millisecond)
   386  	return
   387  }
   388  
   389  // kbfs calls this as a response to receiving an FSEditListRequest with a
   390  // given requestID.
   391  func (c KbfsClient) FSEditList(ctx context.Context, __arg FSEditListArg) (err error) {
   392  	err = c.Cli.Call(ctx, "keybase.1.kbfs.FSEditList", []interface{}{__arg}, nil, 0*time.Millisecond)
   393  	return
   394  }
   395  
   396  // FSSyncStatus is called by KBFS as a response to receiving an
   397  // FSSyncStatusRequest with a given requestID.
   398  func (c KbfsClient) FSSyncStatus(ctx context.Context, __arg FSSyncStatusArg) (err error) {
   399  	err = c.Cli.Call(ctx, "keybase.1.kbfs.FSSyncStatus", []interface{}{__arg}, nil, 0*time.Millisecond)
   400  	return
   401  }
   402  
   403  // FSSyncEvent is called by KBFS when the sync status of an individual path
   404  // changes.
   405  func (c KbfsClient) FSSyncEvent(ctx context.Context, event FSPathSyncStatus) (err error) {
   406  	__arg := FSSyncEventArg{Event: event}
   407  	err = c.Cli.Call(ctx, "keybase.1.kbfs.FSSyncEvent", []interface{}{__arg}, nil, 0*time.Millisecond)
   408  	return
   409  }
   410  
   411  // FSOverallSyncEvent is called by KBFS when the overall sync status
   412  // changes.
   413  func (c KbfsClient) FSOverallSyncEvent(ctx context.Context, status FolderSyncStatus) (err error) {
   414  	__arg := FSOverallSyncEventArg{Status: status}
   415  	err = c.Cli.Call(ctx, "keybase.1.kbfs.FSOverallSyncEvent", []interface{}{__arg}, nil, 0*time.Millisecond)
   416  	return
   417  }
   418  
   419  // FSOnlineStatusChangedEvent is called by KBFS when the online status changes.
   420  func (c KbfsClient) FSOnlineStatusChangedEvent(ctx context.Context, online bool) (err error) {
   421  	__arg := FSOnlineStatusChangedEventArg{Online: online}
   422  	err = c.Cli.Call(ctx, "keybase.1.kbfs.FSOnlineStatusChangedEvent", []interface{}{__arg}, nil, 0*time.Millisecond)
   423  	return
   424  }
   425  
   426  // FSFavoritesChangedEvent is called by KBFS when the favorites list changes.
   427  func (c KbfsClient) FSFavoritesChangedEvent(ctx context.Context) (err error) {
   428  	err = c.Cli.Call(ctx, "keybase.1.kbfs.FSFavoritesChangedEvent", []interface{}{FSFavoritesChangedEventArg{}}, nil, 0*time.Millisecond)
   429  	return
   430  }
   431  
   432  func (c KbfsClient) FSSubscriptionNotifyPathEvent(ctx context.Context, __arg FSSubscriptionNotifyPathEventArg) (err error) {
   433  	err = c.Cli.Call(ctx, "keybase.1.kbfs.FSSubscriptionNotifyPathEvent", []interface{}{__arg}, nil, 0*time.Millisecond)
   434  	return
   435  }
   436  
   437  func (c KbfsClient) FSSubscriptionNotifyEvent(ctx context.Context, __arg FSSubscriptionNotifyEventArg) (err error) {
   438  	err = c.Cli.Call(ctx, "keybase.1.kbfs.FSSubscriptionNotifyEvent", []interface{}{__arg}, nil, 0*time.Millisecond)
   439  	return
   440  }
   441  
   442  // createTLF is called by KBFS to associate the tlfID with the given teamID,
   443  // using the v2 Team-based system.
   444  func (c KbfsClient) CreateTLF(ctx context.Context, __arg CreateTLFArg) (err error) {
   445  	err = c.Cli.Call(ctx, "keybase.1.kbfs.createTLF", []interface{}{__arg}, nil, 0*time.Millisecond)
   446  	return
   447  }
   448  
   449  // getKBFSTeamSettings gets the settings written for the team in the team's sigchain.
   450  func (c KbfsClient) GetKBFSTeamSettings(ctx context.Context, __arg GetKBFSTeamSettingsArg) (res KBFSTeamSettings, err error) {
   451  	err = c.Cli.Call(ctx, "keybase.1.kbfs.getKBFSTeamSettings", []interface{}{__arg}, &res, 0*time.Millisecond)
   452  	return
   453  }
   454  
   455  // upgradeTLF upgrades a TLF to use implicit team keys
   456  func (c KbfsClient) UpgradeTLF(ctx context.Context, __arg UpgradeTLFArg) (err error) {
   457  	err = c.Cli.Call(ctx, "keybase.1.kbfs.upgradeTLF", []interface{}{__arg}, nil, 0*time.Millisecond)
   458  	return
   459  }
   460  
   461  // Encrypt cached favorites to store on disk.
   462  func (c KbfsClient) EncryptFavorites(ctx context.Context, dataToEncrypt []byte) (res []byte, err error) {
   463  	__arg := EncryptFavoritesArg{DataToEncrypt: dataToEncrypt}
   464  	err = c.Cli.Call(ctx, "keybase.1.kbfs.encryptFavorites", []interface{}{__arg}, &res, 0*time.Millisecond)
   465  	return
   466  }
   467  
   468  // Decrypt cached favorites stored on disk.
   469  func (c KbfsClient) DecryptFavorites(ctx context.Context, dataToEncrypt []byte) (res []byte, err error) {
   470  	__arg := DecryptFavoritesArg{DataToEncrypt: dataToEncrypt}
   471  	err = c.Cli.Call(ctx, "keybase.1.kbfs.decryptFavorites", []interface{}{__arg}, &res, 0*time.Millisecond)
   472  	return
   473  }