github.com/decred/dcrlnd@v0.7.6/lnrpc/autopilotrpc/autopilot.pb.gw.go (about) 1 // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. 2 // source: autopilotrpc/autopilot.proto 3 4 /* 5 Package autopilotrpc is a reverse proxy. 6 7 It translates gRPC into RESTful JSON APIs. 8 */ 9 package autopilotrpc 10 11 import ( 12 "context" 13 "io" 14 "net/http" 15 16 "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" 17 "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" 18 "google.golang.org/grpc" 19 "google.golang.org/grpc/codes" 20 "google.golang.org/grpc/grpclog" 21 "google.golang.org/grpc/metadata" 22 "google.golang.org/grpc/status" 23 "google.golang.org/protobuf/proto" 24 ) 25 26 // Suppress "imported and not used" errors 27 var _ codes.Code 28 var _ io.Reader 29 var _ status.Status 30 var _ = runtime.String 31 var _ = utilities.NewDoubleArray 32 var _ = metadata.Join 33 34 func request_Autopilot_Status_0(ctx context.Context, marshaler runtime.Marshaler, client AutopilotClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 35 var protoReq StatusRequest 36 var metadata runtime.ServerMetadata 37 38 msg, err := client.Status(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 39 return msg, metadata, err 40 41 } 42 43 func local_request_Autopilot_Status_0(ctx context.Context, marshaler runtime.Marshaler, server AutopilotServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 44 var protoReq StatusRequest 45 var metadata runtime.ServerMetadata 46 47 msg, err := server.Status(ctx, &protoReq) 48 return msg, metadata, err 49 50 } 51 52 func request_Autopilot_ModifyStatus_0(ctx context.Context, marshaler runtime.Marshaler, client AutopilotClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 53 var protoReq ModifyStatusRequest 54 var metadata runtime.ServerMetadata 55 56 newReader, berr := utilities.IOReaderFactory(req.Body) 57 if berr != nil { 58 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) 59 } 60 if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { 61 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 62 } 63 64 msg, err := client.ModifyStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 65 return msg, metadata, err 66 67 } 68 69 func local_request_Autopilot_ModifyStatus_0(ctx context.Context, marshaler runtime.Marshaler, server AutopilotServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 70 var protoReq ModifyStatusRequest 71 var metadata runtime.ServerMetadata 72 73 newReader, berr := utilities.IOReaderFactory(req.Body) 74 if berr != nil { 75 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) 76 } 77 if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { 78 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 79 } 80 81 msg, err := server.ModifyStatus(ctx, &protoReq) 82 return msg, metadata, err 83 84 } 85 86 var ( 87 filter_Autopilot_QueryScores_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} 88 ) 89 90 func request_Autopilot_QueryScores_0(ctx context.Context, marshaler runtime.Marshaler, client AutopilotClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 91 var protoReq QueryScoresRequest 92 var metadata runtime.ServerMetadata 93 94 if err := req.ParseForm(); err != nil { 95 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 96 } 97 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Autopilot_QueryScores_0); err != nil { 98 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 99 } 100 101 msg, err := client.QueryScores(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 102 return msg, metadata, err 103 104 } 105 106 func local_request_Autopilot_QueryScores_0(ctx context.Context, marshaler runtime.Marshaler, server AutopilotServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 107 var protoReq QueryScoresRequest 108 var metadata runtime.ServerMetadata 109 110 if err := req.ParseForm(); err != nil { 111 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 112 } 113 if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Autopilot_QueryScores_0); err != nil { 114 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 115 } 116 117 msg, err := server.QueryScores(ctx, &protoReq) 118 return msg, metadata, err 119 120 } 121 122 func request_Autopilot_SetScores_0(ctx context.Context, marshaler runtime.Marshaler, client AutopilotClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 123 var protoReq SetScoresRequest 124 var metadata runtime.ServerMetadata 125 126 newReader, berr := utilities.IOReaderFactory(req.Body) 127 if berr != nil { 128 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) 129 } 130 if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { 131 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 132 } 133 134 msg, err := client.SetScores(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) 135 return msg, metadata, err 136 137 } 138 139 func local_request_Autopilot_SetScores_0(ctx context.Context, marshaler runtime.Marshaler, server AutopilotServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { 140 var protoReq SetScoresRequest 141 var metadata runtime.ServerMetadata 142 143 newReader, berr := utilities.IOReaderFactory(req.Body) 144 if berr != nil { 145 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) 146 } 147 if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { 148 return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) 149 } 150 151 msg, err := server.SetScores(ctx, &protoReq) 152 return msg, metadata, err 153 154 } 155 156 // RegisterAutopilotHandlerServer registers the http handlers for service Autopilot to "mux". 157 // UnaryRPC :call AutopilotServer directly. 158 // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. 159 // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAutopilotHandlerFromEndpoint instead. 160 func RegisterAutopilotHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AutopilotServer) error { 161 162 mux.Handle("GET", pattern_Autopilot_Status_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 163 ctx, cancel := context.WithCancel(req.Context()) 164 defer cancel() 165 var stream runtime.ServerTransportStream 166 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) 167 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 168 rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/autopilotrpc.Autopilot/Status", runtime.WithHTTPPathPattern("/v2/autopilot/status")) 169 if err != nil { 170 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 171 return 172 } 173 resp, md, err := local_request_Autopilot_Status_0(rctx, inboundMarshaler, server, req, pathParams) 174 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) 175 ctx = runtime.NewServerMetadataContext(ctx, md) 176 if err != nil { 177 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 178 return 179 } 180 181 forward_Autopilot_Status_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 182 183 }) 184 185 mux.Handle("POST", pattern_Autopilot_ModifyStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 186 ctx, cancel := context.WithCancel(req.Context()) 187 defer cancel() 188 var stream runtime.ServerTransportStream 189 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) 190 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 191 rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/autopilotrpc.Autopilot/ModifyStatus", runtime.WithHTTPPathPattern("/v2/autopilot/modify")) 192 if err != nil { 193 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 194 return 195 } 196 resp, md, err := local_request_Autopilot_ModifyStatus_0(rctx, inboundMarshaler, server, req, pathParams) 197 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) 198 ctx = runtime.NewServerMetadataContext(ctx, md) 199 if err != nil { 200 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 201 return 202 } 203 204 forward_Autopilot_ModifyStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 205 206 }) 207 208 mux.Handle("GET", pattern_Autopilot_QueryScores_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 209 ctx, cancel := context.WithCancel(req.Context()) 210 defer cancel() 211 var stream runtime.ServerTransportStream 212 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) 213 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 214 rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/autopilotrpc.Autopilot/QueryScores", runtime.WithHTTPPathPattern("/v2/autopilot/scores")) 215 if err != nil { 216 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 217 return 218 } 219 resp, md, err := local_request_Autopilot_QueryScores_0(rctx, inboundMarshaler, server, req, pathParams) 220 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) 221 ctx = runtime.NewServerMetadataContext(ctx, md) 222 if err != nil { 223 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 224 return 225 } 226 227 forward_Autopilot_QueryScores_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 228 229 }) 230 231 mux.Handle("POST", pattern_Autopilot_SetScores_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 232 ctx, cancel := context.WithCancel(req.Context()) 233 defer cancel() 234 var stream runtime.ServerTransportStream 235 ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) 236 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 237 rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/autopilotrpc.Autopilot/SetScores", runtime.WithHTTPPathPattern("/v2/autopilot/scores")) 238 if err != nil { 239 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 240 return 241 } 242 resp, md, err := local_request_Autopilot_SetScores_0(rctx, inboundMarshaler, server, req, pathParams) 243 md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) 244 ctx = runtime.NewServerMetadataContext(ctx, md) 245 if err != nil { 246 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 247 return 248 } 249 250 forward_Autopilot_SetScores_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 251 252 }) 253 254 return nil 255 } 256 257 // RegisterAutopilotHandlerFromEndpoint is same as RegisterAutopilotHandler but 258 // automatically dials to "endpoint" and closes the connection when "ctx" gets done. 259 func RegisterAutopilotHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { 260 conn, err := grpc.Dial(endpoint, opts...) 261 if err != nil { 262 return err 263 } 264 defer func() { 265 if err != nil { 266 if cerr := conn.Close(); cerr != nil { 267 grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) 268 } 269 return 270 } 271 go func() { 272 <-ctx.Done() 273 if cerr := conn.Close(); cerr != nil { 274 grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) 275 } 276 }() 277 }() 278 279 return RegisterAutopilotHandler(ctx, mux, conn) 280 } 281 282 // RegisterAutopilotHandler registers the http handlers for service Autopilot to "mux". 283 // The handlers forward requests to the grpc endpoint over "conn". 284 func RegisterAutopilotHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { 285 return RegisterAutopilotHandlerClient(ctx, mux, NewAutopilotClient(conn)) 286 } 287 288 // RegisterAutopilotHandlerClient registers the http handlers for service Autopilot 289 // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AutopilotClient". 290 // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AutopilotClient" 291 // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in 292 // "AutopilotClient" to call the correct interceptors. 293 func RegisterAutopilotHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AutopilotClient) error { 294 295 mux.Handle("GET", pattern_Autopilot_Status_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 296 ctx, cancel := context.WithCancel(req.Context()) 297 defer cancel() 298 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 299 rctx, err := runtime.AnnotateContext(ctx, mux, req, "/autopilotrpc.Autopilot/Status", runtime.WithHTTPPathPattern("/v2/autopilot/status")) 300 if err != nil { 301 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 302 return 303 } 304 resp, md, err := request_Autopilot_Status_0(rctx, inboundMarshaler, client, req, pathParams) 305 ctx = runtime.NewServerMetadataContext(ctx, md) 306 if err != nil { 307 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 308 return 309 } 310 311 forward_Autopilot_Status_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 312 313 }) 314 315 mux.Handle("POST", pattern_Autopilot_ModifyStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 316 ctx, cancel := context.WithCancel(req.Context()) 317 defer cancel() 318 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 319 rctx, err := runtime.AnnotateContext(ctx, mux, req, "/autopilotrpc.Autopilot/ModifyStatus", runtime.WithHTTPPathPattern("/v2/autopilot/modify")) 320 if err != nil { 321 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 322 return 323 } 324 resp, md, err := request_Autopilot_ModifyStatus_0(rctx, inboundMarshaler, client, req, pathParams) 325 ctx = runtime.NewServerMetadataContext(ctx, md) 326 if err != nil { 327 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 328 return 329 } 330 331 forward_Autopilot_ModifyStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 332 333 }) 334 335 mux.Handle("GET", pattern_Autopilot_QueryScores_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 336 ctx, cancel := context.WithCancel(req.Context()) 337 defer cancel() 338 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 339 rctx, err := runtime.AnnotateContext(ctx, mux, req, "/autopilotrpc.Autopilot/QueryScores", runtime.WithHTTPPathPattern("/v2/autopilot/scores")) 340 if err != nil { 341 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 342 return 343 } 344 resp, md, err := request_Autopilot_QueryScores_0(rctx, inboundMarshaler, client, req, pathParams) 345 ctx = runtime.NewServerMetadataContext(ctx, md) 346 if err != nil { 347 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 348 return 349 } 350 351 forward_Autopilot_QueryScores_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 352 353 }) 354 355 mux.Handle("POST", pattern_Autopilot_SetScores_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { 356 ctx, cancel := context.WithCancel(req.Context()) 357 defer cancel() 358 inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) 359 rctx, err := runtime.AnnotateContext(ctx, mux, req, "/autopilotrpc.Autopilot/SetScores", runtime.WithHTTPPathPattern("/v2/autopilot/scores")) 360 if err != nil { 361 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 362 return 363 } 364 resp, md, err := request_Autopilot_SetScores_0(rctx, inboundMarshaler, client, req, pathParams) 365 ctx = runtime.NewServerMetadataContext(ctx, md) 366 if err != nil { 367 runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 368 return 369 } 370 371 forward_Autopilot_SetScores_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) 372 373 }) 374 375 return nil 376 } 377 378 var ( 379 pattern_Autopilot_Status_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "autopilot", "status"}, "")) 380 381 pattern_Autopilot_ModifyStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "autopilot", "modify"}, "")) 382 383 pattern_Autopilot_QueryScores_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "autopilot", "scores"}, "")) 384 385 pattern_Autopilot_SetScores_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "autopilot", "scores"}, "")) 386 ) 387 388 var ( 389 forward_Autopilot_Status_0 = runtime.ForwardResponseMessage 390 391 forward_Autopilot_ModifyStatus_0 = runtime.ForwardResponseMessage 392 393 forward_Autopilot_QueryScores_0 = runtime.ForwardResponseMessage 394 395 forward_Autopilot_SetScores_0 = runtime.ForwardResponseMessage 396 )