Path: blob/main/components/supervisor-api/go/port.pb.gw.go
2498 views
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.5// source: port.proto67/*8Package api is a reverse proxy.910It translates gRPC into RESTful JSON APIs.11*/12package api1314import (15"context"16"io"17"net/http"1819"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"20"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"21"google.golang.org/grpc"22"google.golang.org/grpc/codes"23"google.golang.org/grpc/grpclog"24"google.golang.org/grpc/metadata"25"google.golang.org/grpc/status"26"google.golang.org/protobuf/proto"27)2829// Suppress "imported and not used" errors30var _ codes.Code31var _ io.Reader32var _ status.Status33var _ = runtime.String34var _ = utilities.NewDoubleArray35var _ = metadata.Join3637func request_PortService_Tunnel_0(ctx context.Context, marshaler runtime.Marshaler, client PortServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {38var protoReq TunnelPortRequest39var metadata runtime.ServerMetadata4041newReader, berr := utilities.IOReaderFactory(req.Body)42if berr != nil {43return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)44}45if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {46return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)47}4849var (50val string51ok bool52err error53_ = err54)5556val, ok = pathParams["port"]57if !ok {58return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port")59}6061protoReq.Port, err = runtime.Uint32(val)62if err != nil {63return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port", err)64}6566msg, err := client.Tunnel(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))67return msg, metadata, err6869}7071func local_request_PortService_Tunnel_0(ctx context.Context, marshaler runtime.Marshaler, server PortServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {72var protoReq TunnelPortRequest73var metadata runtime.ServerMetadata7475newReader, berr := utilities.IOReaderFactory(req.Body)76if berr != nil {77return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)78}79if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {80return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)81}8283var (84val string85ok bool86err error87_ = err88)8990val, ok = pathParams["port"]91if !ok {92return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port")93}9495protoReq.Port, err = runtime.Uint32(val)96if err != nil {97return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port", err)98}99100msg, err := server.Tunnel(ctx, &protoReq)101return msg, metadata, err102103}104105func request_PortService_CloseTunnel_0(ctx context.Context, marshaler runtime.Marshaler, client PortServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {106var protoReq CloseTunnelRequest107var metadata runtime.ServerMetadata108109var (110val string111ok bool112err error113_ = err114)115116val, ok = pathParams["port"]117if !ok {118return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port")119}120121protoReq.Port, err = runtime.Uint32(val)122if err != nil {123return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port", err)124}125126msg, err := client.CloseTunnel(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))127return msg, metadata, err128129}130131func local_request_PortService_CloseTunnel_0(ctx context.Context, marshaler runtime.Marshaler, server PortServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {132var protoReq CloseTunnelRequest133var metadata runtime.ServerMetadata134135var (136val string137ok bool138err error139_ = err140)141142val, ok = pathParams["port"]143if !ok {144return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port")145}146147protoReq.Port, err = runtime.Uint32(val)148if err != nil {149return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port", err)150}151152msg, err := server.CloseTunnel(ctx, &protoReq)153return msg, metadata, err154155}156157func request_PortService_AutoTunnel_0(ctx context.Context, marshaler runtime.Marshaler, client PortServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {158var protoReq AutoTunnelRequest159var metadata runtime.ServerMetadata160161var (162val string163ok bool164err error165_ = err166)167168val, ok = pathParams["enabled"]169if !ok {170return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "enabled")171}172173protoReq.Enabled, err = runtime.Bool(val)174if err != nil {175return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "enabled", err)176}177178msg, err := client.AutoTunnel(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))179return msg, metadata, err180181}182183func local_request_PortService_AutoTunnel_0(ctx context.Context, marshaler runtime.Marshaler, server PortServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {184var protoReq AutoTunnelRequest185var metadata runtime.ServerMetadata186187var (188val string189ok bool190err error191_ = err192)193194val, ok = pathParams["enabled"]195if !ok {196return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "enabled")197}198199protoReq.Enabled, err = runtime.Bool(val)200if err != nil {201return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "enabled", err)202}203204msg, err := server.AutoTunnel(ctx, &protoReq)205return msg, metadata, err206207}208209func request_PortService_RetryAutoExpose_0(ctx context.Context, marshaler runtime.Marshaler, client PortServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {210var protoReq RetryAutoExposeRequest211var metadata runtime.ServerMetadata212213var (214val string215ok bool216err error217_ = err218)219220val, ok = pathParams["port"]221if !ok {222return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port")223}224225protoReq.Port, err = runtime.Uint32(val)226if err != nil {227return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port", err)228}229230msg, err := client.RetryAutoExpose(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))231return msg, metadata, err232233}234235func local_request_PortService_RetryAutoExpose_0(ctx context.Context, marshaler runtime.Marshaler, server PortServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {236var protoReq RetryAutoExposeRequest237var metadata runtime.ServerMetadata238239var (240val string241ok bool242err error243_ = err244)245246val, ok = pathParams["port"]247if !ok {248return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port")249}250251protoReq.Port, err = runtime.Uint32(val)252if err != nil {253return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port", err)254}255256msg, err := server.RetryAutoExpose(ctx, &protoReq)257return msg, metadata, err258259}260261// RegisterPortServiceHandlerServer registers the http handlers for service PortService to "mux".262// UnaryRPC :call PortServiceServer directly.263// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.264// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPortServiceHandlerFromEndpoint instead.265func RegisterPortServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PortServiceServer) error {266267mux.Handle("POST", pattern_PortService_Tunnel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {268ctx, cancel := context.WithCancel(req.Context())269defer cancel()270var stream runtime.ServerTransportStream271ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)272inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)273var err error274var annotatedContext context.Context275annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/supervisor.PortService/Tunnel", runtime.WithHTTPPathPattern("/v1/port/tunnel/{port}"))276if err != nil {277runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)278return279}280resp, md, err := local_request_PortService_Tunnel_0(annotatedContext, inboundMarshaler, server, req, pathParams)281md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())282annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)283if err != nil {284runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)285return286}287288forward_PortService_Tunnel_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)289290})291292mux.Handle("DELETE", pattern_PortService_CloseTunnel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {293ctx, cancel := context.WithCancel(req.Context())294defer cancel()295var stream runtime.ServerTransportStream296ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)297inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)298var err error299var annotatedContext context.Context300annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/supervisor.PortService/CloseTunnel", runtime.WithHTTPPathPattern("/v1/port/tunnel/{port}"))301if err != nil {302runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)303return304}305resp, md, err := local_request_PortService_CloseTunnel_0(annotatedContext, inboundMarshaler, server, req, pathParams)306md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())307annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)308if err != nil {309runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)310return311}312313forward_PortService_CloseTunnel_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)314315})316317mux.Handle("POST", pattern_PortService_AutoTunnel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {318ctx, cancel := context.WithCancel(req.Context())319defer cancel()320var stream runtime.ServerTransportStream321ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)322inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)323var err error324var annotatedContext context.Context325annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/supervisor.PortService/AutoTunnel", runtime.WithHTTPPathPattern("/v1/port/tunnel/auto/{enabled}"))326if err != nil {327runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)328return329}330resp, md, err := local_request_PortService_AutoTunnel_0(annotatedContext, inboundMarshaler, server, req, pathParams)331md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())332annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)333if err != nil {334runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)335return336}337338forward_PortService_AutoTunnel_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)339340})341342mux.Handle("POST", pattern_PortService_RetryAutoExpose_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {343ctx, cancel := context.WithCancel(req.Context())344defer cancel()345var stream runtime.ServerTransportStream346ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)347inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)348var err error349var annotatedContext context.Context350annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/supervisor.PortService/RetryAutoExpose", runtime.WithHTTPPathPattern("/v1/port/ports/exposed/retry/{port}"))351if err != nil {352runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)353return354}355resp, md, err := local_request_PortService_RetryAutoExpose_0(annotatedContext, inboundMarshaler, server, req, pathParams)356md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())357annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)358if err != nil {359runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)360return361}362363forward_PortService_RetryAutoExpose_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)364365})366367return nil368}369370// RegisterPortServiceHandlerFromEndpoint is same as RegisterPortServiceHandler but371// automatically dials to "endpoint" and closes the connection when "ctx" gets done.372func RegisterPortServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {373conn, err := grpc.Dial(endpoint, opts...)374if err != nil {375return err376}377defer func() {378if err != nil {379if cerr := conn.Close(); cerr != nil {380grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)381}382return383}384go func() {385<-ctx.Done()386if cerr := conn.Close(); cerr != nil {387grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)388}389}()390}()391392return RegisterPortServiceHandler(ctx, mux, conn)393}394395// RegisterPortServiceHandler registers the http handlers for service PortService to "mux".396// The handlers forward requests to the grpc endpoint over "conn".397func RegisterPortServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {398return RegisterPortServiceHandlerClient(ctx, mux, NewPortServiceClient(conn))399}400401// RegisterPortServiceHandlerClient registers the http handlers for service PortService402// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PortServiceClient".403// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PortServiceClient"404// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in405// "PortServiceClient" to call the correct interceptors.406func RegisterPortServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PortServiceClient) error {407408mux.Handle("POST", pattern_PortService_Tunnel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {409ctx, cancel := context.WithCancel(req.Context())410defer cancel()411inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)412var err error413var annotatedContext context.Context414annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/supervisor.PortService/Tunnel", runtime.WithHTTPPathPattern("/v1/port/tunnel/{port}"))415if err != nil {416runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)417return418}419resp, md, err := request_PortService_Tunnel_0(annotatedContext, inboundMarshaler, client, req, pathParams)420annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)421if err != nil {422runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)423return424}425426forward_PortService_Tunnel_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)427428})429430mux.Handle("DELETE", pattern_PortService_CloseTunnel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {431ctx, cancel := context.WithCancel(req.Context())432defer cancel()433inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)434var err error435var annotatedContext context.Context436annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/supervisor.PortService/CloseTunnel", runtime.WithHTTPPathPattern("/v1/port/tunnel/{port}"))437if err != nil {438runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)439return440}441resp, md, err := request_PortService_CloseTunnel_0(annotatedContext, inboundMarshaler, client, req, pathParams)442annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)443if err != nil {444runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)445return446}447448forward_PortService_CloseTunnel_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)449450})451452mux.Handle("POST", pattern_PortService_AutoTunnel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {453ctx, cancel := context.WithCancel(req.Context())454defer cancel()455inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)456var err error457var annotatedContext context.Context458annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/supervisor.PortService/AutoTunnel", runtime.WithHTTPPathPattern("/v1/port/tunnel/auto/{enabled}"))459if err != nil {460runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)461return462}463resp, md, err := request_PortService_AutoTunnel_0(annotatedContext, inboundMarshaler, client, req, pathParams)464annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)465if err != nil {466runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)467return468}469470forward_PortService_AutoTunnel_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)471472})473474mux.Handle("POST", pattern_PortService_RetryAutoExpose_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {475ctx, cancel := context.WithCancel(req.Context())476defer cancel()477inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)478var err error479var annotatedContext context.Context480annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/supervisor.PortService/RetryAutoExpose", runtime.WithHTTPPathPattern("/v1/port/ports/exposed/retry/{port}"))481if err != nil {482runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)483return484}485resp, md, err := request_PortService_RetryAutoExpose_0(annotatedContext, inboundMarshaler, client, req, pathParams)486annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)487if err != nil {488runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)489return490}491492forward_PortService_RetryAutoExpose_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)493494})495496return nil497}498499var (500pattern_PortService_Tunnel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 1}, []string{"v1", "port", "tunnel"}, ""))501502pattern_PortService_CloseTunnel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 1}, []string{"v1", "port", "tunnel"}, ""))503504pattern_PortService_AutoTunnel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "port", "tunnel", "auto", "enabled"}, ""))505506pattern_PortService_RetryAutoExpose_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 1}, []string{"v1", "port", "ports", "exposed", "retry"}, ""))507)508509var (510forward_PortService_Tunnel_0 = runtime.ForwardResponseMessage511512forward_PortService_CloseTunnel_0 = runtime.ForwardResponseMessage513514forward_PortService_AutoTunnel_0 = runtime.ForwardResponseMessage515516forward_PortService_RetryAutoExpose_0 = runtime.ForwardResponseMessage517)518519520