github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/protocol/keybase1/kvstore.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/kvstore.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 KVGetResult struct {
    13  	TeamName   string  `codec:"teamName" json:"teamName"`
    14  	Namespace  string  `codec:"namespace" json:"namespace"`
    15  	EntryKey   string  `codec:"entryKey" json:"entryKey"`
    16  	EntryValue *string `codec:"entryValue" json:"entryValue"`
    17  	Revision   int     `codec:"revision" json:"revision"`
    18  }
    19  
    20  func (o KVGetResult) DeepCopy() KVGetResult {
    21  	return KVGetResult{
    22  		TeamName:  o.TeamName,
    23  		Namespace: o.Namespace,
    24  		EntryKey:  o.EntryKey,
    25  		EntryValue: (func(x *string) *string {
    26  			if x == nil {
    27  				return nil
    28  			}
    29  			tmp := (*x)
    30  			return &tmp
    31  		})(o.EntryValue),
    32  		Revision: o.Revision,
    33  	}
    34  }
    35  
    36  type KVPutResult struct {
    37  	TeamName  string `codec:"teamName" json:"teamName"`
    38  	Namespace string `codec:"namespace" json:"namespace"`
    39  	EntryKey  string `codec:"entryKey" json:"entryKey"`
    40  	Revision  int    `codec:"revision" json:"revision"`
    41  }
    42  
    43  func (o KVPutResult) DeepCopy() KVPutResult {
    44  	return KVPutResult{
    45  		TeamName:  o.TeamName,
    46  		Namespace: o.Namespace,
    47  		EntryKey:  o.EntryKey,
    48  		Revision:  o.Revision,
    49  	}
    50  }
    51  
    52  type KVEntryID struct {
    53  	TeamID    TeamID `codec:"teamID" json:"teamID"`
    54  	Namespace string `codec:"namespace" json:"namespace"`
    55  	EntryKey  string `codec:"entryKey" json:"entryKey"`
    56  }
    57  
    58  func (o KVEntryID) DeepCopy() KVEntryID {
    59  	return KVEntryID{
    60  		TeamID:    o.TeamID.DeepCopy(),
    61  		Namespace: o.Namespace,
    62  		EntryKey:  o.EntryKey,
    63  	}
    64  }
    65  
    66  type EncryptedKVEntry struct {
    67  	V int    `codec:"v" json:"v"`
    68  	E []byte `codec:"e" json:"e"`
    69  	N []byte `codec:"n" json:"n"`
    70  }
    71  
    72  func (o EncryptedKVEntry) DeepCopy() EncryptedKVEntry {
    73  	return EncryptedKVEntry{
    74  		V: o.V,
    75  		E: (func(x []byte) []byte {
    76  			if x == nil {
    77  				return nil
    78  			}
    79  			return append([]byte{}, x...)
    80  		})(o.E),
    81  		N: (func(x []byte) []byte {
    82  			if x == nil {
    83  				return nil
    84  			}
    85  			return append([]byte{}, x...)
    86  		})(o.N),
    87  	}
    88  }
    89  
    90  type KVListNamespaceResult struct {
    91  	TeamName   string   `codec:"teamName" json:"teamName"`
    92  	Namespaces []string `codec:"namespaces" json:"namespaces"`
    93  }
    94  
    95  func (o KVListNamespaceResult) DeepCopy() KVListNamespaceResult {
    96  	return KVListNamespaceResult{
    97  		TeamName: o.TeamName,
    98  		Namespaces: (func(x []string) []string {
    99  			if x == nil {
   100  				return nil
   101  			}
   102  			ret := make([]string, len(x))
   103  			for i, v := range x {
   104  				vCopy := v
   105  				ret[i] = vCopy
   106  			}
   107  			return ret
   108  		})(o.Namespaces),
   109  	}
   110  }
   111  
   112  type KVListEntryKey struct {
   113  	EntryKey string `codec:"entryKey" json:"entryKey"`
   114  	Revision int    `codec:"revision" json:"revision"`
   115  }
   116  
   117  func (o KVListEntryKey) DeepCopy() KVListEntryKey {
   118  	return KVListEntryKey{
   119  		EntryKey: o.EntryKey,
   120  		Revision: o.Revision,
   121  	}
   122  }
   123  
   124  type KVListEntryResult struct {
   125  	TeamName  string           `codec:"teamName" json:"teamName"`
   126  	Namespace string           `codec:"namespace" json:"namespace"`
   127  	EntryKeys []KVListEntryKey `codec:"entryKeys" json:"entryKeys"`
   128  }
   129  
   130  func (o KVListEntryResult) DeepCopy() KVListEntryResult {
   131  	return KVListEntryResult{
   132  		TeamName:  o.TeamName,
   133  		Namespace: o.Namespace,
   134  		EntryKeys: (func(x []KVListEntryKey) []KVListEntryKey {
   135  			if x == nil {
   136  				return nil
   137  			}
   138  			ret := make([]KVListEntryKey, len(x))
   139  			for i, v := range x {
   140  				vCopy := v.DeepCopy()
   141  				ret[i] = vCopy
   142  			}
   143  			return ret
   144  		})(o.EntryKeys),
   145  	}
   146  }
   147  
   148  type KVDeleteEntryResult struct {
   149  	TeamName  string `codec:"teamName" json:"teamName"`
   150  	Namespace string `codec:"namespace" json:"namespace"`
   151  	EntryKey  string `codec:"entryKey" json:"entryKey"`
   152  	Revision  int    `codec:"revision" json:"revision"`
   153  }
   154  
   155  func (o KVDeleteEntryResult) DeepCopy() KVDeleteEntryResult {
   156  	return KVDeleteEntryResult{
   157  		TeamName:  o.TeamName,
   158  		Namespace: o.Namespace,
   159  		EntryKey:  o.EntryKey,
   160  		Revision:  o.Revision,
   161  	}
   162  }
   163  
   164  type GetKVEntryArg struct {
   165  	SessionID int    `codec:"sessionID" json:"sessionID"`
   166  	TeamName  string `codec:"teamName" json:"teamName"`
   167  	Namespace string `codec:"namespace" json:"namespace"`
   168  	EntryKey  string `codec:"entryKey" json:"entryKey"`
   169  }
   170  
   171  type PutKVEntryArg struct {
   172  	SessionID  int    `codec:"sessionID" json:"sessionID"`
   173  	TeamName   string `codec:"teamName" json:"teamName"`
   174  	Namespace  string `codec:"namespace" json:"namespace"`
   175  	EntryKey   string `codec:"entryKey" json:"entryKey"`
   176  	Revision   int    `codec:"revision" json:"revision"`
   177  	EntryValue string `codec:"entryValue" json:"entryValue"`
   178  }
   179  
   180  type ListKVNamespacesArg struct {
   181  	SessionID int    `codec:"sessionID" json:"sessionID"`
   182  	TeamName  string `codec:"teamName" json:"teamName"`
   183  }
   184  
   185  type ListKVEntriesArg struct {
   186  	SessionID int    `codec:"sessionID" json:"sessionID"`
   187  	TeamName  string `codec:"teamName" json:"teamName"`
   188  	Namespace string `codec:"namespace" json:"namespace"`
   189  }
   190  
   191  type DelKVEntryArg struct {
   192  	SessionID int    `codec:"sessionID" json:"sessionID"`
   193  	TeamName  string `codec:"teamName" json:"teamName"`
   194  	Namespace string `codec:"namespace" json:"namespace"`
   195  	EntryKey  string `codec:"entryKey" json:"entryKey"`
   196  	Revision  int    `codec:"revision" json:"revision"`
   197  }
   198  
   199  type KvstoreInterface interface {
   200  	GetKVEntry(context.Context, GetKVEntryArg) (KVGetResult, error)
   201  	PutKVEntry(context.Context, PutKVEntryArg) (KVPutResult, error)
   202  	ListKVNamespaces(context.Context, ListKVNamespacesArg) (KVListNamespaceResult, error)
   203  	ListKVEntries(context.Context, ListKVEntriesArg) (KVListEntryResult, error)
   204  	DelKVEntry(context.Context, DelKVEntryArg) (KVDeleteEntryResult, error)
   205  }
   206  
   207  func KvstoreProtocol(i KvstoreInterface) rpc.Protocol {
   208  	return rpc.Protocol{
   209  		Name: "keybase.1.kvstore",
   210  		Methods: map[string]rpc.ServeHandlerDescription{
   211  			"getKVEntry": {
   212  				MakeArg: func() interface{} {
   213  					var ret [1]GetKVEntryArg
   214  					return &ret
   215  				},
   216  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   217  					typedArgs, ok := args.(*[1]GetKVEntryArg)
   218  					if !ok {
   219  						err = rpc.NewTypeError((*[1]GetKVEntryArg)(nil), args)
   220  						return
   221  					}
   222  					ret, err = i.GetKVEntry(ctx, typedArgs[0])
   223  					return
   224  				},
   225  			},
   226  			"putKVEntry": {
   227  				MakeArg: func() interface{} {
   228  					var ret [1]PutKVEntryArg
   229  					return &ret
   230  				},
   231  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   232  					typedArgs, ok := args.(*[1]PutKVEntryArg)
   233  					if !ok {
   234  						err = rpc.NewTypeError((*[1]PutKVEntryArg)(nil), args)
   235  						return
   236  					}
   237  					ret, err = i.PutKVEntry(ctx, typedArgs[0])
   238  					return
   239  				},
   240  			},
   241  			"listKVNamespaces": {
   242  				MakeArg: func() interface{} {
   243  					var ret [1]ListKVNamespacesArg
   244  					return &ret
   245  				},
   246  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   247  					typedArgs, ok := args.(*[1]ListKVNamespacesArg)
   248  					if !ok {
   249  						err = rpc.NewTypeError((*[1]ListKVNamespacesArg)(nil), args)
   250  						return
   251  					}
   252  					ret, err = i.ListKVNamespaces(ctx, typedArgs[0])
   253  					return
   254  				},
   255  			},
   256  			"listKVEntries": {
   257  				MakeArg: func() interface{} {
   258  					var ret [1]ListKVEntriesArg
   259  					return &ret
   260  				},
   261  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   262  					typedArgs, ok := args.(*[1]ListKVEntriesArg)
   263  					if !ok {
   264  						err = rpc.NewTypeError((*[1]ListKVEntriesArg)(nil), args)
   265  						return
   266  					}
   267  					ret, err = i.ListKVEntries(ctx, typedArgs[0])
   268  					return
   269  				},
   270  			},
   271  			"delKVEntry": {
   272  				MakeArg: func() interface{} {
   273  					var ret [1]DelKVEntryArg
   274  					return &ret
   275  				},
   276  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   277  					typedArgs, ok := args.(*[1]DelKVEntryArg)
   278  					if !ok {
   279  						err = rpc.NewTypeError((*[1]DelKVEntryArg)(nil), args)
   280  						return
   281  					}
   282  					ret, err = i.DelKVEntry(ctx, typedArgs[0])
   283  					return
   284  				},
   285  			},
   286  		},
   287  	}
   288  }
   289  
   290  type KvstoreClient struct {
   291  	Cli rpc.GenericClient
   292  }
   293  
   294  func (c KvstoreClient) GetKVEntry(ctx context.Context, __arg GetKVEntryArg) (res KVGetResult, err error) {
   295  	err = c.Cli.Call(ctx, "keybase.1.kvstore.getKVEntry", []interface{}{__arg}, &res, 0*time.Millisecond)
   296  	return
   297  }
   298  
   299  func (c KvstoreClient) PutKVEntry(ctx context.Context, __arg PutKVEntryArg) (res KVPutResult, err error) {
   300  	err = c.Cli.Call(ctx, "keybase.1.kvstore.putKVEntry", []interface{}{__arg}, &res, 0*time.Millisecond)
   301  	return
   302  }
   303  
   304  func (c KvstoreClient) ListKVNamespaces(ctx context.Context, __arg ListKVNamespacesArg) (res KVListNamespaceResult, err error) {
   305  	err = c.Cli.Call(ctx, "keybase.1.kvstore.listKVNamespaces", []interface{}{__arg}, &res, 0*time.Millisecond)
   306  	return
   307  }
   308  
   309  func (c KvstoreClient) ListKVEntries(ctx context.Context, __arg ListKVEntriesArg) (res KVListEntryResult, err error) {
   310  	err = c.Cli.Call(ctx, "keybase.1.kvstore.listKVEntries", []interface{}{__arg}, &res, 0*time.Millisecond)
   311  	return
   312  }
   313  
   314  func (c KvstoreClient) DelKVEntry(ctx context.Context, __arg DelKVEntryArg) (res KVDeleteEntryResult, err error) {
   315  	err = c.Cli.Call(ctx, "keybase.1.kvstore.delKVEntry", []interface{}{__arg}, &res, 0*time.Millisecond)
   316  	return
   317  }