github.com/letsencrypt/trillian@v1.1.2-0.20180615153820-ae375a99d36a/quota/etcd/quotapb/quotapb.pb.gw.go (about)

     1  // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
     2  // source: quotapb.proto
     3  
     4  /*
     5  Package quotapb is a reverse proxy.
     6  
     7  It translates gRPC into RESTful JSON APIs.
     8  */
     9  package quotapb
    10  
    11  import (
    12  	"io"
    13  	"net/http"
    14  
    15  	"github.com/golang/protobuf/proto"
    16  	"github.com/grpc-ecosystem/grpc-gateway/runtime"
    17  	"github.com/grpc-ecosystem/grpc-gateway/utilities"
    18  	"golang.org/x/net/context"
    19  	"google.golang.org/grpc"
    20  	"google.golang.org/grpc/codes"
    21  	"google.golang.org/grpc/grpclog"
    22  	"google.golang.org/grpc/status"
    23  )
    24  
    25  var _ codes.Code
    26  var _ io.Reader
    27  var _ status.Status
    28  var _ = runtime.String
    29  var _ = utilities.NewDoubleArray
    30  
    31  func request_Quota_CreateConfig_0(ctx context.Context, marshaler runtime.Marshaler, client QuotaClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    32  	var protoReq CreateConfigRequest
    33  	var metadata runtime.ServerMetadata
    34  
    35  	if req.ContentLength > 0 {
    36  		if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
    37  			return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
    38  		}
    39  	}
    40  
    41  	var (
    42  		val string
    43  		ok  bool
    44  		err error
    45  		_   = err
    46  	)
    47  
    48  	val, ok = pathParams["name"]
    49  	if !ok {
    50  		return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
    51  	}
    52  
    53  	protoReq.Name, err = runtime.String(val)
    54  
    55  	if err != nil {
    56  		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
    57  	}
    58  
    59  	msg, err := client.CreateConfig(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
    60  	return msg, metadata, err
    61  
    62  }
    63  
    64  func request_Quota_DeleteConfig_0(ctx context.Context, marshaler runtime.Marshaler, client QuotaClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    65  	var protoReq DeleteConfigRequest
    66  	var metadata runtime.ServerMetadata
    67  
    68  	var (
    69  		val string
    70  		ok  bool
    71  		err error
    72  		_   = err
    73  	)
    74  
    75  	val, ok = pathParams["name"]
    76  	if !ok {
    77  		return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
    78  	}
    79  
    80  	protoReq.Name, err = runtime.String(val)
    81  
    82  	if err != nil {
    83  		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
    84  	}
    85  
    86  	msg, err := client.DeleteConfig(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
    87  	return msg, metadata, err
    88  
    89  }
    90  
    91  func request_Quota_GetConfig_0(ctx context.Context, marshaler runtime.Marshaler, client QuotaClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    92  	var protoReq GetConfigRequest
    93  	var metadata runtime.ServerMetadata
    94  
    95  	var (
    96  		val string
    97  		ok  bool
    98  		err error
    99  		_   = err
   100  	)
   101  
   102  	val, ok = pathParams["name"]
   103  	if !ok {
   104  		return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
   105  	}
   106  
   107  	protoReq.Name, err = runtime.String(val)
   108  
   109  	if err != nil {
   110  		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
   111  	}
   112  
   113  	msg, err := client.GetConfig(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
   114  	return msg, metadata, err
   115  
   116  }
   117  
   118  var (
   119  	filter_Quota_ListConfigs_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
   120  )
   121  
   122  func request_Quota_ListConfigs_0(ctx context.Context, marshaler runtime.Marshaler, client QuotaClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
   123  	var protoReq ListConfigsRequest
   124  	var metadata runtime.ServerMetadata
   125  
   126  	if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Quota_ListConfigs_0); err != nil {
   127  		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
   128  	}
   129  
   130  	msg, err := client.ListConfigs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
   131  	return msg, metadata, err
   132  
   133  }
   134  
   135  func request_Quota_UpdateConfig_0(ctx context.Context, marshaler runtime.Marshaler, client QuotaClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
   136  	var protoReq UpdateConfigRequest
   137  	var metadata runtime.ServerMetadata
   138  
   139  	if req.ContentLength > 0 {
   140  		if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
   141  			return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
   142  		}
   143  	}
   144  
   145  	var (
   146  		val string
   147  		ok  bool
   148  		err error
   149  		_   = err
   150  	)
   151  
   152  	val, ok = pathParams["name"]
   153  	if !ok {
   154  		return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
   155  	}
   156  
   157  	protoReq.Name, err = runtime.String(val)
   158  
   159  	if err != nil {
   160  		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
   161  	}
   162  
   163  	msg, err := client.UpdateConfig(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
   164  	return msg, metadata, err
   165  
   166  }
   167  
   168  // RegisterQuotaHandlerFromEndpoint is same as RegisterQuotaHandler but
   169  // automatically dials to "endpoint" and closes the connection when "ctx" gets done.
   170  func RegisterQuotaHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
   171  	conn, err := grpc.Dial(endpoint, opts...)
   172  	if err != nil {
   173  		return err
   174  	}
   175  	defer func() {
   176  		if err != nil {
   177  			if cerr := conn.Close(); cerr != nil {
   178  				grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
   179  			}
   180  			return
   181  		}
   182  		go func() {
   183  			<-ctx.Done()
   184  			if cerr := conn.Close(); cerr != nil {
   185  				grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
   186  			}
   187  		}()
   188  	}()
   189  
   190  	return RegisterQuotaHandler(ctx, mux, conn)
   191  }
   192  
   193  // RegisterQuotaHandler registers the http handlers for service Quota to "mux".
   194  // The handlers forward requests to the grpc endpoint over "conn".
   195  func RegisterQuotaHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
   196  	return RegisterQuotaHandlerClient(ctx, mux, NewQuotaClient(conn))
   197  }
   198  
   199  // RegisterQuotaHandler registers the http handlers for service Quota to "mux".
   200  // The handlers forward requests to the grpc endpoint over the given implementation of "QuotaClient".
   201  // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QuotaClient"
   202  // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
   203  // "QuotaClient" to call the correct interceptors.
   204  func RegisterQuotaHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QuotaClient) error {
   205  
   206  	mux.Handle("POST", pattern_Quota_CreateConfig_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   207  		ctx, cancel := context.WithCancel(req.Context())
   208  		defer cancel()
   209  		if cn, ok := w.(http.CloseNotifier); ok {
   210  			go func(done <-chan struct{}, closed <-chan bool) {
   211  				select {
   212  				case <-done:
   213  				case <-closed:
   214  					cancel()
   215  				}
   216  			}(ctx.Done(), cn.CloseNotify())
   217  		}
   218  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   219  		rctx, err := runtime.AnnotateContext(ctx, mux, req)
   220  		if err != nil {
   221  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   222  			return
   223  		}
   224  		resp, md, err := request_Quota_CreateConfig_0(rctx, inboundMarshaler, client, req, pathParams)
   225  		ctx = runtime.NewServerMetadataContext(ctx, md)
   226  		if err != nil {
   227  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   228  			return
   229  		}
   230  
   231  		forward_Quota_CreateConfig_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   232  
   233  	})
   234  
   235  	mux.Handle("DELETE", pattern_Quota_DeleteConfig_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   236  		ctx, cancel := context.WithCancel(req.Context())
   237  		defer cancel()
   238  		if cn, ok := w.(http.CloseNotifier); ok {
   239  			go func(done <-chan struct{}, closed <-chan bool) {
   240  				select {
   241  				case <-done:
   242  				case <-closed:
   243  					cancel()
   244  				}
   245  			}(ctx.Done(), cn.CloseNotify())
   246  		}
   247  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   248  		rctx, err := runtime.AnnotateContext(ctx, mux, req)
   249  		if err != nil {
   250  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   251  			return
   252  		}
   253  		resp, md, err := request_Quota_DeleteConfig_0(rctx, inboundMarshaler, client, req, pathParams)
   254  		ctx = runtime.NewServerMetadataContext(ctx, md)
   255  		if err != nil {
   256  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   257  			return
   258  		}
   259  
   260  		forward_Quota_DeleteConfig_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   261  
   262  	})
   263  
   264  	mux.Handle("GET", pattern_Quota_GetConfig_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   265  		ctx, cancel := context.WithCancel(req.Context())
   266  		defer cancel()
   267  		if cn, ok := w.(http.CloseNotifier); ok {
   268  			go func(done <-chan struct{}, closed <-chan bool) {
   269  				select {
   270  				case <-done:
   271  				case <-closed:
   272  					cancel()
   273  				}
   274  			}(ctx.Done(), cn.CloseNotify())
   275  		}
   276  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   277  		rctx, err := runtime.AnnotateContext(ctx, mux, req)
   278  		if err != nil {
   279  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   280  			return
   281  		}
   282  		resp, md, err := request_Quota_GetConfig_0(rctx, inboundMarshaler, client, req, pathParams)
   283  		ctx = runtime.NewServerMetadataContext(ctx, md)
   284  		if err != nil {
   285  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   286  			return
   287  		}
   288  
   289  		forward_Quota_GetConfig_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   290  
   291  	})
   292  
   293  	mux.Handle("GET", pattern_Quota_ListConfigs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   294  		ctx, cancel := context.WithCancel(req.Context())
   295  		defer cancel()
   296  		if cn, ok := w.(http.CloseNotifier); ok {
   297  			go func(done <-chan struct{}, closed <-chan bool) {
   298  				select {
   299  				case <-done:
   300  				case <-closed:
   301  					cancel()
   302  				}
   303  			}(ctx.Done(), cn.CloseNotify())
   304  		}
   305  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   306  		rctx, err := runtime.AnnotateContext(ctx, mux, req)
   307  		if err != nil {
   308  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   309  			return
   310  		}
   311  		resp, md, err := request_Quota_ListConfigs_0(rctx, inboundMarshaler, client, req, pathParams)
   312  		ctx = runtime.NewServerMetadataContext(ctx, md)
   313  		if err != nil {
   314  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   315  			return
   316  		}
   317  
   318  		forward_Quota_ListConfigs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   319  
   320  	})
   321  
   322  	mux.Handle("PATCH", pattern_Quota_UpdateConfig_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
   323  		ctx, cancel := context.WithCancel(req.Context())
   324  		defer cancel()
   325  		if cn, ok := w.(http.CloseNotifier); ok {
   326  			go func(done <-chan struct{}, closed <-chan bool) {
   327  				select {
   328  				case <-done:
   329  				case <-closed:
   330  					cancel()
   331  				}
   332  			}(ctx.Done(), cn.CloseNotify())
   333  		}
   334  		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
   335  		rctx, err := runtime.AnnotateContext(ctx, mux, req)
   336  		if err != nil {
   337  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   338  			return
   339  		}
   340  		resp, md, err := request_Quota_UpdateConfig_0(rctx, inboundMarshaler, client, req, pathParams)
   341  		ctx = runtime.NewServerMetadataContext(ctx, md)
   342  		if err != nil {
   343  			runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
   344  			return
   345  		}
   346  
   347  		forward_Quota_UpdateConfig_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
   348  
   349  	})
   350  
   351  	return nil
   352  }
   353  
   354  var (
   355  	pattern_Quota_CreateConfig_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 3, 0, 2, 2, 4, 3, 5, 3}, []string{"v1beta1", "quotas", "config", "name"}, ""))
   356  
   357  	pattern_Quota_DeleteConfig_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 3, 0, 2, 2, 4, 3, 5, 3}, []string{"v1beta1", "quotas", "config", "name"}, ""))
   358  
   359  	pattern_Quota_GetConfig_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 3, 0, 2, 2, 4, 3, 5, 3}, []string{"v1beta1", "quotas", "config", "name"}, ""))
   360  
   361  	pattern_Quota_ListConfigs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1beta1", "quotas"}, ""))
   362  
   363  	pattern_Quota_UpdateConfig_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 3, 0, 2, 2, 4, 3, 5, 3}, []string{"v1beta1", "quotas", "config", "name"}, ""))
   364  )
   365  
   366  var (
   367  	forward_Quota_CreateConfig_0 = runtime.ForwardResponseMessage
   368  
   369  	forward_Quota_DeleteConfig_0 = runtime.ForwardResponseMessage
   370  
   371  	forward_Quota_GetConfig_0 = runtime.ForwardResponseMessage
   372  
   373  	forward_Quota_ListConfigs_0 = runtime.ForwardResponseMessage
   374  
   375  	forward_Quota_UpdateConfig_0 = runtime.ForwardResponseMessage
   376  )