inbox_service.pb.gw.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
  2. // source: api/v1/inbox_service.proto
  3. /*
  4. Package apiv1 is a reverse proxy.
  5. It translates gRPC into RESTful JSON APIs.
  6. */
  7. package apiv1
  8. import (
  9. "context"
  10. "errors"
  11. "io"
  12. "net/http"
  13. "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
  14. "github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
  15. "google.golang.org/grpc"
  16. "google.golang.org/grpc/codes"
  17. "google.golang.org/grpc/grpclog"
  18. "google.golang.org/grpc/metadata"
  19. "google.golang.org/grpc/status"
  20. "google.golang.org/protobuf/proto"
  21. )
  22. // Suppress "imported and not used" errors
  23. var (
  24. _ codes.Code
  25. _ io.Reader
  26. _ status.Status
  27. _ = errors.New
  28. _ = runtime.String
  29. _ = utilities.NewDoubleArray
  30. _ = metadata.Join
  31. )
  32. var filter_InboxService_ListInboxes_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
  33. func request_InboxService_ListInboxes_0(ctx context.Context, marshaler runtime.Marshaler, client InboxServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  34. var (
  35. protoReq ListInboxesRequest
  36. metadata runtime.ServerMetadata
  37. )
  38. if err := req.ParseForm(); err != nil {
  39. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  40. }
  41. if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InboxService_ListInboxes_0); err != nil {
  42. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  43. }
  44. msg, err := client.ListInboxes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
  45. return msg, metadata, err
  46. }
  47. func local_request_InboxService_ListInboxes_0(ctx context.Context, marshaler runtime.Marshaler, server InboxServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  48. var (
  49. protoReq ListInboxesRequest
  50. metadata runtime.ServerMetadata
  51. )
  52. if err := req.ParseForm(); err != nil {
  53. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  54. }
  55. if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InboxService_ListInboxes_0); err != nil {
  56. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  57. }
  58. msg, err := server.ListInboxes(ctx, &protoReq)
  59. return msg, metadata, err
  60. }
  61. var filter_InboxService_UpdateInbox_0 = &utilities.DoubleArray{Encoding: map[string]int{"inbox": 0, "name": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}}
  62. func request_InboxService_UpdateInbox_0(ctx context.Context, marshaler runtime.Marshaler, client InboxServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  63. var (
  64. protoReq UpdateInboxRequest
  65. metadata runtime.ServerMetadata
  66. err error
  67. )
  68. newReader, berr := utilities.IOReaderFactory(req.Body)
  69. if berr != nil {
  70. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
  71. }
  72. if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Inbox); err != nil && !errors.Is(err, io.EOF) {
  73. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  74. }
  75. if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
  76. if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Inbox); err != nil {
  77. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  78. } else {
  79. protoReq.UpdateMask = fieldMask
  80. }
  81. }
  82. val, ok := pathParams["inbox.name"]
  83. if !ok {
  84. return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "inbox.name")
  85. }
  86. err = runtime.PopulateFieldFromPath(&protoReq, "inbox.name", val)
  87. if err != nil {
  88. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "inbox.name", err)
  89. }
  90. if err := req.ParseForm(); err != nil {
  91. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  92. }
  93. if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InboxService_UpdateInbox_0); err != nil {
  94. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  95. }
  96. msg, err := client.UpdateInbox(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
  97. return msg, metadata, err
  98. }
  99. func local_request_InboxService_UpdateInbox_0(ctx context.Context, marshaler runtime.Marshaler, server InboxServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  100. var (
  101. protoReq UpdateInboxRequest
  102. metadata runtime.ServerMetadata
  103. err error
  104. )
  105. newReader, berr := utilities.IOReaderFactory(req.Body)
  106. if berr != nil {
  107. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
  108. }
  109. if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Inbox); err != nil && !errors.Is(err, io.EOF) {
  110. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  111. }
  112. if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
  113. if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Inbox); err != nil {
  114. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  115. } else {
  116. protoReq.UpdateMask = fieldMask
  117. }
  118. }
  119. val, ok := pathParams["inbox.name"]
  120. if !ok {
  121. return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "inbox.name")
  122. }
  123. err = runtime.PopulateFieldFromPath(&protoReq, "inbox.name", val)
  124. if err != nil {
  125. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "inbox.name", err)
  126. }
  127. if err := req.ParseForm(); err != nil {
  128. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  129. }
  130. if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InboxService_UpdateInbox_0); err != nil {
  131. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  132. }
  133. msg, err := server.UpdateInbox(ctx, &protoReq)
  134. return msg, metadata, err
  135. }
  136. func request_InboxService_DeleteInbox_0(ctx context.Context, marshaler runtime.Marshaler, client InboxServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  137. var (
  138. protoReq DeleteInboxRequest
  139. metadata runtime.ServerMetadata
  140. err error
  141. )
  142. val, ok := pathParams["name"]
  143. if !ok {
  144. return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
  145. }
  146. protoReq.Name, err = runtime.String(val)
  147. if err != nil {
  148. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
  149. }
  150. msg, err := client.DeleteInbox(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
  151. return msg, metadata, err
  152. }
  153. func local_request_InboxService_DeleteInbox_0(ctx context.Context, marshaler runtime.Marshaler, server InboxServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  154. var (
  155. protoReq DeleteInboxRequest
  156. metadata runtime.ServerMetadata
  157. err error
  158. )
  159. val, ok := pathParams["name"]
  160. if !ok {
  161. return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
  162. }
  163. protoReq.Name, err = runtime.String(val)
  164. if err != nil {
  165. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
  166. }
  167. msg, err := server.DeleteInbox(ctx, &protoReq)
  168. return msg, metadata, err
  169. }
  170. // RegisterInboxServiceHandlerServer registers the http handlers for service InboxService to "mux".
  171. // UnaryRPC :call InboxServiceServer directly.
  172. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
  173. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterInboxServiceHandlerFromEndpoint instead.
  174. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
  175. func RegisterInboxServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server InboxServiceServer) error {
  176. mux.Handle(http.MethodGet, pattern_InboxService_ListInboxes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  177. ctx, cancel := context.WithCancel(req.Context())
  178. defer cancel()
  179. var stream runtime.ServerTransportStream
  180. ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
  181. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  182. annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.InboxService/ListInboxes", runtime.WithHTTPPathPattern("/api/v1/inboxes"))
  183. if err != nil {
  184. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  185. return
  186. }
  187. resp, md, err := local_request_InboxService_ListInboxes_0(annotatedContext, inboundMarshaler, server, req, pathParams)
  188. md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
  189. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  190. if err != nil {
  191. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  192. return
  193. }
  194. forward_InboxService_ListInboxes_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  195. })
  196. mux.Handle(http.MethodPatch, pattern_InboxService_UpdateInbox_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  197. ctx, cancel := context.WithCancel(req.Context())
  198. defer cancel()
  199. var stream runtime.ServerTransportStream
  200. ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
  201. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  202. annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.InboxService/UpdateInbox", runtime.WithHTTPPathPattern("/api/v1/{inbox.name=inboxes/*}"))
  203. if err != nil {
  204. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  205. return
  206. }
  207. resp, md, err := local_request_InboxService_UpdateInbox_0(annotatedContext, inboundMarshaler, server, req, pathParams)
  208. md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
  209. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  210. if err != nil {
  211. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  212. return
  213. }
  214. forward_InboxService_UpdateInbox_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  215. })
  216. mux.Handle(http.MethodDelete, pattern_InboxService_DeleteInbox_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  217. ctx, cancel := context.WithCancel(req.Context())
  218. defer cancel()
  219. var stream runtime.ServerTransportStream
  220. ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
  221. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  222. annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.InboxService/DeleteInbox", runtime.WithHTTPPathPattern("/api/v1/{name=inboxes/*}"))
  223. if err != nil {
  224. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  225. return
  226. }
  227. resp, md, err := local_request_InboxService_DeleteInbox_0(annotatedContext, inboundMarshaler, server, req, pathParams)
  228. md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
  229. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  230. if err != nil {
  231. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  232. return
  233. }
  234. forward_InboxService_DeleteInbox_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  235. })
  236. return nil
  237. }
  238. // RegisterInboxServiceHandlerFromEndpoint is same as RegisterInboxServiceHandler but
  239. // automatically dials to "endpoint" and closes the connection when "ctx" gets done.
  240. func RegisterInboxServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
  241. conn, err := grpc.NewClient(endpoint, opts...)
  242. if err != nil {
  243. return err
  244. }
  245. defer func() {
  246. if err != nil {
  247. if cerr := conn.Close(); cerr != nil {
  248. grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
  249. }
  250. return
  251. }
  252. go func() {
  253. <-ctx.Done()
  254. if cerr := conn.Close(); cerr != nil {
  255. grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
  256. }
  257. }()
  258. }()
  259. return RegisterInboxServiceHandler(ctx, mux, conn)
  260. }
  261. // RegisterInboxServiceHandler registers the http handlers for service InboxService to "mux".
  262. // The handlers forward requests to the grpc endpoint over "conn".
  263. func RegisterInboxServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
  264. return RegisterInboxServiceHandlerClient(ctx, mux, NewInboxServiceClient(conn))
  265. }
  266. // RegisterInboxServiceHandlerClient registers the http handlers for service InboxService
  267. // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "InboxServiceClient".
  268. // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "InboxServiceClient"
  269. // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
  270. // "InboxServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares.
  271. func RegisterInboxServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client InboxServiceClient) error {
  272. mux.Handle(http.MethodGet, pattern_InboxService_ListInboxes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  273. ctx, cancel := context.WithCancel(req.Context())
  274. defer cancel()
  275. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  276. annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.InboxService/ListInboxes", runtime.WithHTTPPathPattern("/api/v1/inboxes"))
  277. if err != nil {
  278. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  279. return
  280. }
  281. resp, md, err := request_InboxService_ListInboxes_0(annotatedContext, inboundMarshaler, client, req, pathParams)
  282. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  283. if err != nil {
  284. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  285. return
  286. }
  287. forward_InboxService_ListInboxes_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  288. })
  289. mux.Handle(http.MethodPatch, pattern_InboxService_UpdateInbox_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  290. ctx, cancel := context.WithCancel(req.Context())
  291. defer cancel()
  292. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  293. annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.InboxService/UpdateInbox", runtime.WithHTTPPathPattern("/api/v1/{inbox.name=inboxes/*}"))
  294. if err != nil {
  295. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  296. return
  297. }
  298. resp, md, err := request_InboxService_UpdateInbox_0(annotatedContext, inboundMarshaler, client, req, pathParams)
  299. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  300. if err != nil {
  301. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  302. return
  303. }
  304. forward_InboxService_UpdateInbox_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  305. })
  306. mux.Handle(http.MethodDelete, pattern_InboxService_DeleteInbox_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  307. ctx, cancel := context.WithCancel(req.Context())
  308. defer cancel()
  309. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  310. annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.InboxService/DeleteInbox", runtime.WithHTTPPathPattern("/api/v1/{name=inboxes/*}"))
  311. if err != nil {
  312. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  313. return
  314. }
  315. resp, md, err := request_InboxService_DeleteInbox_0(annotatedContext, inboundMarshaler, client, req, pathParams)
  316. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  317. if err != nil {
  318. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  319. return
  320. }
  321. forward_InboxService_DeleteInbox_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  322. })
  323. return nil
  324. }
  325. var (
  326. pattern_InboxService_ListInboxes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "inboxes"}, ""))
  327. pattern_InboxService_UpdateInbox_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v1", "inboxes", "inbox.name"}, ""))
  328. pattern_InboxService_DeleteInbox_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v1", "inboxes", "name"}, ""))
  329. )
  330. var (
  331. forward_InboxService_ListInboxes_0 = runtime.ForwardResponseMessage
  332. forward_InboxService_UpdateInbox_0 = runtime.ForwardResponseMessage
  333. forward_InboxService_DeleteInbox_0 = runtime.ForwardResponseMessage
  334. )