Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: api/attachment_service.proto
package apiconnect
import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
api "github.com/usememos/memos/proto/gen/api"
emptypb "google.golang.org/protobuf/types/known/emptypb"
http "net/http"
strings "strings"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0
const (
// AttachmentServiceName is the fully-qualified name of the AttachmentService service.
AttachmentServiceName = "memos.api.AttachmentService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// AttachmentServiceListAttachmentsProcedure is the fully-qualified name of the AttachmentService's
// ListAttachments RPC.
AttachmentServiceListAttachmentsProcedure = "/memos.api.AttachmentService/ListAttachments"
// AttachmentServiceGetAttachmentProcedure is the fully-qualified name of the AttachmentService's
// GetAttachment RPC.
AttachmentServiceGetAttachmentProcedure = "/memos.api.AttachmentService/GetAttachment"
// AttachmentServiceCreateAttachmentProcedure is the fully-qualified name of the AttachmentService's
// CreateAttachment RPC.
AttachmentServiceCreateAttachmentProcedure = "/memos.api.AttachmentService/CreateAttachment"
// AttachmentServiceUpdateAttachmentProcedure is the fully-qualified name of the AttachmentService's
// UpdateAttachment RPC.
AttachmentServiceUpdateAttachmentProcedure = "/memos.api.AttachmentService/UpdateAttachment"
// AttachmentServiceDeleteAttachmentProcedure is the fully-qualified name of the AttachmentService's
// DeleteAttachment RPC.
AttachmentServiceDeleteAttachmentProcedure = "/memos.api.AttachmentService/DeleteAttachment"
// AttachmentServiceBatchDeleteAttachmentsProcedure is the fully-qualified name of the
// AttachmentService's BatchDeleteAttachments RPC.
AttachmentServiceBatchDeleteAttachmentsProcedure = "/memos.api.AttachmentService/BatchDeleteAttachments"
// AttachmentServiceUploadAttachmentProcedure is the fully-qualified name of the AttachmentService's
// UploadAttachment RPC.
AttachmentServiceUploadAttachmentProcedure = "/memos.api.AttachmentService/UploadAttachment"
)
// AttachmentServiceClient is a client for the memos.api.AttachmentService service.
type AttachmentServiceClient interface {
// ListAttachments lists attachments linked to memos the caller can read, plus the caller's unlinked uploads.
ListAttachments(context.Context, *connect.Request[api.ListAttachmentsRequest]) (*connect.Response[api.ListAttachmentsResponse], error)
// GetAttachment gets an attachment by name. An unlinked attachment is visible only to its uploader and admins;
// a linked attachment follows the read access of its memo.
GetAttachment(context.Context, *connect.Request[api.GetAttachmentRequest]) (*connect.Response[api.Attachment], error)
// CreateAttachment creates an attachment from inline content.
CreateAttachment(context.Context, *connect.Request[api.CreateAttachmentRequest]) (*connect.Response[api.Attachment], error)
// UpdateAttachment updates an attachment. Only `filename` can be updated. The caller must be the uploader or an
// admin.
UpdateAttachment(context.Context, *connect.Request[api.UpdateAttachmentRequest]) (*connect.Response[api.Attachment], error)
// DeleteAttachment deletes an attachment uploaded by the caller.
DeleteAttachment(context.Context, *connect.Request[api.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error)
// BatchDeleteAttachments deletes up to 100 attachments in one atomic request. The caller must be the uploader of
// each attachment or an admin.
BatchDeleteAttachments(context.Context, *connect.Request[api.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error)
// UploadAttachment uploads a file in bounded chunks. The first call carries the spec and returns an upload_id;
// later calls carry that upload_id. Uploads are bound to the authenticated user, expire after 30 minutes of
// inactivity, and do not survive a server restart.
UploadAttachment(context.Context, *connect.Request[api.UploadAttachmentRequest]) (*connect.Response[api.UploadAttachmentResponse], error)
}
// NewAttachmentServiceClient constructs a client for the memos.api.AttachmentService service. By
// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
// connect.WithGRPC() or connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewAttachmentServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) AttachmentServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
attachmentServiceMethods := api.File_api_attachment_service_proto.Services().ByName("AttachmentService").Methods()
return &attachmentServiceClient{
listAttachments: connect.NewClient[api.ListAttachmentsRequest, api.ListAttachmentsResponse](
httpClient,
baseURL+AttachmentServiceListAttachmentsProcedure,
connect.WithSchema(attachmentServiceMethods.ByName("ListAttachments")),
connect.WithClientOptions(opts...),
),
getAttachment: connect.NewClient[api.GetAttachmentRequest, api.Attachment](
httpClient,
baseURL+AttachmentServiceGetAttachmentProcedure,
connect.WithSchema(attachmentServiceMethods.ByName("GetAttachment")),
connect.WithClientOptions(opts...),
),
createAttachment: connect.NewClient[api.CreateAttachmentRequest, api.Attachment](
httpClient,
baseURL+AttachmentServiceCreateAttachmentProcedure,
connect.WithSchema(attachmentServiceMethods.ByName("CreateAttachment")),
connect.WithClientOptions(opts...),
),
updateAttachment: connect.NewClient[api.UpdateAttachmentRequest, api.Attachment](
httpClient,
baseURL+AttachmentServiceUpdateAttachmentProcedure,
connect.WithSchema(attachmentServiceMethods.ByName("UpdateAttachment")),
connect.WithClientOptions(opts...),
),
deleteAttachment: connect.NewClient[api.DeleteAttachmentRequest, emptypb.Empty](
httpClient,
baseURL+AttachmentServiceDeleteAttachmentProcedure,
connect.WithSchema(attachmentServiceMethods.ByName("DeleteAttachment")),
connect.WithClientOptions(opts...),
),
batchDeleteAttachments: connect.NewClient[api.BatchDeleteAttachmentsRequest, emptypb.Empty](
httpClient,
baseURL+AttachmentServiceBatchDeleteAttachmentsProcedure,
connect.WithSchema(attachmentServiceMethods.ByName("BatchDeleteAttachments")),
connect.WithClientOptions(opts...),
),
uploadAttachment: connect.NewClient[api.UploadAttachmentRequest, api.UploadAttachmentResponse](
httpClient,
baseURL+AttachmentServiceUploadAttachmentProcedure,
connect.WithSchema(attachmentServiceMethods.ByName("UploadAttachment")),
connect.WithClientOptions(opts...),
),
}
}
// attachmentServiceClient implements AttachmentServiceClient.
type attachmentServiceClient struct {
listAttachments *connect.Client[api.ListAttachmentsRequest, api.ListAttachmentsResponse]
getAttachment *connect.Client[api.GetAttachmentRequest, api.Attachment]
createAttachment *connect.Client[api.CreateAttachmentRequest, api.Attachment]
updateAttachment *connect.Client[api.UpdateAttachmentRequest, api.Attachment]
deleteAttachment *connect.Client[api.DeleteAttachmentRequest, emptypb.Empty]
batchDeleteAttachments *connect.Client[api.BatchDeleteAttachmentsRequest, emptypb.Empty]
uploadAttachment *connect.Client[api.UploadAttachmentRequest, api.UploadAttachmentResponse]
}
// ListAttachments calls memos.api.AttachmentService.ListAttachments.
func (c *attachmentServiceClient) ListAttachments(ctx context.Context, req *connect.Request[api.ListAttachmentsRequest]) (*connect.Response[api.ListAttachmentsResponse], error) {
return c.listAttachments.CallUnary(ctx, req)
}
// GetAttachment calls memos.api.AttachmentService.GetAttachment.
func (c *attachmentServiceClient) GetAttachment(ctx context.Context, req *connect.Request[api.GetAttachmentRequest]) (*connect.Response[api.Attachment], error) {
return c.getAttachment.CallUnary(ctx, req)
}
// CreateAttachment calls memos.api.AttachmentService.CreateAttachment.
func (c *attachmentServiceClient) CreateAttachment(ctx context.Context, req *connect.Request[api.CreateAttachmentRequest]) (*connect.Response[api.Attachment], error) {
return c.createAttachment.CallUnary(ctx, req)
}
// UpdateAttachment calls memos.api.AttachmentService.UpdateAttachment.
func (c *attachmentServiceClient) UpdateAttachment(ctx context.Context, req *connect.Request[api.UpdateAttachmentRequest]) (*connect.Response[api.Attachment], error) {
return c.updateAttachment.CallUnary(ctx, req)
}
// DeleteAttachment calls memos.api.AttachmentService.DeleteAttachment.
func (c *attachmentServiceClient) DeleteAttachment(ctx context.Context, req *connect.Request[api.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error) {
return c.deleteAttachment.CallUnary(ctx, req)
}
// BatchDeleteAttachments calls memos.api.AttachmentService.BatchDeleteAttachments.
func (c *attachmentServiceClient) BatchDeleteAttachments(ctx context.Context, req *connect.Request[api.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error) {
return c.batchDeleteAttachments.CallUnary(ctx, req)
}
// UploadAttachment calls memos.api.AttachmentService.UploadAttachment.
func (c *attachmentServiceClient) UploadAttachment(ctx context.Context, req *connect.Request[api.UploadAttachmentRequest]) (*connect.Response[api.UploadAttachmentResponse], error) {
return c.uploadAttachment.CallUnary(ctx, req)
}
// AttachmentServiceHandler is an implementation of the memos.api.AttachmentService service.
type AttachmentServiceHandler interface {
// ListAttachments lists attachments linked to memos the caller can read, plus the caller's unlinked uploads.
ListAttachments(context.Context, *connect.Request[api.ListAttachmentsRequest]) (*connect.Response[api.ListAttachmentsResponse], error)
// GetAttachment gets an attachment by name. An unlinked attachment is visible only to its uploader and admins;
// a linked attachment follows the read access of its memo.
GetAttachment(context.Context, *connect.Request[api.GetAttachmentRequest]) (*connect.Response[api.Attachment], error)
// CreateAttachment creates an attachment from inline content.
CreateAttachment(context.Context, *connect.Request[api.CreateAttachmentRequest]) (*connect.Response[api.Attachment], error)
// UpdateAttachment updates an attachment. Only `filename` can be updated. The caller must be the uploader or an
// admin.
UpdateAttachment(context.Context, *connect.Request[api.UpdateAttachmentRequest]) (*connect.Response[api.Attachment], error)
// DeleteAttachment deletes an attachment uploaded by the caller.
DeleteAttachment(context.Context, *connect.Request[api.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error)
// BatchDeleteAttachments deletes up to 100 attachments in one atomic request. The caller must be the uploader of
// each attachment or an admin.
BatchDeleteAttachments(context.Context, *connect.Request[api.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error)
// UploadAttachment uploads a file in bounded chunks. The first call carries the spec and returns an upload_id;
// later calls carry that upload_id. Uploads are bound to the authenticated user, expire after 30 minutes of
// inactivity, and do not survive a server restart.
UploadAttachment(context.Context, *connect.Request[api.UploadAttachmentRequest]) (*connect.Response[api.UploadAttachmentResponse], error)
}
// NewAttachmentServiceHandler builds an HTTP handler from the service implementation. It returns
// the path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewAttachmentServiceHandler(svc AttachmentServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
attachmentServiceMethods := api.File_api_attachment_service_proto.Services().ByName("AttachmentService").Methods()
attachmentServiceListAttachmentsHandler := connect.NewUnaryHandler(
AttachmentServiceListAttachmentsProcedure,
svc.ListAttachments,
connect.WithSchema(attachmentServiceMethods.ByName("ListAttachments")),
connect.WithHandlerOptions(opts...),
)
attachmentServiceGetAttachmentHandler := connect.NewUnaryHandler(
AttachmentServiceGetAttachmentProcedure,
svc.GetAttachment,
connect.WithSchema(attachmentServiceMethods.ByName("GetAttachment")),
connect.WithHandlerOptions(opts...),
)
attachmentServiceCreateAttachmentHandler := connect.NewUnaryHandler(
AttachmentServiceCreateAttachmentProcedure,
svc.CreateAttachment,
connect.WithSchema(attachmentServiceMethods.ByName("CreateAttachment")),
connect.WithHandlerOptions(opts...),
)
attachmentServiceUpdateAttachmentHandler := connect.NewUnaryHandler(
AttachmentServiceUpdateAttachmentProcedure,
svc.UpdateAttachment,
connect.WithSchema(attachmentServiceMethods.ByName("UpdateAttachment")),
connect.WithHandlerOptions(opts...),
)
attachmentServiceDeleteAttachmentHandler := connect.NewUnaryHandler(
AttachmentServiceDeleteAttachmentProcedure,
svc.DeleteAttachment,
connect.WithSchema(attachmentServiceMethods.ByName("DeleteAttachment")),
connect.WithHandlerOptions(opts...),
)
attachmentServiceBatchDeleteAttachmentsHandler := connect.NewUnaryHandler(
AttachmentServiceBatchDeleteAttachmentsProcedure,
svc.BatchDeleteAttachments,
connect.WithSchema(attachmentServiceMethods.ByName("BatchDeleteAttachments")),
connect.WithHandlerOptions(opts...),
)
attachmentServiceUploadAttachmentHandler := connect.NewUnaryHandler(
AttachmentServiceUploadAttachmentProcedure,
svc.UploadAttachment,
connect.WithSchema(attachmentServiceMethods.ByName("UploadAttachment")),
connect.WithHandlerOptions(opts...),
)
return "/memos.api.AttachmentService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case AttachmentServiceListAttachmentsProcedure:
attachmentServiceListAttachmentsHandler.ServeHTTP(w, r)
case AttachmentServiceGetAttachmentProcedure:
attachmentServiceGetAttachmentHandler.ServeHTTP(w, r)
case AttachmentServiceCreateAttachmentProcedure:
attachmentServiceCreateAttachmentHandler.ServeHTTP(w, r)
case AttachmentServiceUpdateAttachmentProcedure:
attachmentServiceUpdateAttachmentHandler.ServeHTTP(w, r)
case AttachmentServiceDeleteAttachmentProcedure:
attachmentServiceDeleteAttachmentHandler.ServeHTTP(w, r)
case AttachmentServiceBatchDeleteAttachmentsProcedure:
attachmentServiceBatchDeleteAttachmentsHandler.ServeHTTP(w, r)
case AttachmentServiceUploadAttachmentProcedure:
attachmentServiceUploadAttachmentHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedAttachmentServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedAttachmentServiceHandler struct{}
func (UnimplementedAttachmentServiceHandler) ListAttachments(context.Context, *connect.Request[api.ListAttachmentsRequest]) (*connect.Response[api.ListAttachmentsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.ListAttachments is not implemented"))
}
func (UnimplementedAttachmentServiceHandler) GetAttachment(context.Context, *connect.Request[api.GetAttachmentRequest]) (*connect.Response[api.Attachment], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.GetAttachment is not implemented"))
}
func (UnimplementedAttachmentServiceHandler) CreateAttachment(context.Context, *connect.Request[api.CreateAttachmentRequest]) (*connect.Response[api.Attachment], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.CreateAttachment is not implemented"))
}
func (UnimplementedAttachmentServiceHandler) UpdateAttachment(context.Context, *connect.Request[api.UpdateAttachmentRequest]) (*connect.Response[api.Attachment], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.UpdateAttachment is not implemented"))
}
func (UnimplementedAttachmentServiceHandler) DeleteAttachment(context.Context, *connect.Request[api.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.DeleteAttachment is not implemented"))
}
func (UnimplementedAttachmentServiceHandler) BatchDeleteAttachments(context.Context, *connect.Request[api.BatchDeleteAttachmentsRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.BatchDeleteAttachments is not implemented"))
}
func (UnimplementedAttachmentServiceHandler) UploadAttachment(context.Context, *connect.Request[api.UploadAttachmentRequest]) (*connect.Response[api.UploadAttachmentResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.AttachmentService.UploadAttachment is not implemented"))
}