github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/protocol/keybase1/favorite.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/favorite.avdl
     3  
     4  package keybase1
     5  
     6  import (
     7  	"errors"
     8  	"fmt"
     9  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
    10  	context "golang.org/x/net/context"
    11  	"time"
    12  )
    13  
    14  type FolderType int
    15  
    16  const (
    17  	FolderType_UNKNOWN FolderType = 0
    18  	FolderType_PRIVATE FolderType = 1
    19  	FolderType_PUBLIC  FolderType = 2
    20  	FolderType_TEAM    FolderType = 3
    21  )
    22  
    23  func (o FolderType) DeepCopy() FolderType { return o }
    24  
    25  var FolderTypeMap = map[string]FolderType{
    26  	"UNKNOWN": 0,
    27  	"PRIVATE": 1,
    28  	"PUBLIC":  2,
    29  	"TEAM":    3,
    30  }
    31  
    32  var FolderTypeRevMap = map[FolderType]string{
    33  	0: "UNKNOWN",
    34  	1: "PRIVATE",
    35  	2: "PUBLIC",
    36  	3: "TEAM",
    37  }
    38  
    39  func (e FolderType) String() string {
    40  	if v, ok := FolderTypeRevMap[e]; ok {
    41  		return v
    42  	}
    43  	return fmt.Sprintf("%v", int(e))
    44  }
    45  
    46  type FolderConflictType int
    47  
    48  const (
    49  	FolderConflictType_NONE                  FolderConflictType = 0
    50  	FolderConflictType_IN_CONFLICT           FolderConflictType = 1
    51  	FolderConflictType_IN_CONFLICT_AND_STUCK FolderConflictType = 2
    52  	FolderConflictType_CLEARED_CONFLICT      FolderConflictType = 3
    53  )
    54  
    55  func (o FolderConflictType) DeepCopy() FolderConflictType { return o }
    56  
    57  var FolderConflictTypeMap = map[string]FolderConflictType{
    58  	"NONE":                  0,
    59  	"IN_CONFLICT":           1,
    60  	"IN_CONFLICT_AND_STUCK": 2,
    61  	"CLEARED_CONFLICT":      3,
    62  }
    63  
    64  var FolderConflictTypeRevMap = map[FolderConflictType]string{
    65  	0: "NONE",
    66  	1: "IN_CONFLICT",
    67  	2: "IN_CONFLICT_AND_STUCK",
    68  	3: "CLEARED_CONFLICT",
    69  }
    70  
    71  func (e FolderConflictType) String() string {
    72  	if v, ok := FolderConflictTypeRevMap[e]; ok {
    73  		return v
    74  	}
    75  	return fmt.Sprintf("%v", int(e))
    76  }
    77  
    78  type ConflictStateType int
    79  
    80  const (
    81  	ConflictStateType_NormalView               ConflictStateType = 1
    82  	ConflictStateType_ManualResolvingLocalView ConflictStateType = 2
    83  )
    84  
    85  func (o ConflictStateType) DeepCopy() ConflictStateType { return o }
    86  
    87  var ConflictStateTypeMap = map[string]ConflictStateType{
    88  	"NormalView":               1,
    89  	"ManualResolvingLocalView": 2,
    90  }
    91  
    92  var ConflictStateTypeRevMap = map[ConflictStateType]string{
    93  	1: "NormalView",
    94  	2: "ManualResolvingLocalView",
    95  }
    96  
    97  func (e ConflictStateType) String() string {
    98  	if v, ok := ConflictStateTypeRevMap[e]; ok {
    99  		return v
   100  	}
   101  	return fmt.Sprintf("%v", int(e))
   102  }
   103  
   104  type FolderNormalView struct {
   105  	ResolvingConflict bool   `codec:"resolvingConflict" json:"resolvingConflict"`
   106  	StuckInConflict   bool   `codec:"stuckInConflict" json:"stuckInConflict"`
   107  	LocalViews        []Path `codec:"localViews" json:"localViews"`
   108  }
   109  
   110  func (o FolderNormalView) DeepCopy() FolderNormalView {
   111  	return FolderNormalView{
   112  		ResolvingConflict: o.ResolvingConflict,
   113  		StuckInConflict:   o.StuckInConflict,
   114  		LocalViews: (func(x []Path) []Path {
   115  			if x == nil {
   116  				return nil
   117  			}
   118  			ret := make([]Path, len(x))
   119  			for i, v := range x {
   120  				vCopy := v.DeepCopy()
   121  				ret[i] = vCopy
   122  			}
   123  			return ret
   124  		})(o.LocalViews),
   125  	}
   126  }
   127  
   128  type FolderConflictManualResolvingLocalView struct {
   129  	NormalView Path `codec:"normalView" json:"normalView"`
   130  }
   131  
   132  func (o FolderConflictManualResolvingLocalView) DeepCopy() FolderConflictManualResolvingLocalView {
   133  	return FolderConflictManualResolvingLocalView{
   134  		NormalView: o.NormalView.DeepCopy(),
   135  	}
   136  }
   137  
   138  type ConflictState struct {
   139  	ConflictStateType__        ConflictStateType                       `codec:"conflictStateType" json:"conflictStateType"`
   140  	Normalview__               *FolderNormalView                       `codec:"normalview,omitempty" json:"normalview,omitempty"`
   141  	Manualresolvinglocalview__ *FolderConflictManualResolvingLocalView `codec:"manualresolvinglocalview,omitempty" json:"manualresolvinglocalview,omitempty"`
   142  }
   143  
   144  func (o *ConflictState) ConflictStateType() (ret ConflictStateType, err error) {
   145  	switch o.ConflictStateType__ {
   146  	case ConflictStateType_NormalView:
   147  		if o.Normalview__ == nil {
   148  			err = errors.New("unexpected nil value for Normalview__")
   149  			return ret, err
   150  		}
   151  	case ConflictStateType_ManualResolvingLocalView:
   152  		if o.Manualresolvinglocalview__ == nil {
   153  			err = errors.New("unexpected nil value for Manualresolvinglocalview__")
   154  			return ret, err
   155  		}
   156  	}
   157  	return o.ConflictStateType__, nil
   158  }
   159  
   160  func (o ConflictState) Normalview() (res FolderNormalView) {
   161  	if o.ConflictStateType__ != ConflictStateType_NormalView {
   162  		panic("wrong case accessed")
   163  	}
   164  	if o.Normalview__ == nil {
   165  		return
   166  	}
   167  	return *o.Normalview__
   168  }
   169  
   170  func (o ConflictState) Manualresolvinglocalview() (res FolderConflictManualResolvingLocalView) {
   171  	if o.ConflictStateType__ != ConflictStateType_ManualResolvingLocalView {
   172  		panic("wrong case accessed")
   173  	}
   174  	if o.Manualresolvinglocalview__ == nil {
   175  		return
   176  	}
   177  	return *o.Manualresolvinglocalview__
   178  }
   179  
   180  func NewConflictStateWithNormalview(v FolderNormalView) ConflictState {
   181  	return ConflictState{
   182  		ConflictStateType__: ConflictStateType_NormalView,
   183  		Normalview__:        &v,
   184  	}
   185  }
   186  
   187  func NewConflictStateWithManualresolvinglocalview(v FolderConflictManualResolvingLocalView) ConflictState {
   188  	return ConflictState{
   189  		ConflictStateType__:        ConflictStateType_ManualResolvingLocalView,
   190  		Manualresolvinglocalview__: &v,
   191  	}
   192  }
   193  
   194  func (o ConflictState) DeepCopy() ConflictState {
   195  	return ConflictState{
   196  		ConflictStateType__: o.ConflictStateType__.DeepCopy(),
   197  		Normalview__: (func(x *FolderNormalView) *FolderNormalView {
   198  			if x == nil {
   199  				return nil
   200  			}
   201  			tmp := (*x).DeepCopy()
   202  			return &tmp
   203  		})(o.Normalview__),
   204  		Manualresolvinglocalview__: (func(x *FolderConflictManualResolvingLocalView) *FolderConflictManualResolvingLocalView {
   205  			if x == nil {
   206  				return nil
   207  			}
   208  			tmp := (*x).DeepCopy()
   209  			return &tmp
   210  		})(o.Manualresolvinglocalview__),
   211  	}
   212  }
   213  
   214  // Folder represents a favorite top-level folder in kbfs.
   215  // This type is likely to change significantly as all the various parts are
   216  // connected and tested.
   217  type Folder struct {
   218  	Name          string            `codec:"name" json:"name"`
   219  	Private       bool              `codec:"private" json:"private"`
   220  	Created       bool              `codec:"created" json:"created"`
   221  	FolderType    FolderType        `codec:"folderType" json:"folderType"`
   222  	TeamID        *TeamID           `codec:"team_id,omitempty" json:"team_id,omitempty"`
   223  	ResetMembers  []User            `codec:"reset_members" json:"reset_members"`
   224  	Mtime         *Time             `codec:"mtime,omitempty" json:"mtime,omitempty"`
   225  	ConflictState *ConflictState    `codec:"conflictState,omitempty" json:"conflictState,omitempty"`
   226  	SyncConfig    *FolderSyncConfig `codec:"syncConfig,omitempty" json:"syncConfig,omitempty"`
   227  }
   228  
   229  func (o Folder) DeepCopy() Folder {
   230  	return Folder{
   231  		Name:       o.Name,
   232  		Private:    o.Private,
   233  		Created:    o.Created,
   234  		FolderType: o.FolderType.DeepCopy(),
   235  		TeamID: (func(x *TeamID) *TeamID {
   236  			if x == nil {
   237  				return nil
   238  			}
   239  			tmp := (*x).DeepCopy()
   240  			return &tmp
   241  		})(o.TeamID),
   242  		ResetMembers: (func(x []User) []User {
   243  			if x == nil {
   244  				return nil
   245  			}
   246  			ret := make([]User, len(x))
   247  			for i, v := range x {
   248  				vCopy := v.DeepCopy()
   249  				ret[i] = vCopy
   250  			}
   251  			return ret
   252  		})(o.ResetMembers),
   253  		Mtime: (func(x *Time) *Time {
   254  			if x == nil {
   255  				return nil
   256  			}
   257  			tmp := (*x).DeepCopy()
   258  			return &tmp
   259  		})(o.Mtime),
   260  		ConflictState: (func(x *ConflictState) *ConflictState {
   261  			if x == nil {
   262  				return nil
   263  			}
   264  			tmp := (*x).DeepCopy()
   265  			return &tmp
   266  		})(o.ConflictState),
   267  		SyncConfig: (func(x *FolderSyncConfig) *FolderSyncConfig {
   268  			if x == nil {
   269  				return nil
   270  			}
   271  			tmp := (*x).DeepCopy()
   272  			return &tmp
   273  		})(o.SyncConfig),
   274  	}
   275  }
   276  
   277  type FolderHandle struct {
   278  	Name       string     `codec:"name" json:"name"`
   279  	FolderType FolderType `codec:"folderType" json:"folderType"`
   280  	Created    bool       `codec:"created" json:"created"`
   281  }
   282  
   283  func (o FolderHandle) DeepCopy() FolderHandle {
   284  	return FolderHandle{
   285  		Name:       o.Name,
   286  		FolderType: o.FolderType.DeepCopy(),
   287  		Created:    o.Created,
   288  	}
   289  }
   290  
   291  type FavoritesResult struct {
   292  	FavoriteFolders []Folder `codec:"favoriteFolders" json:"favoriteFolders"`
   293  	IgnoredFolders  []Folder `codec:"ignoredFolders" json:"ignoredFolders"`
   294  	NewFolders      []Folder `codec:"newFolders" json:"newFolders"`
   295  }
   296  
   297  func (o FavoritesResult) DeepCopy() FavoritesResult {
   298  	return FavoritesResult{
   299  		FavoriteFolders: (func(x []Folder) []Folder {
   300  			if x == nil {
   301  				return nil
   302  			}
   303  			ret := make([]Folder, len(x))
   304  			for i, v := range x {
   305  				vCopy := v.DeepCopy()
   306  				ret[i] = vCopy
   307  			}
   308  			return ret
   309  		})(o.FavoriteFolders),
   310  		IgnoredFolders: (func(x []Folder) []Folder {
   311  			if x == nil {
   312  				return nil
   313  			}
   314  			ret := make([]Folder, len(x))
   315  			for i, v := range x {
   316  				vCopy := v.DeepCopy()
   317  				ret[i] = vCopy
   318  			}
   319  			return ret
   320  		})(o.IgnoredFolders),
   321  		NewFolders: (func(x []Folder) []Folder {
   322  			if x == nil {
   323  				return nil
   324  			}
   325  			ret := make([]Folder, len(x))
   326  			for i, v := range x {
   327  				vCopy := v.DeepCopy()
   328  				ret[i] = vCopy
   329  			}
   330  			return ret
   331  		})(o.NewFolders),
   332  	}
   333  }
   334  
   335  type FavoriteAddArg struct {
   336  	SessionID int          `codec:"sessionID" json:"sessionID"`
   337  	Folder    FolderHandle `codec:"folder" json:"folder"`
   338  }
   339  
   340  type FavoriteIgnoreArg struct {
   341  	SessionID int          `codec:"sessionID" json:"sessionID"`
   342  	Folder    FolderHandle `codec:"folder" json:"folder"`
   343  }
   344  
   345  type GetFavoritesArg struct {
   346  	SessionID int `codec:"sessionID" json:"sessionID"`
   347  }
   348  
   349  type FavoriteInterface interface {
   350  	// Adds a folder to a user's list of favorite folders.
   351  	FavoriteAdd(context.Context, FavoriteAddArg) error
   352  	// Removes a folder from a user's list of favorite folders.
   353  	FavoriteIgnore(context.Context, FavoriteIgnoreArg) error
   354  	// Returns all of a user's favorite folders.
   355  	GetFavorites(context.Context, int) (FavoritesResult, error)
   356  }
   357  
   358  func FavoriteProtocol(i FavoriteInterface) rpc.Protocol {
   359  	return rpc.Protocol{
   360  		Name: "keybase.1.favorite",
   361  		Methods: map[string]rpc.ServeHandlerDescription{
   362  			"favoriteAdd": {
   363  				MakeArg: func() interface{} {
   364  					var ret [1]FavoriteAddArg
   365  					return &ret
   366  				},
   367  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   368  					typedArgs, ok := args.(*[1]FavoriteAddArg)
   369  					if !ok {
   370  						err = rpc.NewTypeError((*[1]FavoriteAddArg)(nil), args)
   371  						return
   372  					}
   373  					err = i.FavoriteAdd(ctx, typedArgs[0])
   374  					return
   375  				},
   376  			},
   377  			"favoriteIgnore": {
   378  				MakeArg: func() interface{} {
   379  					var ret [1]FavoriteIgnoreArg
   380  					return &ret
   381  				},
   382  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   383  					typedArgs, ok := args.(*[1]FavoriteIgnoreArg)
   384  					if !ok {
   385  						err = rpc.NewTypeError((*[1]FavoriteIgnoreArg)(nil), args)
   386  						return
   387  					}
   388  					err = i.FavoriteIgnore(ctx, typedArgs[0])
   389  					return
   390  				},
   391  			},
   392  			"getFavorites": {
   393  				MakeArg: func() interface{} {
   394  					var ret [1]GetFavoritesArg
   395  					return &ret
   396  				},
   397  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   398  					typedArgs, ok := args.(*[1]GetFavoritesArg)
   399  					if !ok {
   400  						err = rpc.NewTypeError((*[1]GetFavoritesArg)(nil), args)
   401  						return
   402  					}
   403  					ret, err = i.GetFavorites(ctx, typedArgs[0].SessionID)
   404  					return
   405  				},
   406  			},
   407  		},
   408  	}
   409  }
   410  
   411  type FavoriteClient struct {
   412  	Cli rpc.GenericClient
   413  }
   414  
   415  // Adds a folder to a user's list of favorite folders.
   416  func (c FavoriteClient) FavoriteAdd(ctx context.Context, __arg FavoriteAddArg) (err error) {
   417  	err = c.Cli.Call(ctx, "keybase.1.favorite.favoriteAdd", []interface{}{__arg}, nil, 0*time.Millisecond)
   418  	return
   419  }
   420  
   421  // Removes a folder from a user's list of favorite folders.
   422  func (c FavoriteClient) FavoriteIgnore(ctx context.Context, __arg FavoriteIgnoreArg) (err error) {
   423  	err = c.Cli.Call(ctx, "keybase.1.favorite.favoriteIgnore", []interface{}{__arg}, nil, 0*time.Millisecond)
   424  	return
   425  }
   426  
   427  // Returns all of a user's favorite folders.
   428  func (c FavoriteClient) GetFavorites(ctx context.Context, sessionID int) (res FavoritesResult, err error) {
   429  	__arg := GetFavoritesArg{SessionID: sessionID}
   430  	err = c.Cli.Call(ctx, "keybase.1.favorite.getFavorites", []interface{}{__arg}, &res, 0*time.Millisecond)
   431  	return
   432  }