diff --git a/lists/Makefile b/lists/Makefile new file mode 100644 index 0000000..7013fdf --- /dev/null +++ b/lists/Makefile @@ -0,0 +1,29 @@ + +GOPATH:=$(shell go env GOPATH) + +.PHONY: api +api: + protoc --openapi_out=. --proto_path=. proto/lists.proto + +.PHONY: init +init: + go get -u github.com/golang/protobuf/proto + go get -u github.com/golang/protobuf/protoc-gen-go + go get github.com/micro/micro/v3/cmd/protoc-gen-micro + go get github.com/micro/micro/v3/cmd/protoc-gen-openapi + +.PHONY: proto +proto: + protoc --proto_path=. --micro_out=. --go_out=:. proto/lists.proto + +.PHONY: build +build: + go build -o lists *.go + +.PHONY: test +test: + go test -v ./... -cover + +.PHONY: docker +docker: + docker build . -t lists:latest diff --git a/lists/README.md b/lists/README.md new file mode 100644 index 0000000..8daaec5 --- /dev/null +++ b/lists/README.md @@ -0,0 +1,6 @@ +Makes a list + +# Lists Service + +Make lists for anything. Shopping, todos, mail, waitlists, absolutely anything. + diff --git a/lists/examples.json b/lists/examples.json new file mode 100644 index 0000000..7b31736 --- /dev/null +++ b/lists/examples.json @@ -0,0 +1,111 @@ + +{ + "create": [{ + "title": "Create a list", + "description": "Create a simple text based list", + "run_check": false, + "request": { + "title": "New List", + "text": "This is my list" + }, + "response": { + "list": { + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a", + "created": "2021-09-29T13:33:03+01:00", + "updated": "2021-09-29T13:33:03+01:00", + "title": "New List", + "text": "This is my list" + } + } + }], + "read": [{ + "title": "Read a list", + "description": "Read a list by its ID", + "run_check": false, + "request": { + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" + }, + "response": { + "list": { + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a", + "created": "2021-09-29T13:33:03+01:00", + "updated": "2021-09-29T13:33:03+01:00", + "title": "New List", + "text": "This is my list" + } + } + }], + "list": [{ + "title": "List all lists", + "description": "List all your available lists", + "run_check": false, + "request": {}, + "response": { + "lists": [ + { + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a", + "created": "2021-09-29T13:33:03+01:00", + "updated": "2021-09-29T13:33:03+01:00", + "title": "New List", + "text": "This is my list" + } + ] + } + }], + "update": [{ + "title": "Update a List", + "description": "Update the list title and text", + "run_check": false, + "request": { + "list": { + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a", + "title": "Update List", + "text": "Updated list text" + } + }, + "response": { + "list": { + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a", + "created": "2021-09-29T13:33:03+01:00", + "updated": "2021-09-29T13:50:20+01:00", + "title": "Update List", + "text": "Updated list text" + } + } + }], + "delete": [{ + "title": "Delete a List", + "description": "Delete a list by id", + "run_check": false, + "request": { + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" + }, + "response": { + "list": { + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a", + "created": "2021-09-29T13:33:03+01:00", + "updated": "2021-09-29T13:50:20+01:00", + "title": "Update List", + "text": "Updated list text" + } + } + }], + "events": [{ + "title": "Subscribe to events", + "description": "Subscribe to list change events", + "run_check": false, + "request": { + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a" + }, + "response": { + "event": "deleted", + "list": { + "id": "63c0cdf8-2121-11ec-a881-0242e36f037a", + "created": "2021-09-29T13:33:03+01:00", + "updated": "2021-09-29T13:50:20+01:00", + "title": "Update List", + "text": "Updated list text" + } + } + }] +} diff --git a/lists/handler/lists.go b/lists/handler/lists.go new file mode 100644 index 0000000..c9620b0 --- /dev/null +++ b/lists/handler/lists.go @@ -0,0 +1,323 @@ +package handler + +import ( + "context" + "encoding/json" + "fmt" + "time" + + "github.com/google/uuid" + "github.com/micro/micro/v3/service/client" + "github.com/micro/micro/v3/service/errors" + "github.com/micro/micro/v3/service/logger" + "github.com/micro/micro/v3/service/store" + pb "github.com/micro/services/lists/proto" + streamPb "github.com/micro/services/mq/proto" + pauth "github.com/micro/services/pkg/auth" + adminpb "github.com/micro/services/pkg/service/proto" + "github.com/micro/services/pkg/tenant" + "google.golang.org/protobuf/types/known/structpb" +) + +// New returns an initialized Lists +func New(c client.Client) *Lists { + return &Lists{ + Stream: streamPb.NewMqService("mq", c), + } +} + +// Lists implements the lists proto definition +type Lists struct { + Stream streamPb.MqService +} + +func newMessage(ev map[string]interface{}) *structpb.Struct { + st := new(structpb.Struct) + b, _ := json.Marshal(ev) + json.Unmarshal(b, st) + return st +} + +// Create inserts a new list in the store +func (h *Lists) Create(ctx context.Context, req *pb.CreateRequest, rsp *pb.CreateResponse) error { + if len(req.Name) == 0 && len(req.Items) == 0 { + return errors.BadRequest("lists.create", "missing name and text") + } + + tnt, ok := tenant.FromContext(ctx) + if !ok { + tnt = "default" + } + + // generate a key (uuid v4) + id, err := uuid.NewUUID() + if err != nil { + return err + } + + t := time.Now().Format(time.RFC3339) + // set the generated fields on the list + list := &pb.List{ + Id: id.String(), + Created: t, + Updated: t, + Name: req.Name, + Items: req.Items, + } + + key := fmt.Sprintf("%s:%s", tnt, id) + rec := store.NewRecord(key, list) + + if err = store.Write(rec); err != nil { + return errors.InternalServerError("lists.created", "failed to create list") + } + + // return the list in the response + rsp.List = list + + h.Stream.Publish(ctx, &streamPb.PublishRequest{ + Topic: "lists", + Message: newMessage(map[string]interface{}{ + "event": "create", + "list": list, + }), + }) + + return nil +} + +func (h *Lists) Read(ctx context.Context, req *pb.ReadRequest, rsp *pb.ReadResponse) error { + if len(req.Id) == 0 { + return errors.BadRequest("lists.read", "Missing List ID") + } + + tnt, ok := tenant.FromContext(ctx) + if !ok { + tnt = "default" + } + + key := fmt.Sprintf("%s:%s", tnt, req.Id) + + // read the specific list + recs, err := store.Read(key) + if err == store.ErrNotFound { + return errors.NotFound("lists.read", "List not found") + } else if err != nil { + return errors.InternalServerError("lists.read", "Error reading from store: %v", err.Error()) + } + + // Decode the list + var list *pb.List + if err := recs[0].Decode(&list); err != nil { + return errors.InternalServerError("lists.update", "Error unmarshaling JSON: %v", err.Error()) + } + + // return the list + rsp.List = list + + return nil +} + +// Update is a unary API which updates a list in the store +func (h *Lists) Update(ctx context.Context, req *pb.UpdateRequest, rsp *pb.UpdateResponse) error { + // Validate the request + if req.List == nil { + return errors.BadRequest("lists.update", "Missing List") + } + if len(req.List.Id) == 0 { + return errors.BadRequest("lists.update", "Missing List ID") + } + + tnt, ok := tenant.FromContext(ctx) + if !ok { + tnt = "default" + } + + key := fmt.Sprintf("%s:%s", tnt, req.List.Id) + + // read the specific list + recs, err := store.Read(key) + if err == store.ErrNotFound { + return errors.NotFound("lists.update", "List not found") + } else if err != nil { + return errors.InternalServerError("lists.update", "Error reading from store: %v", err.Error()) + } + + // Decode the list + var list *pb.List + if err := recs[0].Decode(&list); err != nil { + return errors.InternalServerError("lists.update", "Error unmarshaling JSON: %v", err.Error()) + } + + // Update the lists name and text + list.Name = req.List.Name + list.Items = req.List.Items + list.Updated = time.Now().Format(time.RFC3339) + + rec := store.NewRecord(key, list) + + // Write the updated list to the store + if err = store.Write(rec); err != nil { + return errors.InternalServerError("lists.update", "Error writing to store: %v", err.Error()) + } + + h.Stream.Publish(ctx, &streamPb.PublishRequest{ + Topic: "lists", + Message: newMessage(map[string]interface{}{ + "event": "update", + "list": list, + }), + }) + + rsp.List = list + + return nil +} + +func (h *Lists) Events(ctx context.Context, req *pb.EventsRequest, stream pb.Lists_EventsStream) error { + backendStream, err := h.Stream.Subscribe(ctx, &streamPb.SubscribeRequest{ + Topic: "lists", + }) + if err != nil { + return errors.InternalServerError("lists.subscribe", "Failed to subscribe to lists") + } + + for { + select { + case <-ctx.Done(): + return nil + default: + } + + // receive messages from the stream + msg, err := backendStream.Recv() + if err != nil { + return nil + } + + v, err := msg.Message.MarshalJSON() + if err != nil { + continue + } + + rsp := new(pb.EventsResponse) + + if err := json.Unmarshal(v, rsp); err != nil { + continue + } + + list := rsp.List + + // filter if necessary by id + if len(req.Id) > 0 && list.Id != req.Id { + continue + } + + // send back the event to the client + if err := stream.Send(rsp); err != nil { + return nil + } + } + + return nil +} + +// Delete removes the list from the store, looking up using ID +func (h *Lists) Delete(ctx context.Context, req *pb.DeleteRequest, rsp *pb.DeleteResponse) error { + // Validate the request + if len(req.Id) == 0 { + return errors.BadRequest("lists.delete", "Missing List ID") + } + + tnt, ok := tenant.FromContext(ctx) + if !ok { + tnt = "default" + } + + key := fmt.Sprintf("%s:%s", tnt, req.Id) + + // read the specific list + recs, err := store.Read(key) + if err == store.ErrNotFound { + return nil + } else if err != nil { + return errors.InternalServerError("lists.delete", "Error reading from store: %v", err.Error()) + } + + // Decode the list + var list *pb.List + if err := recs[0].Decode(&list); err != nil { + return errors.InternalServerError("lists.delete", "Error unmarshaling JSON: %v", err.Error()) + } + + // now delete it + if err := store.Delete(key); err != nil && err != store.ErrNotFound { + return errors.InternalServerError("lists.delete", "Failed to delete list") + } + + h.Stream.Publish(ctx, &streamPb.PublishRequest{ + Topic: "lists", + Message: newMessage(map[string]interface{}{ + "event": "delete", + "list": list, + }), + }) + + rsp.List = list + + return nil +} + +// List returns all of the lists in the store +func (h *Lists) List(ctx context.Context, req *pb.ListRequest, rsp *pb.ListResponse) error { + tnt, ok := tenant.FromContext(ctx) + if !ok { + tnt = "default" + } + + key := fmt.Sprintf("%s:", tnt) + + // Retrieve all of the records in the store + recs, err := store.Read(key, store.ReadPrefix()) + if err != nil { + return errors.InternalServerError("lists.list", "Error reading from store: %v", err.Error()) + } + + // Initialize the response lists slice + rsp.Lists = make([]*pb.List, len(recs)) + + // Unmarshal the lists into the response + for i, r := range recs { + if err := r.Decode(&rsp.Lists[i]); err != nil { + return errors.InternalServerError("lists.list", "Error decoding list: %v", err.Error()) + } + } + + return nil +} + +func (h *Lists) DeleteData(ctx context.Context, request *adminpb.DeleteDataRequest, response *adminpb.DeleteDataResponse) error { + method := "admin.DeleteData" + _, err := pauth.VerifyMicroAdmin(ctx, method) + if err != nil { + return err + } + + if len(request.TenantId) < 10 { // deliberate length check so we don't delete all the things + return errors.BadRequest(method, "Missing tenant ID") + } + + keys, err := store.List(store.ListPrefix(request.TenantId)) + if err != nil { + return err + } + + for _, k := range keys { + if err := store.Delete(k); err != nil { + return err + } + } + + logger.Infof("Deleted %d keys for %s", len(keys), request.TenantId) + return nil +} diff --git a/lists/main.go b/lists/main.go new file mode 100644 index 0000000..b86a186 --- /dev/null +++ b/lists/main.go @@ -0,0 +1,30 @@ +package main + +import ( + "github.com/micro/micro/v3/service" + log "github.com/micro/micro/v3/service/logger" + "github.com/micro/services/lists/handler" + pb "github.com/micro/services/lists/proto" + admin "github.com/micro/services/pkg/service/proto" +) + +func main() { + // New Service + srv := service.New( + service.Name("lists"), + service.Version("latest"), + ) + + // Initialise service + srv.Init() + + h := handler.New(srv.Client()) + // Register Handler + pb.RegisterListsHandler(srv.Server(), h) + admin.RegisterAdminHandler(srv.Server(), h) + + // Run service + if err := srv.Run(); err != nil { + log.Fatal(err) + } +} diff --git a/lists/proto/lists.pb.go b/lists/proto/lists.pb.go new file mode 100644 index 0000000..fe6b584 --- /dev/null +++ b/lists/proto/lists.pb.go @@ -0,0 +1,1001 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.1 +// protoc v3.15.6 +// source: proto/lists.proto + +package lists + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type List struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // unique id for the list, generated if not specified + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // time at which the list was created + Created string `protobuf:"bytes,2,opt,name=created,proto3" json:"created,omitempty"` + // time at which the list was updated + Updated string `protobuf:"bytes,3,opt,name=updated,proto3" json:"updated,omitempty"` + // name of the list + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + // items within the list + Items []string `protobuf:"bytes,5,rep,name=items,proto3" json:"items,omitempty"` +} + +func (x *List) Reset() { + *x = List{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lists_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *List) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*List) ProtoMessage() {} + +func (x *List) ProtoReflect() protoreflect.Message { + mi := &file_proto_lists_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use List.ProtoReflect.Descriptor instead. +func (*List) Descriptor() ([]byte, []int) { + return file_proto_lists_proto_rawDescGZIP(), []int{0} +} + +func (x *List) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *List) GetCreated() string { + if x != nil { + return x.Created + } + return "" +} + +func (x *List) GetUpdated() string { + if x != nil { + return x.Updated + } + return "" +} + +func (x *List) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *List) GetItems() []string { + if x != nil { + return x.Items + } + return nil +} + +// Create a new list +type CreateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // list name + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // list items + Items []string `protobuf:"bytes,2,rep,name=items,proto3" json:"items,omitempty"` +} + +func (x *CreateRequest) Reset() { + *x = CreateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lists_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateRequest) ProtoMessage() {} + +func (x *CreateRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_lists_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateRequest.ProtoReflect.Descriptor instead. +func (*CreateRequest) Descriptor() ([]byte, []int) { + return file_proto_lists_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CreateRequest) GetItems() []string { + if x != nil { + return x.Items + } + return nil +} + +type CreateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The created list + List *List `protobuf:"bytes,1,opt,name=list,proto3" json:"list,omitempty"` +} + +func (x *CreateResponse) Reset() { + *x = CreateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lists_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateResponse) ProtoMessage() {} + +func (x *CreateResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_lists_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateResponse.ProtoReflect.Descriptor instead. +func (*CreateResponse) Descriptor() ([]byte, []int) { + return file_proto_lists_proto_rawDescGZIP(), []int{2} +} + +func (x *CreateResponse) GetList() *List { + if x != nil { + return x.List + } + return nil +} + +// Read a list +type ReadRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // the list id + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *ReadRequest) Reset() { + *x = ReadRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lists_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadRequest) ProtoMessage() {} + +func (x *ReadRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_lists_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadRequest.ProtoReflect.Descriptor instead. +func (*ReadRequest) Descriptor() ([]byte, []int) { + return file_proto_lists_proto_rawDescGZIP(), []int{3} +} + +func (x *ReadRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type ReadResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The list + List *List `protobuf:"bytes,1,opt,name=list,proto3" json:"list,omitempty"` +} + +func (x *ReadResponse) Reset() { + *x = ReadResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lists_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadResponse) ProtoMessage() {} + +func (x *ReadResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_lists_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadResponse.ProtoReflect.Descriptor instead. +func (*ReadResponse) Descriptor() ([]byte, []int) { + return file_proto_lists_proto_rawDescGZIP(), []int{4} +} + +func (x *ReadResponse) GetList() *List { + if x != nil { + return x.List + } + return nil +} + +// Update a list +type UpdateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + List *List `protobuf:"bytes,1,opt,name=list,proto3" json:"list,omitempty"` +} + +func (x *UpdateRequest) Reset() { + *x = UpdateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lists_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateRequest) ProtoMessage() {} + +func (x *UpdateRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_lists_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateRequest.ProtoReflect.Descriptor instead. +func (*UpdateRequest) Descriptor() ([]byte, []int) { + return file_proto_lists_proto_rawDescGZIP(), []int{5} +} + +func (x *UpdateRequest) GetList() *List { + if x != nil { + return x.List + } + return nil +} + +type UpdateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + List *List `protobuf:"bytes,1,opt,name=list,proto3" json:"list,omitempty"` +} + +func (x *UpdateResponse) Reset() { + *x = UpdateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lists_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateResponse) ProtoMessage() {} + +func (x *UpdateResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_lists_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateResponse.ProtoReflect.Descriptor instead. +func (*UpdateResponse) Descriptor() ([]byte, []int) { + return file_proto_lists_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateResponse) GetList() *List { + if x != nil { + return x.List + } + return nil +} + +// Delete a list +type DeleteRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // specify the id of the list + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *DeleteRequest) Reset() { + *x = DeleteRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lists_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteRequest) ProtoMessage() {} + +func (x *DeleteRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_lists_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteRequest.ProtoReflect.Descriptor instead. +func (*DeleteRequest) Descriptor() ([]byte, []int) { + return file_proto_lists_proto_rawDescGZIP(), []int{7} +} + +func (x *DeleteRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type DeleteResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + List *List `protobuf:"bytes,1,opt,name=list,proto3" json:"list,omitempty"` +} + +func (x *DeleteResponse) Reset() { + *x = DeleteResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lists_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteResponse) ProtoMessage() {} + +func (x *DeleteResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_lists_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteResponse.ProtoReflect.Descriptor instead. +func (*DeleteResponse) Descriptor() ([]byte, []int) { + return file_proto_lists_proto_rawDescGZIP(), []int{8} +} + +func (x *DeleteResponse) GetList() *List { + if x != nil { + return x.List + } + return nil +} + +// List all the lists +type ListRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListRequest) Reset() { + *x = ListRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lists_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRequest) ProtoMessage() {} + +func (x *ListRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_lists_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListRequest.ProtoReflect.Descriptor instead. +func (*ListRequest) Descriptor() ([]byte, []int) { + return file_proto_lists_proto_rawDescGZIP(), []int{9} +} + +type ListResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // the list of lists + Lists []*List `protobuf:"bytes,1,rep,name=lists,proto3" json:"lists,omitempty"` +} + +func (x *ListResponse) Reset() { + *x = ListResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lists_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListResponse) ProtoMessage() {} + +func (x *ListResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_lists_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListResponse.ProtoReflect.Descriptor instead. +func (*ListResponse) Descriptor() ([]byte, []int) { + return file_proto_lists_proto_rawDescGZIP(), []int{10} +} + +func (x *ListResponse) GetLists() []*List { + if x != nil { + return x.Lists + } + return nil +} + +// Subscribe to lists events +type EventsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // optionally specify a list id + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *EventsRequest) Reset() { + *x = EventsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lists_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EventsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EventsRequest) ProtoMessage() {} + +func (x *EventsRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_lists_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EventsRequest.ProtoReflect.Descriptor instead. +func (*EventsRequest) Descriptor() ([]byte, []int) { + return file_proto_lists_proto_rawDescGZIP(), []int{11} +} + +func (x *EventsRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type EventsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // the event which occured; create, delete, update + Event string `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"` + // the list which the operation occured on + List *List `protobuf:"bytes,2,opt,name=list,proto3" json:"list,omitempty"` +} + +func (x *EventsResponse) Reset() { + *x = EventsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lists_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EventsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EventsResponse) ProtoMessage() {} + +func (x *EventsResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_lists_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EventsResponse.ProtoReflect.Descriptor instead. +func (*EventsResponse) Descriptor() ([]byte, []int) { + return file_proto_lists_proto_rawDescGZIP(), []int{12} +} + +func (x *EventsResponse) GetEvent() string { + if x != nil { + return x.Event + } + return "" +} + +func (x *EventsResponse) GetList() *List { + if x != nil { + return x.List + } + return nil +} + +var File_proto_lists_proto protoreflect.FileDescriptor + +var file_proto_lists_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x22, 0x74, 0x0a, 0x04, 0x4c, 0x69, + 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x18, 0x0a, 0x07, + 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, + 0x65, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, + 0x22, 0x39, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x31, 0x0a, 0x0e, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, + 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6c, 0x69, + 0x73, 0x74, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x1d, + 0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x2f, 0x0a, + 0x0c, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, + 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6c, 0x69, + 0x73, 0x74, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x30, + 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x1f, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, + 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, + 0x22, 0x31, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0b, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x04, 0x6c, + 0x69, 0x73, 0x74, 0x22, 0x1f, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x64, 0x22, 0x31, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x0d, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x31, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x05, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x05, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x22, 0x1f, 0x0a, 0x0d, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x47, 0x0a, 0x0e, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0b, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x04, 0x6c, + 0x69, 0x73, 0x74, 0x32, 0xc7, 0x02, 0x0a, 0x05, 0x4c, 0x69, 0x73, 0x74, 0x73, 0x12, 0x2f, 0x0a, + 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x12, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6c, 0x69, 0x73, 0x74, + 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, + 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x14, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x73, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, + 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x04, 0x52, 0x65, 0x61, 0x64, 0x12, 0x12, 0x2e, + 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x13, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x12, 0x14, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, + 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x14, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, + 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x14, + 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x2e, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x0f, 0x5a, + 0x0d, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6c, 0x69, 0x73, 0x74, 0x73, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_proto_lists_proto_rawDescOnce sync.Once + file_proto_lists_proto_rawDescData = file_proto_lists_proto_rawDesc +) + +func file_proto_lists_proto_rawDescGZIP() []byte { + file_proto_lists_proto_rawDescOnce.Do(func() { + file_proto_lists_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_lists_proto_rawDescData) + }) + return file_proto_lists_proto_rawDescData +} + +var file_proto_lists_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_proto_lists_proto_goTypes = []interface{}{ + (*List)(nil), // 0: lists.List + (*CreateRequest)(nil), // 1: lists.CreateRequest + (*CreateResponse)(nil), // 2: lists.CreateResponse + (*ReadRequest)(nil), // 3: lists.ReadRequest + (*ReadResponse)(nil), // 4: lists.ReadResponse + (*UpdateRequest)(nil), // 5: lists.UpdateRequest + (*UpdateResponse)(nil), // 6: lists.UpdateResponse + (*DeleteRequest)(nil), // 7: lists.DeleteRequest + (*DeleteResponse)(nil), // 8: lists.DeleteResponse + (*ListRequest)(nil), // 9: lists.ListRequest + (*ListResponse)(nil), // 10: lists.ListResponse + (*EventsRequest)(nil), // 11: lists.EventsRequest + (*EventsResponse)(nil), // 12: lists.EventsResponse +} +var file_proto_lists_proto_depIdxs = []int32{ + 0, // 0: lists.CreateResponse.list:type_name -> lists.List + 0, // 1: lists.ReadResponse.list:type_name -> lists.List + 0, // 2: lists.UpdateRequest.list:type_name -> lists.List + 0, // 3: lists.UpdateResponse.list:type_name -> lists.List + 0, // 4: lists.DeleteResponse.list:type_name -> lists.List + 0, // 5: lists.ListResponse.lists:type_name -> lists.List + 0, // 6: lists.EventsResponse.list:type_name -> lists.List + 9, // 7: lists.Lists.List:input_type -> lists.ListRequest + 1, // 8: lists.Lists.Create:input_type -> lists.CreateRequest + 3, // 9: lists.Lists.Read:input_type -> lists.ReadRequest + 7, // 10: lists.Lists.Delete:input_type -> lists.DeleteRequest + 5, // 11: lists.Lists.Update:input_type -> lists.UpdateRequest + 11, // 12: lists.Lists.Events:input_type -> lists.EventsRequest + 10, // 13: lists.Lists.List:output_type -> lists.ListResponse + 2, // 14: lists.Lists.Create:output_type -> lists.CreateResponse + 4, // 15: lists.Lists.Read:output_type -> lists.ReadResponse + 8, // 16: lists.Lists.Delete:output_type -> lists.DeleteResponse + 6, // 17: lists.Lists.Update:output_type -> lists.UpdateResponse + 12, // 18: lists.Lists.Events:output_type -> lists.EventsResponse + 13, // [13:19] is the sub-list for method output_type + 7, // [7:13] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_proto_lists_proto_init() } +func file_proto_lists_proto_init() { + if File_proto_lists_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_proto_lists_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*List); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_lists_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_lists_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_lists_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReadRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_lists_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReadResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_lists_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_lists_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_lists_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_lists_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_lists_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_lists_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_lists_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EventsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_lists_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EventsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_proto_lists_proto_rawDesc, + NumEnums: 0, + NumMessages: 13, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_proto_lists_proto_goTypes, + DependencyIndexes: file_proto_lists_proto_depIdxs, + MessageInfos: file_proto_lists_proto_msgTypes, + }.Build() + File_proto_lists_proto = out.File + file_proto_lists_proto_rawDesc = nil + file_proto_lists_proto_goTypes = nil + file_proto_lists_proto_depIdxs = nil +} diff --git a/lists/proto/lists.pb.micro.go b/lists/proto/lists.pb.micro.go new file mode 100644 index 0000000..6e8911f --- /dev/null +++ b/lists/proto/lists.pb.micro.go @@ -0,0 +1,253 @@ +// Code generated by protoc-gen-micro. DO NOT EDIT. +// source: proto/lists.proto + +package lists + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +import ( + context "context" + api "github.com/micro/micro/v3/service/api" + client "github.com/micro/micro/v3/service/client" + server "github.com/micro/micro/v3/service/server" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +// Reference imports to suppress errors if they are not otherwise used. +var _ api.Endpoint +var _ context.Context +var _ client.Option +var _ server.Option + +// Api Endpoints for Lists service + +func NewListsEndpoints() []*api.Endpoint { + return []*api.Endpoint{} +} + +// Client API for Lists service + +type ListsService interface { + List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) + Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error) + Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) + Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) + Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error) + Events(ctx context.Context, in *EventsRequest, opts ...client.CallOption) (Lists_EventsService, error) +} + +type listsService struct { + c client.Client + name string +} + +func NewListsService(name string, c client.Client) ListsService { + return &listsService{ + c: c, + name: name, + } +} + +func (c *listsService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) { + req := c.c.NewRequest(c.name, "Lists.List", in) + out := new(ListResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *listsService) Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error) { + req := c.c.NewRequest(c.name, "Lists.Create", in) + out := new(CreateResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *listsService) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) { + req := c.c.NewRequest(c.name, "Lists.Read", in) + out := new(ReadResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *listsService) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) { + req := c.c.NewRequest(c.name, "Lists.Delete", in) + out := new(DeleteResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *listsService) Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error) { + req := c.c.NewRequest(c.name, "Lists.Update", in) + out := new(UpdateResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *listsService) Events(ctx context.Context, in *EventsRequest, opts ...client.CallOption) (Lists_EventsService, error) { + req := c.c.NewRequest(c.name, "Lists.Events", &EventsRequest{}) + stream, err := c.c.Stream(ctx, req, opts...) + if err != nil { + return nil, err + } + if err := stream.Send(in); err != nil { + return nil, err + } + return &listsServiceEvents{stream}, nil +} + +type Lists_EventsService interface { + Context() context.Context + SendMsg(interface{}) error + RecvMsg(interface{}) error + Close() error + Recv() (*EventsResponse, error) +} + +type listsServiceEvents struct { + stream client.Stream +} + +func (x *listsServiceEvents) Close() error { + return x.stream.Close() +} + +func (x *listsServiceEvents) Context() context.Context { + return x.stream.Context() +} + +func (x *listsServiceEvents) SendMsg(m interface{}) error { + return x.stream.Send(m) +} + +func (x *listsServiceEvents) RecvMsg(m interface{}) error { + return x.stream.Recv(m) +} + +func (x *listsServiceEvents) Recv() (*EventsResponse, error) { + m := new(EventsResponse) + err := x.stream.Recv(m) + if err != nil { + return nil, err + } + return m, nil +} + +// Server API for Lists service + +type ListsHandler interface { + List(context.Context, *ListRequest, *ListResponse) error + Create(context.Context, *CreateRequest, *CreateResponse) error + Read(context.Context, *ReadRequest, *ReadResponse) error + Delete(context.Context, *DeleteRequest, *DeleteResponse) error + Update(context.Context, *UpdateRequest, *UpdateResponse) error + Events(context.Context, *EventsRequest, Lists_EventsStream) error +} + +func RegisterListsHandler(s server.Server, hdlr ListsHandler, opts ...server.HandlerOption) error { + type lists interface { + List(ctx context.Context, in *ListRequest, out *ListResponse) error + Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error + Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error + Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error + Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error + Events(ctx context.Context, stream server.Stream) error + } + type Lists struct { + lists + } + h := &listsHandler{hdlr} + return s.Handle(s.NewHandler(&Lists{h}, opts...)) +} + +type listsHandler struct { + ListsHandler +} + +func (h *listsHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error { + return h.ListsHandler.List(ctx, in, out) +} + +func (h *listsHandler) Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error { + return h.ListsHandler.Create(ctx, in, out) +} + +func (h *listsHandler) Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error { + return h.ListsHandler.Read(ctx, in, out) +} + +func (h *listsHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error { + return h.ListsHandler.Delete(ctx, in, out) +} + +func (h *listsHandler) Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error { + return h.ListsHandler.Update(ctx, in, out) +} + +func (h *listsHandler) Events(ctx context.Context, stream server.Stream) error { + m := new(EventsRequest) + if err := stream.Recv(m); err != nil { + return err + } + return h.ListsHandler.Events(ctx, m, &listsEventsStream{stream}) +} + +type Lists_EventsStream interface { + Context() context.Context + SendMsg(interface{}) error + RecvMsg(interface{}) error + Close() error + Send(*EventsResponse) error +} + +type listsEventsStream struct { + stream server.Stream +} + +func (x *listsEventsStream) Close() error { + return x.stream.Close() +} + +func (x *listsEventsStream) Context() context.Context { + return x.stream.Context() +} + +func (x *listsEventsStream) SendMsg(m interface{}) error { + return x.stream.Send(m) +} + +func (x *listsEventsStream) RecvMsg(m interface{}) error { + return x.stream.Recv(m) +} + +func (x *listsEventsStream) Send(m *EventsResponse) error { + return x.stream.Send(m) +} diff --git a/lists/proto/lists.proto b/lists/proto/lists.proto new file mode 100644 index 0000000..e1bd47e --- /dev/null +++ b/lists/proto/lists.proto @@ -0,0 +1,91 @@ +syntax = "proto3"; + +package lists; + +option go_package = "./proto;lists"; + +service Lists { + rpc List(ListRequest) returns (ListResponse); + rpc Create(CreateRequest) returns (CreateResponse); + rpc Read(ReadRequest) returns (ReadResponse); + rpc Delete(DeleteRequest) returns (DeleteResponse); + rpc Update(UpdateRequest) returns (UpdateResponse); + rpc Events(EventsRequest) returns (stream EventsResponse); +} + +message List { + // unique id for the list, generated if not specified + string id = 1; + // time at which the list was created + string created = 2; + // time at which the list was updated + string updated = 3; + // name of the list + string name = 4; + // items within the list + repeated string items = 5; +} + +// Create a new list +message CreateRequest { + // list name + string name = 1; + // list items + repeated string items = 2; +} + +message CreateResponse { + // The created list + List list = 1; +} + +// Read a list +message ReadRequest { + // the list id + string id = 1; +} + +message ReadResponse { + // The list + List list = 1; +} + +// Update a list +message UpdateRequest { + List list = 1; +} + +message UpdateResponse { + List list = 1; +} + +// Delete a list +message DeleteRequest { + // specify the id of the list + string id = 1; +} + +message DeleteResponse { + List list = 1; +} + +// List all the lists +message ListRequest {} + +message ListResponse { + // the list of lists + repeated List lists = 1; +} + +// Subscribe to lists events +message EventsRequest { + // optionally specify a list id + string id = 1; +} + +message EventsResponse { + // the event which occured; create, delete, update + string event = 1; + // the list which the operation occured on + List list = 2; +} diff --git a/lists/publicapi.json b/lists/publicapi.json new file mode 100644 index 0000000..aab0b92 --- /dev/null +++ b/lists/publicapi.json @@ -0,0 +1,6 @@ +{ + "name": "lists", + "icon": "✔️", + "category": "storage", + "display_name": "Lists" +}