func request_FlowCombination_RpcPathNestedStream_2(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcPathNestedStreamClient, error) { var protoReq NestedProto if err := json.NewDecoder(req.Body).Decode(&protoReq.C); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } var ( val string ok bool err error _ = err ) val, ok = pathParams["a.str"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, err } if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcPathNestedStream_2); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } return client.RpcPathNestedStream(ctx, &protoReq) }
func request_FlowCombination_RpcBodyStream_6(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, error) { var protoReq NonEmptyProto var ( val string ok bool err error _ = err ) val, ok = pathParams["a"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a") } protoReq.A, err = runtime.String(val) if err != nil { return nil, err } if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcBodyStream_6); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } return client.RpcBodyStream(ctx, &protoReq) }
func request_FlowCombination_RpcPathSingleNestedRpc_0(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq SingleNestedProto var ( val string ok bool err error _ = err ) val, ok = pathParams["a.str"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, err } if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcPathSingleNestedRpc_0); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } return client.RpcPathSingleNestedRpc(ctx, &protoReq) }
func request_ABitOfEverythingService_Echo_2(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq sub.StringMessage if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_ABitOfEverythingService_Echo_2); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } return client.Echo(ctx, &protoReq) }
func request_FlowCombination_RpcBodyStream_2(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, error) { var protoReq NonEmptyProto if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcBodyStream_2); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } return client.RpcBodyStream(ctx, &protoReq) }
func request_FlowCombination_RpcBodyRpc_4(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq NonEmptyProto if err := json.NewDecoder(req.Body).Decode(&protoReq.C); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcBodyRpc_4); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } return client.RpcBodyRpc(ctx, &protoReq) }
func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq ABitOfEverything var ( val string ok bool err error _ = err ) val, ok = pathParams["float_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "float_value") } protoReq.FloatValue, err = runtime.Float32(val) if err != nil { return nil, err } val, ok = pathParams["double_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "double_value") } protoReq.DoubleValue, err = runtime.Float64(val) if err != nil { return nil, err } val, ok = pathParams["int64_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "int64_value") } protoReq.Int64Value, err = runtime.Int64(val) if err != nil { return nil, err } val, ok = pathParams["uint64_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "uint64_value") } protoReq.Uint64Value, err = runtime.Uint64(val) if err != nil { return nil, err } val, ok = pathParams["int32_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "int32_value") } protoReq.Int32Value, err = runtime.Int32(val) if err != nil { return nil, err } val, ok = pathParams["fixed64_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "fixed64_value") } protoReq.Fixed64Value, err = runtime.Uint64(val) if err != nil { return nil, err } val, ok = pathParams["fixed32_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "fixed32_value") } protoReq.Fixed32Value, err = runtime.Uint32(val) if err != nil { return nil, err } val, ok = pathParams["bool_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "bool_value") } protoReq.BoolValue, err = runtime.Bool(val) if err != nil { return nil, err } val, ok = pathParams["string_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "string_value") } protoReq.StringValue, err = runtime.String(val) if err != nil { return nil, err } val, ok = pathParams["uint32_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "uint32_value") } protoReq.Uint32Value, err = runtime.Uint32(val) if err != nil { return nil, err } val, ok = pathParams["sfixed32_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "sfixed32_value") } protoReq.Sfixed32Value, err = runtime.Int32(val) if err != nil { return nil, err } val, ok = pathParams["sfixed64_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "sfixed64_value") } protoReq.Sfixed64Value, err = runtime.Int64(val) if err != nil { return nil, err } val, ok = pathParams["sint32_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "sint32_value") } protoReq.Sint32Value, err = runtime.Int32(val) if err != nil { return nil, err } val, ok = pathParams["sint64_value"] if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "sint64_value") } protoReq.Sint64Value, err = runtime.Int64(val) if err != nil { return nil, err } if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_ABitOfEverythingService_Create_0); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } return client.Create(ctx, &protoReq) }
func TestPopulateParametersWithFilters(t *testing.T) { for _, spec := range []struct { values url.Values filter *utilities.DoubleArray want proto.Message }{ { values: url.Values{ "bool_value": {"true"}, "string_value": {"str"}, "repeated_value": {"a", "b", "c"}, }, filter: utilities.NewDoubleArray([][]string{ {"bool_value"}, {"repeated_value"}, }), want: &proto3Message{ StringValue: "str", }, }, { values: url.Values{ "nested.nested.bool_value": {"true"}, "nested.nested.string_value": {"str"}, "nested.string_value": {"str"}, "string_value": {"str"}, }, filter: utilities.NewDoubleArray([][]string{ {"nested"}, }), want: &proto3Message{ StringValue: "str", }, }, { values: url.Values{ "nested.nested.bool_value": {"true"}, "nested.nested.string_value": {"str"}, "nested.string_value": {"str"}, "string_value": {"str"}, }, filter: utilities.NewDoubleArray([][]string{ {"nested", "nested"}, }), want: &proto3Message{ Nested: &proto2Message{ StringValue: proto.String("str"), }, StringValue: "str", }, }, { values: url.Values{ "nested.nested.bool_value": {"true"}, "nested.nested.string_value": {"str"}, "nested.string_value": {"str"}, "string_value": {"str"}, }, filter: utilities.NewDoubleArray([][]string{ {"nested", "nested", "string_value"}, }), want: &proto3Message{ Nested: &proto2Message{ StringValue: proto.String("str"), Nested: &proto3Message{ BoolValue: true, }, }, StringValue: "str", }, }, } { msg := proto.Clone(spec.want) msg.Reset() err := runtime.PopulateQueryParameters(msg, spec.values, spec.filter) if err != nil { t.Errorf("runtime.PoplateQueryParameters(msg, %v, %v) failed with %v; want success", spec.values, spec.filter, err) continue } if got, want := msg, spec.want; !proto.Equal(got, want) { t.Errorf("runtime.PopulateQueryParameters(msg, %v, %v = %v; want %v", spec.values, spec.filter, got, want) } } }
func TestPopulateParameters(t *testing.T) { for _, spec := range []struct { values url.Values filter *utilities.DoubleArray want proto.Message }{ { values: url.Values{ "float_value": {"1.5"}, "double_value": {"2.5"}, "int64_value": {"-1"}, "int32_value": {"-2"}, "uint64_value": {"3"}, "uint32_value": {"4"}, "bool_value": {"true"}, "string_value": {"str"}, "repeated_value": {"a", "b", "c"}, }, filter: utilities.NewDoubleArray(nil), want: &proto3Message{ FloatValue: 1.5, DoubleValue: 2.5, Int64Value: -1, Int32Value: -2, Uint64Value: 3, Uint32Value: 4, BoolValue: true, StringValue: "str", RepeatedValue: []string{"a", "b", "c"}, }, }, { values: url.Values{ "float_value": {"1.5"}, "double_value": {"2.5"}, "int64_value": {"-1"}, "int32_value": {"-2"}, "uint64_value": {"3"}, "uint32_value": {"4"}, "bool_value": {"true"}, "string_value": {"str"}, "repeated_value": {"a", "b", "c"}, }, filter: utilities.NewDoubleArray(nil), want: &proto2Message{ FloatValue: proto.Float32(1.5), DoubleValue: proto.Float64(2.5), Int64Value: proto.Int64(-1), Int32Value: proto.Int32(-2), Uint64Value: proto.Uint64(3), Uint32Value: proto.Uint32(4), BoolValue: proto.Bool(true), StringValue: proto.String("str"), RepeatedValue: []string{"a", "b", "c"}, }, }, { values: url.Values{ "nested.nested.nested.repeated_value": {"a", "b", "c"}, "nested.nested.nested.string_value": {"s"}, "nested.nested.string_value": {"t"}, "nested.string_value": {"u"}, "nested_non_null.string_value": {"v"}, }, filter: utilities.NewDoubleArray(nil), want: &proto3Message{ Nested: &proto2Message{ Nested: &proto3Message{ Nested: &proto2Message{ RepeatedValue: []string{"a", "b", "c"}, StringValue: proto.String("s"), }, StringValue: "t", }, StringValue: proto.String("u"), }, NestedNonNull: proto2Message{ StringValue: proto.String("v"), }, }, }, { values: url.Values{ "uint64_value": {"1", "2", "3", "4", "5"}, }, filter: utilities.NewDoubleArray(nil), want: &proto3Message{ Uint64Value: 1, }, }, } { msg := proto.Clone(spec.want) msg.Reset() err := runtime.PopulateQueryParameters(msg, spec.values, spec.filter) if err != nil { t.Errorf("runtime.PoplateQueryParameters(msg, %v, %v) failed with %v; want success", spec.values, spec.filter, err) continue } if got, want := msg, spec.want; !proto.Equal(got, want) { t.Errorf("runtime.PopulateQueryParameters(msg, %v, %v = %v; want %v", spec.values, spec.filter, got, want) } } }